Move to object_ptr

This commit is contained in:
Jiga228
2025-10-17 21:39:30 +07:00
parent 136235749a
commit 137522cefa
8 changed files with 58 additions and 48 deletions
+8 -8
View File
@@ -16,17 +16,17 @@ Actor::Actor()
std::shared_ptr<SaveMap> Actor::save()
{
return std::make_shared<SaveMap>("Actor")
->SaveObject("loc", &loc)
->SaveObject("rot", &rot)
->SaveObject("scale", &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 = *reinterpret_cast<Vector3D*>(save->GetObject("loc"));
rot = *reinterpret_cast<Vector3D*>(save->GetObject("rot"));
scale = *reinterpret_cast<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"));
}
@@ -41,13 +41,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);
}
+4 -5
View File
@@ -7,6 +7,7 @@
#include "Game/SaveMap/ISave.h"
#include "Delegate/Delegate.h"
#include "Math/Vector.hpp"
#include "Types/object_ptr.hpp"
class World;
GENERATE_META(Actor)
@@ -15,9 +16,7 @@ class Actor : public ISave, public IRTTI
{
World* world_;
Vector3D loc;
Vector3D rot;
Vector3D scale;
UType::object_ptr<Vector3D> loc, rot, scale;
std::list<std::string> tags;
@@ -42,14 +41,14 @@ public:
* Вызывает делегат OnSetActorLocate
*/
void SetActorLocate(const Vector3D& loc) noexcept;
inline const Vector3D& GetActorLocate() const { return loc; }
inline const UType::object_ptr<Vector3D> GetActorLocate() const { return loc; }
/*
* Изменяет ориентацию в пространстве
* Вызывает делегат OnSetActorRotate
*/
void SetActorRotate(const Vector3D& rot) noexcept;
inline const 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;