Навёл порядок в тестах. Добавил тесты для мира. Исправил ошибку в SpawnActorFromClass
This commit is contained in:
@@ -18,7 +18,7 @@ std::shared_ptr<SaveMap> Actor::save()
|
||||
save->SaveObject("loc", loc_);
|
||||
save->SaveObject("rot", rot_);
|
||||
save->SaveObject("scale", scale_);
|
||||
save->SaveListStrings("tags", std::move(tags));
|
||||
save->SaveListStrings("tags", std::move(tags_));
|
||||
return save;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ void Actor::load(std::shared_ptr<SaveMap> save)
|
||||
loc_ = std::static_pointer_cast<Vector3D>(save->GetObject("loc"));
|
||||
rot_ = std::static_pointer_cast<Vector3D>(save->GetObject("rot"));
|
||||
scale_ = std::static_pointer_cast<Vector3D>(save->GetObject("scale"));
|
||||
tags = std::move(save->GetListString("tags"));
|
||||
tags_ = std::move(save->GetListString("tags"));
|
||||
}
|
||||
|
||||
void Actor::BeginPlay()
|
||||
@@ -52,10 +52,10 @@ void Actor::SetActorRotate(const Vector3D& rot) noexcept
|
||||
|
||||
void Actor::AddTag(const std::string& tag) noexcept
|
||||
{
|
||||
tags.push_back(tag);
|
||||
tags_.push_back(tag);
|
||||
}
|
||||
|
||||
void Actor::RemoveTag(const std::string& tag) noexcept
|
||||
{
|
||||
tags.remove(tag);
|
||||
tags_.remove(tag);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Actor : public ISave, public IRTTI
|
||||
|
||||
std::shared_ptr<Vector3D> loc_, rot_, scale_;
|
||||
|
||||
std::list<std::string> tags;
|
||||
std::list<std::string> tags_;
|
||||
|
||||
protected:
|
||||
virtual void OnDestroy();
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
void AddTag(const std::string& tag) noexcept;
|
||||
void RemoveTag(const std::string& tag) noexcept;
|
||||
const std::list<std::string>& GetTags() const { return tags; }
|
||||
const std::list<std::string>& GetTags() const { return tags_; }
|
||||
|
||||
std::shared_ptr<World> GetWorld() const { return world_; }
|
||||
const std::string& GetName() const { return name_; }
|
||||
|
||||
@@ -21,7 +21,7 @@ ISave* SaveMap::MakeObjectByName(const std::string& name)
|
||||
return factory.factory();
|
||||
}
|
||||
}
|
||||
throw std::runtime_error("Object not found");
|
||||
throw std::runtime_error("Object not found (" + name + ")");
|
||||
}
|
||||
|
||||
SaveMap::SaveMap(const char* class_name) : class_name(class_name)
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
std::shared_ptr<T> object = std::make_shared<T>();
|
||||
object->SetActorLocate(loc);
|
||||
object->SetActorRotate(rot);
|
||||
std::static_pointer_cast<Actor>(object)->world_ = this;
|
||||
std::static_pointer_cast<Actor>(object)->world_ = std::static_pointer_cast<World>(shared_from_this());
|
||||
std::static_pointer_cast<Actor>(object)->name_ = name;
|
||||
actors_map.try_emplace(name, object);
|
||||
return object;
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
void DestroyActor(std::weak_ptr<Actor> ptr);
|
||||
|
||||
template<class T, class Container = std::vector<T*>>
|
||||
template<class T, class Container = std::vector<std::weak_ptr<T>>>
|
||||
Container GetActorsByTag(std::string tag)
|
||||
{
|
||||
Container container;
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
for (auto& j : tags)
|
||||
{
|
||||
if (j == tag)
|
||||
container.push_back(i);
|
||||
container.push_back(i.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
std::weak_ptr<T> GetActorByID(const std::string& id)
|
||||
std::weak_ptr<T> GetActorByName(const std::string& name)
|
||||
{
|
||||
auto it = actors_map.find(id);
|
||||
auto it = actors_map.find(name);
|
||||
if (it == actors_map.end() || it->second == nullptr)
|
||||
return {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user