This commit is contained in:
Jiga228
2025-10-18 17:08:50 +07:00
parent d79258e191
commit 1ba310ba92
7 changed files with 21 additions and 25 deletions
+9 -9
View File
@@ -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);
}
+5 -5
View File
@@ -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;