bool Game::ProtectedUpdate(AUDynArray<AUEntityId> &entities, float fDeltaTime) { bool bSuccess = true; assert(!m_bHaveProgramError); __try { for (size_t i=0; i<entities.Size(); ++i) { IAUEntity* pEnt = m_pEnv->sys->pEntitySystem->Get(entities[i]); if (pEnt) // Safety check in case entity was deleted during this update by another object { IAUUpdateable* pUpdateable = pEnt->GetUpdateable(); if (pUpdateable) { // If dropped here after a runtime failure, your crash was likely // somewhere directly in the pUpdatable object's Update method pUpdateable->Update(fDeltaTime); } } } } __except( RuntimeExceptionFilter() ) { bSuccess = false; } return bSuccess; }
virtual void DestroyGameObject( const char* name ) { IEntitySystem* pEntitySystem = PerModuleInterface::g_pSystemTable->pEntitySystem; IAUEntity* pEnt = pEntitySystem->Get(name); if (pEnt) { DestroyGameObject( pEnt->GetObject()->GetObjectId() ); } }
void Game::EntityUpdateProtector::ProtectedFunc() { for (size_t i=0; i<entities.Size(); ++i) { IAUEntity* pEnt = pEntitySystem->Get(entities[i]); if (pEnt) // Safety check in case entity was deleted during this update by another object { IAUUpdateable* pUpdateable = pEnt->GetUpdateable(); if (pUpdateable) { // If dropped here after a runtime failure, your crash was likely // somewhere directly in the pUpdatable object's Update method pUpdateable->Update(fDeltaTime); } } } }
void AURenderContext::Render( IEntitySystem* pEntitySystem ) { //loop through setting matrices and calling render. pEntitySystem->GetAll( g_entities ); for( size_t i = 0; i < g_entities.Size(); ++i ) { IAUEntity* pEntity = pEntitySystem->Get( g_entities[ i ] ); IAURenderable* pRenderable = pEntity->GetRenderable(); if( pRenderable ) { glPushMatrix(); glMatrixMode(GL_MODELVIEW); // Translation const AUVec3f& t = pEntity->GetPosition(); glTranslatef( t.x, t.y, t.z ); // Rotation float fglMatrix[16]; pEntity->GetOrientation().LoadglObjectMatrix(fglMatrix); glMultMatrixf(fglMatrix); // Scale glEnable(GL_NORMALIZE); // Needed so normals don't get wrecked by scaling - not sure how costly it is though const AUVec3f& s = pEntity->GetScale(); glScalef( s.x, s.y, s.z ); pRenderable->Render(); glPopMatrix(); } } }