本文整理汇总了C++中IEntitySystem::GetClassRegistry方法的典型用法代码示例。如果您正苦于以下问题:C++ IEntitySystem::GetClassRegistry方法的具体用法?C++ IEntitySystem::GetClassRegistry怎么用?C++ IEntitySystem::GetClassRegistry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntitySystem
的用法示例。
在下文中一共展示了IEntitySystem::GetClassRegistry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCountOfClass
//------------------------------------------------------------------------
int CInventory::GetCountOfClass(const char *className) const
{
int count = 0;
IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
IEntityClass* pClass = (className != NULL) ? pEntitySystem->GetClassRegistry()->FindClass( className ) : NULL;
if (pClass)
{
for (TInventoryCIt it = m_stats.slots.begin(); it != m_stats.slots.end(); ++it)
{
IEntity *pEntity = pEntitySystem->GetEntity(*it);
if ((pEntity != NULL) && (pEntity->GetClass() == pClass))
{
++count;
}
}
TInventoryVectorEx::const_iterator endEx = m_stats.accessorySlots.end();
for (TInventoryVectorEx::const_iterator cit = m_stats.accessorySlots.begin(); cit!=endEx; ++cit)
{
if (*cit == pClass)
{
count++;
}
}
}
return count;
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:30,代码来源:Inventory.cpp
示例2: SpawnEntity
//------------------------------------------------------------------------
void CVehicleActionEntityAttachment::SpawnEntity()
{
IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
assert(pEntitySystem);
IEntityClassRegistry* pClassRegistry = pEntitySystem->GetClassRegistry();
assert(pClassRegistry);
IEntityClass* pEntityClass = pClassRegistry->FindClass(m_entityClassName.c_str());
if (!pEntityClass)
return;
char pEntityName[256];
_snprintf(pEntityName, 256, "%s_%s", m_pVehicle->GetEntity()->GetName(), m_entityClassName.c_str());
pEntityName[sizeof(pEntityName)-1] = '\0';
SEntitySpawnParams params;
params.sName = pEntityName;
params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
params.pClass = pEntityClass;
IEntity* pEntity = pEntitySystem->SpawnEntity(params, true);
if (!pEntity)
{
m_entityId = 0;
return;
}
m_entityId = pEntity->GetId();
m_pVehicle->GetEntity()->AttachChild(pEntity);
pEntity->SetLocalTM(m_pHelper->GetVehicleTM());
m_isAttached = true;
}
示例3: GetAdditionalMinimapData
//////////////////////////////////////////////////////////////////////////
//
// Allows the game code to write game-specific data into the minimap xml
// file on level export. Currently used to export data to StatsTool
//
//////////////////////////////////////////////////////////////////////////
bool CEditorGame::GetAdditionalMinimapData(XmlNodeRef output)
{
string classes = g_pGameCVars->g_telemetryEntityClassesToExport;
if(!classes.empty())
{
// additional data relating to StatsTool
XmlNodeRef statsNode = output->findChild("StatsTool");
if(!statsNode)
{
statsNode = GetISystem()->CreateXmlNode("StatsTool");
output->addChild(statsNode);
}
else
{
statsNode->removeAllChilds();
}
// first build a list of entity classes from the cvar
std::vector<IEntityClass*> interestingClasses;
int curPos = 0;
string currentClass = classes.Tokenize(",",curPos);
IEntitySystem* pES = GetISystem()->GetIEntitySystem();
if(IEntityClassRegistry* pClassReg = pES->GetClassRegistry())
{
while (!currentClass.empty())
{
if(IEntityClass* pClass = pClassReg->FindClass(currentClass.c_str()))
{
interestingClasses.push_back(pClass);
}
currentClass = classes.Tokenize(",",curPos);
}
}
// now iterate through all entities and save the ones which match the classes
if(interestingClasses.size() > 0)
{
IEntityItPtr it = pES->GetEntityIterator();
while(IEntity* pEntity = it->Next())
{
if(stl::find(interestingClasses, pEntity->GetClass()))
{
XmlNodeRef entityNode = GetISystem()->CreateXmlNode("Entity");
statsNode->addChild(entityNode);
entityNode->setAttr("class", pEntity->GetClass()->GetName());
Vec3 pos = pEntity->GetWorldPos();
entityNode->setAttr("x", pos.x);
entityNode->setAttr("y", pos.y);
entityNode->setAttr("z", pos.z);
}
}
}
}
return true;
}
示例4: OnClientConnect
bool CGameRules::OnClientConnect(int channelId, bool isReset)
{
const float fTerrainSize = static_cast<float>(gEnv->p3DEngine->GetTerrainSize());
const float fTerrainElevation = gEnv->p3DEngine->GetTerrainElevation(fTerrainSize * 0.5f, fTerrainSize * 0.5f);
const Vec3 vSpawnLocation(fTerrainSize * 0.5f, fTerrainSize * 0.5f, fTerrainElevation + 15.0f);
IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
IEntityClass* pPlayerClass = pEntitySystem->GetClassRegistry()->FindClass("Player");
if (!pPlayerClass)
return false;
SEntitySpawnParams params;
params.sName = "Player";
params.vPosition = vSpawnLocation;
params.pClass = pPlayerClass;
if (channelId)
{
params.nFlags |= ENTITY_FLAG_NEVER_NETWORK_STATIC;
if (INetChannel* pNetChannel = gEnv->pGame->GetIGameFramework()->GetNetChannel(channelId))
{
if (pNetChannel->IsLocal())
{
params.id = LOCAL_PLAYER_ENTITY_ID;
}
}
}
IEntity* pPlayerEntity = pEntitySystem->SpawnEntity(params, false);
CGameObject* pGameObject = static_cast<CGameObject*>(pPlayerEntity->GetProxy(ENTITY_PROXY_USER));
// always set the channel id before initializing the entity
pGameObject->SetChannelId(channelId);
return pEntitySystem->InitEntity(pPlayerEntity, params);
}
示例5: CreateRope
//------------------------------------------------------------------------
EntityId CVehicleActionDeployRope::CreateRope(IPhysicalEntity* pLinkedEntity, const Vec3& highPos, const Vec3& lowPos)
{
IEntitySystem* pEntitySystem = gEnv->pEntitySystem;
assert(pEntitySystem);
char pRopeName[256];
_snprintf(pRopeName, 256, "%s_rope_%d", m_pVehicle->GetEntity()->GetName(), m_seatId);
pRopeName[sizeof(pRopeName)-1] = '\0';
SEntitySpawnParams params;
params.sName = pRopeName;
params.nFlags = ENTITY_FLAG_CLIENT_ONLY;
params.pClass = pEntitySystem->GetClassRegistry()->FindClass("RopeEntity");
IEntity* pRopeEntity = pEntitySystem->SpawnEntity(params, true);
if (!pRopeEntity)
return 0;
pRopeEntity->SetFlags(pRopeEntity->GetFlags() | ENTITY_FLAG_CASTSHADOW );
pRopeEntity->CreateProxy(ENTITY_PROXY_ROPE);
IEntityRopeProxy* pEntityRopeProxy = (IEntityRopeProxy*) pRopeEntity->GetProxy(ENTITY_PROXY_ROPE);
if (!pEntityRopeProxy)
{
pEntitySystem->RemoveEntity(pRopeEntity->GetId());
return 0;
}
IRopeRenderNode* pRopeNode = pEntityRopeProxy->GetRopeRendeNode();
assert(pRopeNode);
Vec3 ropePoints[2];
ropePoints[0] = highPos;
ropePoints[1] = lowPos;
IRopeRenderNode::SRopeParams m_ropeParams;
m_ropeParams.nFlags = IRopeRenderNode::eRope_CheckCollisinos | IRopeRenderNode::eRope_Smooth;
m_ropeParams.fThickness = 0.05f;
m_ropeParams.fAnchorRadius = 0.1f;
m_ropeParams.nNumSegments = 8;
m_ropeParams.nNumSides = 4;
m_ropeParams.nMaxSubVtx = 3;
m_ropeParams.nPhysSegments = 8;
m_ropeParams.mass = 1.0f;
m_ropeParams.friction = 2;
m_ropeParams.frictionPull = 2;
m_ropeParams.wind.Set(0,0,0);
m_ropeParams.windVariance = 0;
m_ropeParams.waterResistance = 0;
m_ropeParams.jointLimit = 0;
m_ropeParams.maxForce = 0;
m_ropeParams.airResistance = 0;
m_ropeParams.fTextureTileU = 1.0f;
m_ropeParams.fTextureTileV = 10.0f;
pRopeNode->SetParams(m_ropeParams);
pRopeNode->SetPoints(ropePoints, 2);
pRopeNode->SetEntityOwner(m_pVehicle->GetEntity()->GetId());
pRopeNode->LinkEndEntities(m_pVehicle->GetEntity()->GetPhysics(), NULL);
return pRopeEntity->GetId();
}