コード例 #1
0
	void CreateIndividualBlackboards( IGameObject* pGameObject )
	{
		ObjectId id = pGameObject->GetObjectId();

		// Individual
		TIndividualMap::iterator it = m_BlackboardIndividual.find(id);
		AU_ASSERT(it == m_BlackboardIndividual.end());
		if (it == m_BlackboardIndividual.end())
		{
			const char* text = 0;
			switch (pGameObject->GetGameObjectType())
			{
			case EGO_WBC: text = "BB_Individual_WBC"; break;
			case EGO_RBC: text = "BB_Individual_RBC"; break;
			case EGO_VIRUS: text = "BB_Individual_Virus"; break;
			case EGO_INFECTED: text = "BB_Individual_Infected"; break;
            default: AU_ASSERT(false);
			}

			m_BlackboardIndividual[id] = IObjectUtils::CreateObject( text )->GetObjectId();
		}

		// IndividualCommon
		it = m_BlackboardIndividualCommon.find(id);
		AU_ASSERT(it == m_BlackboardIndividualCommon.end());
		if (it == m_BlackboardIndividualCommon.end())
		{
			m_BlackboardIndividualCommon[id] = IObjectUtils::CreateObject( "BB_Individual_Common" )->GetObjectId();
		}
	}
コード例 #2
0
	virtual void Serialize( ISimpleSerializer *pSerializer )
	{
		AU_ASSERT(pSerializer);

		SERIALIZE(m_bDoUpdate);
		SerializeObjectsList( pSerializer );
	}
コード例 #3
0
	virtual void Update( float deltaTime )
	{	
		AU_ASSERT(m_pBehaviorTree);
		m_pBehaviorTree->Execute(this);
		
		AU_ASSERT(m_pBehavior);
		IBehavior* pBehavior = m_pBehavior; //Demo
		
		pBehavior->Update(deltaTime);

		UpdateScale();
		m_scaleModulationTime += deltaTime;
		
		//m_pRenMesh->SetColor( AUColor(1,1,1) ); // Demo

		SetRotation((float)M_PI_4 * 0.5f * deltaTime); // Demo
	}
コード例 #4
0
	virtual void Serialize(ISimpleSerializer *pSerializer)
	{
		AU_ASSERT(pSerializer);
		IEntityObject::Serialize(pSerializer);
		SERIALIZEIOBJPTR(m_pSelectedObject);
		
		SerializeObjectsList( pSerializer);
	}
コード例 #5
0
	void ModifyTeamCount( EGameTeam team, int delta )
	{
		IBlackboard* pTeam = GetBlackboardTeam(team);
		
		switch (team)
		{
		case EGT_IMMUNE: ((BB_Team_Immune*)pTeam)->team_size += delta; break;
		case EGT_INFECTION: ((BB_Team_Infection*)pTeam)->team_size += delta; break;
        default: AU_ASSERT(false);
		}
	}
コード例 #6
0
	void ModifyGroupCount( EGameObject type, int delta )
	{
		IBlackboard* pGroup = GetBlackboardGroup(type);

		switch (type)
		{
		case EGO_WBC: ((BB_Group_WBC*)pGroup)->group_size += delta; break;
		case EGO_RBC: ((BB_Group_RBC*)pGroup)->group_size += delta; break;
		case EGO_VIRUS: ((BB_Group_Virus*)pGroup)->group_size += delta; break;
		case EGO_INFECTED: ((BB_Group_Infected*)pGroup)->group_size += delta; break;
        default: AU_ASSERT(false);
		}
	}
コード例 #7
0
	virtual void Serialize(ISimpleSerializer *pSerializer)
	{
		AU_ASSERT(pSerializer);
		IEntityObject::Serialize(pSerializer);
		SERIALIZE(m_ImageFile);
		SERIALIZE(m_fMinViewTime);
		SERIALIZE(m_fFadeInTime);
		SERIALIZE(m_fFadeOutTime);
		SERIALIZE(m_fTimeDisplayed);
		SERIALIZE(m_fFadeOutStartTime);
		SERIALIZE(m_bAutoClose);
		SERIALIZE(m_bCloseRequested);
		SERIALIZE(m_bReadyToClose);
	}
