Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/ComponentManager.cpp
Show First 20 Lines • Show All 818 Lines • ▼ Show 20 Lines | entity_id_t CComponentManager::AddEntity(const std::wstring& templateName, entity_id_t ent) | ||||
// This also ensures that ent does not exist | // This also ensures that ent does not exist | ||||
CEntityHandle handle = AllocateEntityHandle(ent); | CEntityHandle handle = AllocateEntityHandle(ent); | ||||
// Construct a component for each child of the root element | // Construct a component for each child of the root element | ||||
const CParamNode::ChildrenMap& tmplChilds = tmpl->GetChildren(); | const CParamNode::ChildrenMap& tmplChilds = tmpl->GetChildren(); | ||||
for (CParamNode::ChildrenMap::const_iterator it = tmplChilds.begin(); it != tmplChilds.end(); ++it) | for (CParamNode::ChildrenMap::const_iterator it = tmplChilds.begin(); it != tmplChilds.end(); ++it) | ||||
{ | { | ||||
// Ignore attributes on the root element | // Ignore attributes on the root element | ||||
if (it->first.length() && it->first[0] == '@') | if (it->first.attribute) | ||||
continue; | continue; | ||||
CComponentManager::ComponentTypeId cid = LookupCID(it->first); | CComponentManager::ComponentTypeId cid = LookupCID(it->first); | ||||
if (cid == CID__Invalid) | if (cid == CID__Invalid) | ||||
{ | { | ||||
LOGERROR("Unrecognized component type name '%s' in entity template '%s'", it->first, utf8_from_wstring(templateName)); | LOGERROR("Unrecognized component type name '%s' in entity template '%s'", it->first.name, utf8_from_wstring(templateName)); | ||||
return INVALID_ENTITY; | return INVALID_ENTITY; | ||||
} | } | ||||
if (!AddComponent(handle, cid, it->second)) | if (!AddComponent(handle, cid, it->second)) | ||||
{ | { | ||||
LOGERROR("Failed to construct component type name '%s' in entity template '%s'", it->first, utf8_from_wstring(templateName)); | LOGERROR("Failed to construct component type name '%s' in entity template '%s'", it->first.name, utf8_from_wstring(templateName)); | ||||
return INVALID_ENTITY; | return INVALID_ENTITY; | ||||
} | } | ||||
// TODO: maybe we should delete already-constructed components if one of them fails? | // TODO: maybe we should delete already-constructed components if one of them fails? | ||||
} | } | ||||
CMessageCreate msg(ent); | CMessageCreate msg(ent); | ||||
PostMessage(ent, msg); | PostMessage(ent, msg); | ||||
▲ Show 20 Lines • Show All 292 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator