void Game::DeleteObjects()
{
    m_pConsole->DestroyContext();

    delete IObjectUtils::GetUniqueObject( "MainObject" );


#ifdef _DEBUG
    // Do a check to verify that all objects have been destroyed at this point
    int totalObjectCount = 0;
    AUDynArray<IObjectConstructor*> constructors;
    m_pEnv->sys->pObjectFactorySystem->GetAll(constructors);
    for (size_t i=0; i<constructors.Size(); ++i)
    {
        IObjectConstructor* pConstructor = constructors[i];

        size_t count = pConstructor->GetNumberConstructedObjects();

        // Need to iterate through all objects and check if they're valid
        // since GetNumConstructedObjects isn't accurate, can return some null pointers
        for (size_t j=0; j<count; ++j)
        {
            if (pConstructor->GetConstructedObject(j) != NULL)
            {
                totalObjectCount++;
            }
        }

        // Do an assert check here so it's easy to figure out which object type wasn't deleted
        AU_ASSERT( totalObjectCount == 0 );
    }

#endif
}
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;
}
void EntitySystem::Reset()
{
	AUDynArray<AUEntityId> entities;
	GetAll(entities);
	for (size_t i = 0; i < entities.Size(); ++i)
	{
		Destroy(entities[i]);
	}

	assert(m_Entities.size() == 0);
}
Beispiel #4
0
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();
		}
	}

}