Удалил UType::object_ptr и заменил его на комбинацию из std::shared_ptr и std::weak_ptr из-за ужасной реализации.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
|
||||
World::World(GameInstance& game_instance) : game_instance(game_instance)
|
||||
World::World(GameInstance& game_instance) : game_instance_(game_instance)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ std::shared_ptr<SaveMap> World::save()
|
||||
void World::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
std::vector<std::string> actors_IDs = save->GetVectorString("ActorsIDs");
|
||||
std::list<UType::object_ptr<Actor>> act = std::move(reinterpret_cast<std::list<UType::object_ptr<Actor>>&>(save->GetListObject("Actors")));
|
||||
std::list<std::shared_ptr<Actor>> act = std::move(reinterpret_cast<std::list<std::shared_ptr<Actor>>&>(save->GetListObject("Actors")));
|
||||
|
||||
size_t i_id = 0;
|
||||
for (auto& i : act)
|
||||
@@ -46,13 +46,13 @@ void World::load(std::shared_ptr<SaveMap> save)
|
||||
}
|
||||
}
|
||||
|
||||
void World::DestroyActor(UType::object_ptr<Actor> ptr)
|
||||
void World::DestroyActor(std::weak_ptr<Actor> ptr)
|
||||
{
|
||||
if (ptr.get() == nullptr)
|
||||
std::shared_ptr<Actor> actor = ptr.lock();
|
||||
if (actor.get() == nullptr)
|
||||
return;
|
||||
|
||||
std::string name = ptr->GetName();
|
||||
std::string name = actor->GetName();
|
||||
actor->OnDestroy();
|
||||
actors_map.erase(name);
|
||||
ptr->OnDestroy();
|
||||
ptr.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user