本文整理汇总了C++中CGameObject::Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CGameObject::Deserialize方法的具体用法?C++ CGameObject::Deserialize怎么用?C++ CGameObject::Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGameObject
的用法示例。
在下文中一共展示了CGameObject::Deserialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InstantiatePrototype
CGameObject* CFactory::InstantiatePrototype(const string &AProtoName, const string &AName /*= ""*/)
{
CXMLNode *xml = GetPrototypeXML(AProtoName);
if (!xml)
{
Log("ERROR", "Can't create prototype instance: no such prototype: '%s'", AProtoName.c_str());
return NULL;
}
CGameObject *result = New<CGameObject>(AName);
if (AName.empty())
result->SetName(AProtoName + itos(result->GetID()));
result->Prototype = true;
result->Deserialize(xml);
SetRecursionLimit(AProtoName, from_string<int>(xml->SafeGetAttribute("RecursionLimit", "-1")));
TraversePrototypeNode(xml, result, result);
result->FinalizeCreation();
Log("INFO", "Prototype INSTANTIATED: '%s', instance name: '%s'", AProtoName.c_str(), result->GetName().c_str());
return result;
}
示例2: TraversePrototypeNode
void CFactory::TraversePrototypeNode(CXMLNode *ANode, CGameObject *AObject, CGameObject *CurrentProto)
{
CGameObject *child;
string NodeName;
string ChildName;
string LocalChildName;
for (CXMLChildrenList::Iterator it = ANode->Children.Begin(); it != ANode->Children.End(); ++it)
{
if ((*it)->GetType() != CXMLNode::XML_NODE_TYPE_NORMAL)
continue;
NodeName = (*it)->GetName();
int recursionsLeft = GetRecursionsLeft(NodeName);
if (recursionsLeft < 1)
{
if (recursionsLeft == -1)
Log("ERROR", "Unlimited recursive reference of prototype '%s'", NodeName.c_str());
continue;
}
IncreaseUsedCount(NodeName);
ChildName = (*it)->SafeGetAttribute("Name");
LocalChildName = (*it)->SafeGetAttribute("LocalName");
child = CreateGameObject(NodeName, ChildName, false);
if (!child)
{
Log("ERROR", "Can't create object of class '%s' from prototype", NodeName.c_str());
continue;
}
CurrentProto->AddLocalName(LocalChildName, child);
child->Deserialize(*it);
AObject->Attach(child);
if (!child->IsPrototype())
child->FinalizeCreation();
TraversePrototypeNode(*it, child, CurrentProto);
DecreaseUsedCount(NodeName);
}
}