本文整理汇总了C++中CBaseEntity::GetHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ CBaseEntity::GetHandle方法的具体用法?C++ CBaseEntity::GetHandle怎么用?C++ CBaseEntity::GetHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBaseEntity
的用法示例。
在下文中一共展示了CBaseEntity::GetHandle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ClientEnterGame
void CGameServer::ClientEnterGame(int iClient)
{
TMsg(sprintf(tstring("Client %d (") + GameNetwork()->GetClientNickname(iClient) + ") entering game.\n", iClient));
if (GetGame())
GetGame()->OnClientEnterGame(iClient);
for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
{
CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
if (!pEntity)
continue;
::CreateEntity.RunCommand(sprintf(tstring("%s %d %d"), pEntity->GetClassName(), pEntity->GetHandle(), pEntity->GetSpawnSeed()), iClient);
}
CGameServerNetwork::UpdateNetworkVariables(iClient, true);
// Update entities after all creations have been run, so we don't refer to entities that haven't been created yet.
for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++)
{
CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
if (!pEntity)
continue;
pEntity->ClientUpdate(iClient);
}
GameNetwork()->CallFunction(iClient, "EnterGame");
GameNetwork()->CallFunction(iClient, "LoadingDone");
}
示例2: UpdateNetworkVariables
void CGameServerNetwork::UpdateNetworkVariables(int iClient, bool bForceAll)
{
if (!GameNetwork()->IsConnected())
return;
double flTime = GameServer()->GetGameTime();
size_t iMaxEnts = GameServer()->GetMaxEntities();
for (size_t i = 0; i < iMaxEnts; i++)
{
CBaseEntity* pEntity = CBaseEntity::GetEntity(i);
if (!pEntity)
continue;
const tchar* pszClassName = pEntity->GetClassName();
CEntityRegistration* pRegistration = NULL;
do
{
pRegistration = pEntity->GetRegisteredEntity(pszClassName);
TAssert(pRegistration);
if (!pRegistration)
break;
size_t iNetVarsSize = pRegistration->m_aNetworkVariables.size();
for (size_t j = 0; j < iNetVarsSize; j++)
{
CNetworkedVariableData* pVarData = &pRegistration->m_aNetworkVariables[j];
CNetworkedVariableBase* pVariable = pVarData->GetNetworkedVariableBase(pEntity);
if (!bForceAll)
{
if (!pVariable->IsDirty())
continue;
if (flTime - pVariable->m_flLastUpdate < pVarData->m_flUpdateInterval)
continue;
}
// For one, m_flLastUpdate needs to be a double
pVariable->m_flLastUpdate = (float)flTime;
// For two, it's shit.
TUnimplemented();
// Try some testing or something.
CNetworkParameters p;
p.ui1 = pEntity->GetHandle();
size_t iDataSize;
void* pValue = pVariable->Serialize(iDataSize);
if (net_replication_debug.GetBool())
{
if (iDataSize >= 4)
TMsg(tstring("Updating ") + pVarData->GetName() + sprintf(tstring(" (%x) (%f) (%d)\n"), *(unsigned int*)pValue, *(float*)pValue, *(int*)pValue));
else
TMsg(tstring("Updating ") + pVarData->GetName() + "\n");
}
p.CreateExtraData(iDataSize + strlen(pVarData->GetName())+1);
strcpy((char*)p.m_pExtraData, pVarData->GetName());
memcpy((unsigned char*)(p.m_pExtraData) + strlen(pVarData->GetName())+1, pValue, iDataSize);
// UV stands for UpdateValue
GameNetwork()->CallFunctionParameters(iClient, "UV", &p);
// Only reset the dirty flag if all clients got the message.
if (iClient == NETWORK_TOCLIENTS)
pVariable->SetDirty(false);
}
pszClassName = pRegistration->m_pszParentClass;
} while (pszClassName);
}
}