本文整理汇总了C++中XmlNodeRef::setAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeRef::setAttr方法的具体用法?C++ XmlNodeRef::setAttr怎么用?C++ XmlNodeRef::setAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNodeRef
的用法示例。
在下文中一共展示了XmlNodeRef::setAttr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*static*/ void CAntiCheatManager::Xml_SetCheatType(XmlNodeRef xmlNode, TCheatType eCheatType)
{
xmlNode->setAttr("cheat_type", s_cheatTypeNames[eCheatType]);
}
示例2: LoadMethod
CMethodBase* LoadMethod(const char* value_)
{
//Self.test_ns::AgentActionTest::Action2(0)
char agentIntanceName[kNameLength];
char agentClassName[kNameLength];
char methodName[kNameLength];
const char* pBeginP = ParseMethodNames(value_, agentIntanceName, agentClassName, methodName);
//propertyName = FormatString("%s::%s", agentClassName, methodName);
CStringID agentClassId(agentClassName);
CStringID methodId(methodName);
CMethodBase* method = Agent::CreateMethod(agentClassId, methodId);
if (!method)
{
BEHAVIAC_LOGWARNING("No Method %s::%s registered\n", agentClassName, methodName);
BEHAVIAC_ASSERT(0, "No Method %s::%s registered\n", agentClassName, methodName);
}
else
{
if (Agent::IsNameRegistered(agentIntanceName))
{
method->SetInstanceNameString(agentIntanceName, PT_INSTANCE);
}
else
{
//BEHAVIAC_ASSERT(agentIntanceName == "Self");
}
BEHAVIAC_ASSERT(method, "No Method %s::%s registered", agentClassName, methodName);
const char* params = pBeginP;
BEHAVIAC_ASSERT(params[0] == '(');
behaviac::vector<behaviac::string> tokens;
{
int len = strlen(params);
BEHAVIAC_ASSERT (params[len - 1] == ')');
behaviac::string text = behaviac::string(params + 1, len - 2);
//behaviac::StringUtils::SplitIntoArray(text, ",", tokens);
ParseForParams(text, tokens);
}
if (tokens.size() > 0)
{
XmlNodeRef xmlNode = CreateXmlNode("Method");
for (uint32_t i = 0; i < tokens.size(); ++i)
{
const behaviac::string& token = tokens[i];
behaviac::string attriName = FormatString("param%d", i + 1);
xmlNode->setAttr(attriName.c_str(), token);
}
CTextNode node(xmlNode);
method->LoadFromXML(0, node);
}
}
return method;
}
示例3: Load
bool CScriptSurfaceType::Load( int nId )
{
m_nId = nId;
IScriptSystem *pScriptSystem = gEnv->pScriptSystem;
SmartScriptTable mtlTable;
if (!pScriptSystem->GetGlobalValue("Materials", mtlTable))
{
return false;
}
//////////////////////////////////////////////////////////////////////////
if (!pScriptSystem->ExecuteFile( m_script,true ))
{
GetISystem()->Warning(
VALIDATOR_MODULE_3DENGINE,VALIDATOR_WARNING,
VALIDATOR_FLAG_FILE|VALIDATOR_FLAG_SCRIPT,
m_script.c_str(),
"'%s' failed to load surface type definition script",m_name.c_str() );
return false;
}
if (!mtlTable->GetValue( m_name,m_pScriptTable ))
return false;
XmlNodeRef matNode = m_root->newChild("SurfaceType");
matNode->setAttr( "name",m_name );
// Load physics params.
SmartScriptTable pPhysicsTable,props;
float fBouncyness = 0.0f;
float fFriction = 1.0f;
int iPiercingResistence = sf_max_pierceable; // physics traces range 0-15
int imatBreakable = -1, bManuallyBreakable=0;
m_iBreakability=0; m_nHitpoints=0; m_breakEnergy=0;
if (m_pScriptTable->GetValue("physics",pPhysicsTable))
{
pPhysicsTable->GetValue("friction",fFriction);
pPhysicsTable->GetValue("bouncyness",fBouncyness);
pPhysicsTable->GetValue("breakable_id",imatBreakable);
if (pPhysicsTable->GetValue("pierceability",iPiercingResistence))
{
if(iPiercingResistence>sf_max_pierceable)
iPiercingResistence = sf_max_pierceable;
}
int nBreakable2d = 0;
int bNoCollide = 0;
pPhysicsTable->GetValue("no_collide", bNoCollide);
if (pPhysicsTable->GetValue("break_energy",m_breakEnergy))
{
bManuallyBreakable = sf_manually_breakable;
m_iBreakability = 2;
pPhysicsTable->GetValue("hit_points",m_nHitpoints);
} else if (m_pScriptTable->GetValue("breakable_2d",props))
{
nBreakable2d = 1;
bManuallyBreakable = sf_manually_breakable;
m_iBreakability = 1;
props->GetValue("break_energy",m_breakEnergy);
props->GetValue("hit_points",m_nHitpoints);
}
m_nFlags &= ~SURFACE_TYPE_NO_COLLIDE;
if (bNoCollide)
m_nFlags |= SURFACE_TYPE_NO_COLLIDE;
XmlNodeRef physNode = matNode->newChild("Physics");
physNode->setAttr( "friction",fFriction );
physNode->setAttr( "elasticity",fBouncyness );
physNode->setAttr( "breakable_id",imatBreakable );
physNode->setAttr( "pierceability",iPiercingResistence );
physNode->setAttr( "no_collide",bNoCollide );
physNode->setAttr( "break_energy",m_breakEnergy );
physNode->setAttr( "hit_points",m_nHitpoints );
physNode->setAttr( "breakable_2d",nBreakable2d );
}
SmartScriptTable pAITable;
if (m_pScriptTable->GetValue("AI",pAITable))
{
XmlNodeRef aiNode = matNode->newChild("AI");
float fImpactRadius = 1;
float fFootStepRadius = 1;
float proneMult = 1;
float crouchMult = 1;
float movingMult = 1;
pAITable->GetValue( "fImpactRadius",fImpactRadius );
pAITable->GetValue( "fFootStepRadius",fFootStepRadius );
pAITable->GetValue( "proneMult",proneMult );
pAITable->GetValue( "crouchMult",crouchMult );
pAITable->GetValue( "movingMult",movingMult );
aiNode->setAttr( "fImpactRadius",fImpactRadius );
aiNode->setAttr( "fFootStepRadius",fFootStepRadius );
aiNode->setAttr( "proneMult",proneMult );
aiNode->setAttr( "crouchMult",crouchMult );
aiNode->setAttr( "movingMult",movingMult );
}
gEnv->pPhysicalWorld->SetSurfaceParameters(m_nId,fBouncyness,fFriction,
//.........这里部分代码省略.........
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:101,代码来源:SurfaceTypes.cpp
示例4: MakeXmlNodeStruct
XmlNodeRef MakeXmlNodeStruct(const char* str, const behaviac::string& typeNameT)
{
behaviac::string src = str;
//{color=0;id=;type={bLive=false;name=0;weight=0;};}
//the first char is '{'
//the last char is '}'
behaviac::string::size_type posCloseBrackets = behaviac::StringUtils::Private::SkipPairedBrackets(src);
BEHAVIAC_ASSERT(posCloseBrackets != behaviac::string::npos);
bool bIsStructMember = false;
XmlNodeRef xmlNode = CreateXmlNode(typeNameT.c_str());
//{color=0;id=;type={bLive=false;name=0;weight=0;};}
behaviac::string::size_type posBegin = 1;
behaviac::string::size_type posEnd = src.find_first_of(';', posBegin);
while (posEnd != behaviac::string::npos)
{
BEHAVIAC_ASSERT(src[posEnd] == ';');
//the last one might be empty
if (posEnd > posBegin)
{
behaviac::string::size_type posEqual = src.find_first_of('=', posBegin);
BEHAVIAC_ASSERT(posEqual > posBegin);
int length = posEqual - posBegin;
behaviac::string memmberName = src.substr(posBegin, length);
behaviac::string memmberValue;
char c = src[posEqual + 1];
if (c != '{')
{
length = posEnd - posEqual - 1;
memmberValue = src.substr(posEqual + 1, length);
}
else
{
bIsStructMember = true;
const char* pStructBegin = src.c_str();
pStructBegin += posEqual + 1;
const char* posCloseBrackets_ = behaviac::StringUtils::Private::SkipPairedBrackets(pStructBegin);
length = posCloseBrackets_ - pStructBegin + 1;
memmberValue = src.substr(posEqual + 1, length);
posEnd = posEqual + 1 + length;
}
if (bIsStructMember)
{
XmlNodeRef memberNode = MakeXmlNodeStruct(memmberValue.c_str(), memmberName);
xmlNode->addChild(memberNode);
}
else
{
//behaviac::string memmberNameFull = typeNameT + "::" + memmberName;
//xmlNode->setAttr(memmberNameFull.c_str(), memmberValue.c_str());
xmlNode->setAttr(memmberName.c_str(), memmberValue.c_str());
}
}
bIsStructMember = false;
//skip ';'
posBegin = posEnd + 1;
//{color=0;id=;type={bLive=false;name=0;weight=0;};}
posEnd = src.find_first_of(';', posBegin);
if (posEnd > posCloseBrackets)
{
break;
}
}
return xmlNode;
}