Game Development Reference
In-Depth Information
int GetNumActors()
{
EditorGame* pGame = (EditorGame*)g_pApp->m_pGame;
return ( pGame ) ? pGame->GetNumActors() : 0;
}
void GetActorList( int *ptr, int numActors )
{
EditorGame* pGame = (EditorGame*)g_pApp->m_pGame;
if ( pGame )
{
ActorMap::const_iterator itr;
int actorArrayIndex;
for ( itr = pGame->GetActorMap().begin(), actorArrayIndex = 0;
itr != pGame->GetActorMap().end() && actorArrayIndex < numActors;
++itr,
++actorArrayIndex )
{
ActorId actorId = itr->first;
ptr[actorArrayIndex] = actorId;
}
}
}
GetNumActors()
is pretty simple. It uses the global application layer pointer to get
to the game logic. Once it has a pointer to the game logic, it gets the number of
actors in the level and returns that. The reason why you need the number of actors
is that the C# editor application will be allocating space for an array of integers. The
editor will use the number of actors to determine how large of an array to allocate.
GetActorList()
fills that array with the actors in this level by iterating through the
actor data structure stored in the editor logic.
The next two functions get XML information from a specific actor.
int GetActorXmlSize ( ActorId actorId )
{
StrongActorPtr pActor = MakeStrongPtr(g_pApp->m_pGame->VGetActor(actorId));
if ( !pActor )
{
return 0;
}
std::string xml = pActor->ToXML();
return xml.length();
}