Refactor
This commit is contained in:
@@ -8,7 +8,7 @@ void Actor::OnDestroy()
|
||||
{
|
||||
}
|
||||
|
||||
Actor::Actor() : loc(new Vector3D), rot(new Vector3D), scale(new Vector3D)
|
||||
Actor::Actor() : loc_(new Vector3D), rot_(new Vector3D), scale_(new Vector3D)
|
||||
{
|
||||
SetType(Classes::Actor);
|
||||
}
|
||||
@@ -16,17 +16,17 @@ Actor::Actor() : loc(new Vector3D), rot(new Vector3D), scale(new Vector3D)
|
||||
std::shared_ptr<SaveMap> Actor::save()
|
||||
{
|
||||
return std::make_shared<SaveMap>("Actor")
|
||||
->SaveObject("loc", static_cast<UType::object_ptr<ISave>>(loc))
|
||||
->SaveObject("rot", static_cast<UType::object_ptr<ISave>>(rot))
|
||||
->SaveObject("scale", UType::object_ptr<ISave>(scale))
|
||||
->SaveObject("loc", static_cast<UType::object_ptr<ISave>>(loc_))
|
||||
->SaveObject("rot", static_cast<UType::object_ptr<ISave>>(rot_))
|
||||
->SaveObject("scale", UType::object_ptr<ISave>(scale_))
|
||||
->SaveListStrings("tags", std::move(tags));
|
||||
}
|
||||
|
||||
void Actor::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
loc = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("loc"));
|
||||
rot = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("rot"));
|
||||
scale = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("scale"));
|
||||
loc_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("loc"));
|
||||
rot_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("rot"));
|
||||
scale_ = static_cast<UType::object_ptr<Vector3D>>(save->GetObject("scale"));
|
||||
tags = std::move(save->GetListString("tags"));
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ void Actor::Tick(double delta_time)
|
||||
|
||||
void Actor::SetActorLocate(const Vector3D& loc) noexcept
|
||||
{
|
||||
*this->loc = loc;
|
||||
*this->loc_ = loc;
|
||||
OnSetActorLocate.Call(loc);
|
||||
}
|
||||
|
||||
void Actor::SetActorRotate(const Vector3D& rot) noexcept
|
||||
{
|
||||
*this->rot = rot;
|
||||
*this->rot_ = rot;
|
||||
OnSetActorRotate.Call(rot);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class Actor : public ISave, public IRTTI
|
||||
World* world_;
|
||||
std::string name_;
|
||||
|
||||
UType::object_ptr<Vector3D> loc, rot, scale;
|
||||
UType::object_ptr<Vector3D> loc_, rot_, scale_;
|
||||
|
||||
std::list<std::string> tags;
|
||||
|
||||
@@ -30,8 +30,8 @@ public:
|
||||
Delegate<const Vector3D&> OnSetActorRotate;
|
||||
|
||||
#pragma region ISave
|
||||
virtual std::shared_ptr<SaveMap> save() override;
|
||||
virtual void load(std::shared_ptr<SaveMap> save) override;
|
||||
std::shared_ptr<SaveMap> save() override;
|
||||
void load(std::shared_ptr<SaveMap> save) override;
|
||||
#pragma endregion
|
||||
|
||||
virtual void BeginPlay();
|
||||
@@ -42,14 +42,14 @@ public:
|
||||
* Вызывает делегат OnSetActorLocate
|
||||
*/
|
||||
void SetActorLocate(const Vector3D& loc) noexcept;
|
||||
inline const UType::object_ptr<Vector3D> GetActorLocate() const { return loc; }
|
||||
inline const UType::object_ptr<Vector3D> GetActorLocate() const { return loc_; }
|
||||
|
||||
/*
|
||||
* Изменяет ориентацию в пространстве
|
||||
* Вызывает делегат OnSetActorRotate
|
||||
*/
|
||||
void SetActorRotate(const Vector3D& rot) noexcept;
|
||||
inline const UType::object_ptr<Vector3D> GetActorRotate() const { return rot; }
|
||||
inline const UType::object_ptr<Vector3D> GetActorRotate() const { return rot_; }
|
||||
|
||||
void AddTag(const std::string& tag) noexcept;
|
||||
void RemoveTag(const std::string& tag) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user