コード例 #8
0
	void CreateSharedBlackboards()
	{
		// Global
		AU_ASSERT(!m_pBlackboardGlobal);
		IObjectUtils::CreateObject( &m_pBlackboardGlobal, "BB_Global" );

		// Team
		m_BlackboardTeam[EGT_IMMUNE] = IObjectUtils::CreateObject( "BB_Team_Immune" )->GetObjectId();
		m_BlackboardTeam[EGT_INFECTION] = IObjectUtils::CreateObject( "BB_Team_Infection" )->GetObjectId();
		
		// Group
		m_BlackboardGroup[EGO_WBC] = IObjectUtils::CreateObject( "BB_Group_WBC" )->GetObjectId();
		m_BlackboardGroup[EGO_RBC] = IObjectUtils::CreateObject( "BB_Group_RBC" )->GetObjectId();
		m_BlackboardGroup[EGO_VIRUS] = IObjectUtils::CreateObject( "BB_Group_Virus" )->GetObjectId();
		m_BlackboardGroup[EGO_INFECTED] = IObjectUtils::CreateObject( "BB_Group_Infected" )->GetObjectId();
	}
コード例 #9
0
	virtual void GetAll( EGameObject type, IAUDynArray<ObjectId> &objects ) const
	{
		AU_ASSERT(type < EGO_COUNT);
		if (type < EGO_COUNT)
		{
			size_t count = m_GameObjects[type].size();

			objects.Resize(count);
			TGameObjects::const_iterator it = m_GameObjects[type].begin();
			TGameObjects::const_iterator itEnd = m_GameObjects[type].end();
			for(int i = 0; it != itEnd; ++it, ++i)
			{
				objects[i] = (*it)->GetObjectId();
			}
		}	
	}
コード例 #10
0
	void DoInit(bool bFirstTime)
	{
		m_pGameManager = (IGameManager*)IObjectUtils::GetUniqueInterface( "GameManager", IID_IGAMEMANAGER );
		m_pBlackboardManager= (IBlackboardManager*)IObjectUtils::GetUniqueInterface( "BlackboardManager", IID_IBLACKBOARDMANAGER );
		m_pGlobalParameters = m_pGameManager->GetGlobalParameters();
		m_pGameObjectParams = &(m_pGlobalParameters->go[m_gameObjectType]);

		m_gameTeam = m_pGameObjectParams->team;
		SetModel( m_pGameObjectParams->model.c_str() );
		m_collisionRadius = m_pGameObjectParams->collision_radius;

		if (bFirstTime)
		{
			SetColor( m_bIsSelected ? m_pGameObjectParams->color_highlight : m_pGameObjectParams->color_normal);
			m_scaleModulationTime = (float)(rand()*2*M_PI/RAND_MAX);
		}
		else
		{
			SetColor( m_color ); // Set render mesh to serialised color
		}

		if (!m_pBehaviorTree)
		{
			IBehaviorTreeManager* pBTManager = (IBehaviorTreeManager*)IObjectUtils::GetUniqueInterface( "BehaviorTreeManager", IID_IBEHAVIORTREEMANAGER );

			m_pBehaviorTree = pBTManager->GetTree( m_pGameObjectParams->behavior_tree.c_str() );
			AU_ASSERT(m_pBehaviorTree);
		}

		//* Demo
		if (m_rotationAxis.IsZero())
		{
			m_rotationAxis = AUVec3f((float)rand()/RAND_MAX - 0.5f, (float)rand()/RAND_MAX - 0.5f, (float)rand()/RAND_MAX - 0.5f);
			m_rotationAxis.Normalise();
			SetRotation((float)(rand()*2*M_PI/RAND_MAX - M_PI));
		}
		//*/

		m_pEntity->SetUpdateable( this );
	}
コード例 #11
0
	virtual void SetImage( const char* imageFile )
	{
		AU_ASSERT(imageFile);
		m_ImageFile = imageFile;
		if (m_pSplashElement)
		{
			m_pSplashElement->SetAttribute("src", imageFile);

			// Position element correctly so that it is centered
			PerModuleInterface::g_pSystemTable->pGame->GetWindowSize( m_WindowSize[0], m_WindowSize[1] );

			char buff[16];
			int left;
			left = (int)( (m_WindowSize[0] - m_pSplashElement->GetClientWidth()) * 0.5f );
            _snprintf_s(buff, sizeof(buff), _TRUNCATE, "%d",left);
			m_pSplashElement->SetProperty("left", buff);

			int top;
			top = (int)( (m_WindowSize[1] - m_pSplashElement->GetClientHeight()) * 0.5f );
            _snprintf_s(buff, sizeof(buff), _TRUNCATE, "%d",top);
			m_pSplashElement->SetProperty("top", buff);
		}
	}
