|
|
|
|
@ -16,15 +16,14 @@ namespace lunarium
|
|
|
|
|
Entity::Entity(World& w)
|
|
|
|
|
: mHandle(entt::null), mWorld(w), mParent(0), mParentSet(false)
|
|
|
|
|
{
|
|
|
|
|
mUUID = UUID::GetNewID();
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Entity::Entity(World& w, LUUID uuid, entt::entity handle)
|
|
|
|
|
: mHandle(handle), mWorld(w), mUUID(uuid)
|
|
|
|
|
{
|
|
|
|
|
Init();
|
|
|
|
|
}
|
|
|
|
|
// Entity::Entity(World& w, entt::entity handle)
|
|
|
|
|
// : mHandle(handle), mWorld(w)
|
|
|
|
|
// {
|
|
|
|
|
// Init();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
void Entity::Init()
|
|
|
|
|
{
|
|
|
|
|
@ -35,11 +34,14 @@ namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
Logger::Warn(LogCategory::GAME_SYSTEM, "Requested entity handle was not used");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddComponent<UUIDComponent>(UUID::GetNewID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LUUID Entity::GetUUID() const
|
|
|
|
|
LUUID Entity::GetUUID()
|
|
|
|
|
{
|
|
|
|
|
return mUUID;
|
|
|
|
|
return GetComponent<UUIDComponent>().UUID;
|
|
|
|
|
// return mUUID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entt::entity Entity::GetEnttHandle() const
|
|
|
|
|
@ -68,7 +70,7 @@ namespace lunarium
|
|
|
|
|
void Entity::AddChild(LUUID child)
|
|
|
|
|
{
|
|
|
|
|
Entity* e = mWorld.GetEntity(child);
|
|
|
|
|
e->AddComponent<ParentEntityComponent>(mUUID);
|
|
|
|
|
e->AddComponent<ParentEntityComponent>(GetUUID());
|
|
|
|
|
|
|
|
|
|
if (!HasComponent<ChildrenComponent>())
|
|
|
|
|
{
|
|
|
|
|
@ -151,7 +153,7 @@ namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
#if !BUILD_NO_EDITOR // Only does this when this is an editor build
|
|
|
|
|
|
|
|
|
|
node["UUID"] = mUUID;
|
|
|
|
|
// node["UUID"] = mUUID;
|
|
|
|
|
node["name"] = mName;
|
|
|
|
|
|
|
|
|
|
auto& components = node["components"];
|
|
|
|
|
@ -299,7 +301,7 @@ namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
#if !BUILD_NO_EDITOR // Only does this when this is an editor build
|
|
|
|
|
|
|
|
|
|
mUUID = node["UUID"].get<u64>();
|
|
|
|
|
//mUUID = node["UUID"].get<u64>();
|
|
|
|
|
mName = node["name"].get<std::string>();
|
|
|
|
|
|
|
|
|
|
// TODO: Load components
|
|
|
|
|
@ -313,7 +315,11 @@ namespace lunarium
|
|
|
|
|
if ("UUIDComponent" == comp_type_name)
|
|
|
|
|
{
|
|
|
|
|
LUUID uuid = comp["UUID"].get<u64>();
|
|
|
|
|
AddComponent<UUIDComponent>(uuid);
|
|
|
|
|
//AddComponent<UUIDComponent>(uuid);
|
|
|
|
|
if (HasComponent<UUIDComponent>())
|
|
|
|
|
{
|
|
|
|
|
GetComponent<UUIDComponent>().UUID = uuid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("TagComponent" == comp_type_name)
|
|
|
|
|
@ -433,8 +439,8 @@ namespace lunarium
|
|
|
|
|
|
|
|
|
|
bool Entity::IsValidNode(nlohmann::ordered_json& node)
|
|
|
|
|
{
|
|
|
|
|
if (node["UUID"].is_null()) { return false; }
|
|
|
|
|
if (!node["UUID"].is_number()) { return false; }
|
|
|
|
|
// if (node["UUID"].is_null()) { return false; }
|
|
|
|
|
// if (!node["UUID"].is_number()) { return false; }
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|