コード例 #12
0
	virtual void Serialize(ISimpleSerializer *pSerializer)
	{
		AU_ASSERT(pSerializer);
		IEntityObject::Serialize(pSerializer);
		SERIALIZE(m_trees);
	}
コード例 #13
0
	virtual void Serialize(ISimpleSerializer *pSerializer)
	{
		AU_ASSERT(pSerializer);
		SERIALIZE(m_fWorldCenteringDist);
		SerializeObjectsList( pSerializer );
	}
コード例 #14
0
void ObjectFactorySystem::CompleteConstructorSwap( ProtectedObjectSwapper& swapper )
{
    if( swapper.HasHadException() && PHASE_DELETEOLD != swapper.m_ProtectedPhase )
    {
        if( m_pLogger )
        {
            m_pLogger->LogError( "Exception during object swapping, switching back to previous objects." );
            switch( swapper.m_ProtectedPhase  )
            {
            case PHASE_NONE:
                AU_ASSERT( false );
                break;
            case PHASE_SERIALIZEOUT:
                m_pLogger->LogError( "\tError occured during serialize out old objects phase." );
                break;
            case PHASE_CONSTRUCTNEW:
                m_pLogger->LogError( "\tError occured during constructing new objects phase." );
                break;
            case PHASE_SERIALIZEIN:
                m_pLogger->LogError( "\tError occured during serialize into the new objects phase." );
                break;
            case PHASE_AUTOCONSTRUCTSINGLETONS:
                m_pLogger->LogError( "\tError occured during auto construct singletons phase." );
                break;
            case PHASE_INITANDSERIALIZEOUTTEST:
                if( m_bTestSerialization )
                {
                    m_pLogger->LogError( "\tError occured during Initialization and serialize test of new objects phase." );
                }
                else
                {
                    m_pLogger->LogError( "\tError occured during Initialization phase." );
                }
                break;
           case PHASE_DELETEOLD:
                break;
             }
        }

        //swap back to new constructors before everything is serialized back in
        m_Constructors = swapper.m_ConstructorsOld;
        if( PHASE_SERIALIZEOUT != swapper.m_ProtectedPhase )
        {
            //serialize back with old objects - could cause exception which isn't handled, but hopefully not.
            swapper.m_Serializer.SetIsLoading( true );
            for( size_t i = 0; i < m_Constructors.size(); ++i )
            {
                IObjectConstructor* pConstructor = m_Constructors[i];
                for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
                {
                    // Iserialize new object
                    IObject* pObject = pConstructor->GetConstructedObject( objId );
                    if (pObject)
                    {
                        swapper.m_Serializer.Serialize( pObject );
                    }
                }
            }

            // Do a second pass, initializing objects now that they've all been serialized
            for( size_t i = 0; i < m_Constructors.size(); ++i )
            {
                IObjectConstructor* pConstructor = m_Constructors[i];
                for( PerTypeObjectId objId = 0; objId < pConstructor->GetNumberConstructedObjects(); ++ objId )
                {
                    IObject* pObject = pConstructor->GetConstructedObject( objId );
                    if (pObject)
                    {
                        pObject->Init(false);
                    }
                }
            }
        }
    }
    else
    {
        if( m_pLogger ) m_pLogger->LogInfo( "Object swap completed");
        if( swapper.HasHadException() && PHASE_DELETEOLD == swapper.m_ProtectedPhase )
        {
            if( m_pLogger ) m_pLogger->LogError( "Exception during object destruction of old objects, leaking." );
        }
    }

    // Notify any listeners that constructors have changed
    TObjectFactoryListeners::iterator it = m_Listeners.begin();
    TObjectFactoryListeners::iterator itEnd = m_Listeners.end();
    while (it != itEnd)
    {
        (*it)->OnConstructorsAdded();
        ++it;
    }
}