virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Activate:
			if (IsPortActive(pActInfo, 0)) 
			{
				IActor* pActor = GetAIActor(pActInfo);
				if(pActor)
				{
					float health = pActor->GetHealth();
					float minH = GetPortFloat(pActInfo, 1);
					float maxH = GetPortFloat(pActInfo, 2);
					ActivateOutput(pActInfo, 0, minH <= health && health <= maxH);
				}
				else
				{
					CryLogAlways("CFlowActorCheckHealth - No Entity or Entity not an Actor!");
				}
			}
		}
	}
Exemplo n.º 2
0
	void Init(SActivationInfo* const pActInfo)
	{
		if (gEnv->pAudioSystem != NULL)
		{
			GetRtpcID(pActInfo);

			m_oRequest.pData = &m_oRequestData;
			m_oRequestData.nControlID = m_nRtpcID;

			float fValue = GetPortFloat(pActInfo, eIn_RtpcValue);
			SetValue(pActInfo->pEntity, fValue, true);
		}
	}
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
	{
#if !defined(_RELEASE)
		if (event == eFE_Activate)
		{
			if (IsPortActive(pActInfo, eIP_Draw))
			{
				IPersistantDebug* pPersistentDebug = CCryAction::GetCryAction()->GetIPersistantDebug();
				if (pPersistentDebug)
				{
					const Vec3 pos = GetPortVec3(pActInfo, eIP_Pos);
					const float radius = GetPortFloat(pActInfo, eIP_Radius);
					const float time = GetPortFloat(pActInfo, eIP_Time);
					const ColorF color = GetPortVec3(pActInfo, eIP_Color);

					pPersistentDebug->Begin("FG_Sphere", false);
					pPersistentDebug->AddSphere(pos, radius, color, time);
				}
			}
		}
#endif
	}
	void Start( SActivationInfo* pActInfo )
	{
		IEntity *pEnt = pActInfo->pEntity;
		if(!pEnt)
			return;

		m_bForceFinishAsTooNear = false;
		m_position = m_coorSys==CS_WORLD ? pEnt->GetWorldPos() : pEnt->GetPos();
		m_startPos = m_position;
		m_lastFrameTime = gEnv->pTimer->GetFrameStartTime().GetSeconds();
		m_startTime = m_lastFrameTime;
		ReadDestinationPosFromInput( pActInfo );
		m_easeOutDistance = GetPortFloat(pActInfo, IN_EASEOUT);
		m_easeInDistance = GetPortFloat(pActInfo, IN_EASEIN);
		ReadSpeedFromInput( pActInfo );
		if(m_easeOutDistance < 0.0f) m_easeOutDistance = 0.0f;
		m_stopping = false;

		pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
		m_bActive = true;
		ActivateOutput(pActInfo, OUT_START, true);
	}
    virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
    {
        switch (event)
        {
        case eFE_Activate:
        {
            ITimeOfDay* pTOD = gEnv->p3DEngine->GetTimeOfDay();
            if (pTOD == 0)
                return;

            if (IsPortActive(pActInfo,IN_SET))
            {
                const bool bForceUpdate = GetPortBool(pActInfo, IN_FORCEUPDATE);
                pTOD->SetTime(GetPortFloat(pActInfo, IN_TIME), bForceUpdate);
                ActivateOutput(pActInfo, OUT_CURTIME, pTOD->GetTime());
            }
            if (IsPortActive(pActInfo,IN_GET))
            {
                ActivateOutput(pActInfo, OUT_CURTIME, pTOD->GetTime());
            }
            if (IsPortActive(pActInfo,IN_SET_SPEED))
            {
                ITimeOfDay::SAdvancedInfo info;
                pTOD->GetAdvancedInfo(info);
                info.fAnimSpeed = GetPortFloat(pActInfo, IN_SPEED);
                pTOD->SetAdvancedInfo(info);
                ActivateOutput(pActInfo, OUT_CURSPEED, info.fAnimSpeed);
            }
            if (IsPortActive(pActInfo,IN_GET_SPEED))
            {
                ITimeOfDay::SAdvancedInfo info;
                pTOD->GetAdvancedInfo(info);
                ActivateOutput(pActInfo, OUT_CURSPEED, info.fAnimSpeed);
            }
        }
        break;
        }
    }
Exemplo n.º 6
0
	void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		if (event == eFE_Activate)
		{
			RadioChatterModule* radioChatterModule = gGameAIEnv.radioChatterModule;

			if (IsPortActive(pActInfo, IN_Enable))
			{
				radioChatterModule->SetEnabled(true);
				ActivateOutput(pActInfo, OUT_Enabled, true);
			}

			if (IsPortActive(pActInfo, IN_Disable))
			{
				radioChatterModule->SetEnabled(false);
				ActivateOutput(pActInfo, OUT_Disabled, true);
			}

			if (IsPortActive(pActInfo, IN_Set) || IsPortActive(pActInfo, IN_Enable))
			{
				const float minimumSilenceDuration = GetPortFloat(pActInfo, IN_MinimumSilenceDuration);
				const float maximumSilenceDuration = GetPortFloat(pActInfo, IN_MaximumSilenceDuration);
				const string& chatterSoundName = GetPortString(pActInfo, IN_SoundName);

				if (minimumSilenceDuration < 0.0f || maximumSilenceDuration < 0.0f)
					radioChatterModule->SetDefaultSilenceDuration();
				else
					radioChatterModule->SetSilenceDuration(minimumSilenceDuration, maximumSilenceDuration);

				if (chatterSoundName.empty())
					radioChatterModule->SetDefaultSound();
				else
					radioChatterModule->SetSound(chatterSoundName);

				ActivateOutput(pActInfo, OUT_Set, true);
			}
		}
	}
Exemplo n.º 7
0
	virtual void ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
	{
		CCamera camera(gEnv->pSystem->GetViewCamera());
		Vec3    pos(camera.GetPosition());
		Vec3    dir(camera.GetViewdir());
		float   roll(camera.GetAngles().z); // GetAngles() returns YPR angles - roll is in z component

		switch (event)
		{
		case eFE_Initialize:
			pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, GetPortBool(pActInfo, 3));
			break;
		case eFE_Activate:
		{
			if (InputEntityIsLocalPlayer( pActInfo ))
			{
				if (IsPortActive(pActInfo, 0))
					pos = GetPortVec3(pActInfo, 0);
				if (IsPortActive(pActInfo, 1))
					dir = GetPortVec3(pActInfo, 1);
				if (IsPortActive(pActInfo, 2))
					roll = GetPortFloat(pActInfo, 2);

				if (IsPortActive(pActInfo, 3))
				{
					pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, GetPortBool(pActInfo, 3));
				}

				if (dir.len2() > 0.0f)
				{
					dir.Normalize();
					camera.SetMatrix(CCamera::CreateOrientationYPR(CCamera::CreateAnglesYPR(dir, roll)));
					camera.SetPosition(pos);
					gEnv->pSystem->SetViewCamera(camera);
				}
			}
		}
		break;
		case eFE_Update:
		{
			if (InputEntityIsLocalPlayer( pActInfo ))
			{
				ActivateOutput(pActInfo, 0, pos);
				ActivateOutput(pActInfo, 1, dir);
				ActivateOutput(pActInfo, 2, roll);
			}
		}
		break;
		}
	}
    virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
    {
        switch (event)
        {
        case eFE_Initialize:
        {
            pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
        }
        break;

        case eFE_Update:
        {
            float fPeriod = GetPortFloat(pActInfo,IN_PERIOD);
            CTimeValue time = gEnv->pTimer->GetFrameStartTime();
            CTimeValue dt = time - m_lastTickTime;
            if (dt.GetSeconds() >= fPeriod)
            {
                m_lastTickTime = time;
                ++m_count;
                ActivateOutput( pActInfo, OUT_COUNT, m_count );
                if (m_count >= GetPortInt( pActInfo, IN_LIMIT ))
                {
                    pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
                    ActivateOutput( pActInfo, OUT_FINISHED, GetPortAny( pActInfo, IN_START ));
                }
            }
        }
        break;
        case eFE_Activate:
        {
            if (IsPortActive(pActInfo,IN_START))
            {
                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
                m_count = 0;
                m_lastTickTime = gEnv->pTimer->GetFrameStartTime();
            }

            if (IsPortActive(pActInfo,IN_STOP))
            {
                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
            }

            if (IsPortActive(pActInfo,IN_CONTINUE))
            {
                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
            }
        }
        break;
        }
    }
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
	{
		switch (event)
		{
		case eFE_Initialize:
			{
				break;
			}
		case eFE_Activate:
			{
				if (IsPortActive(pActInfo, eIn_Set))
				{
					const string& variableName = GetPortString(pActInfo, eIn_VariableName);

					if (variableName.empty())
					{
						CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CAction:DRS_SetVariable: Cannot be executed without a Variable Name.");
						return;
					}

					const string& collectionName = GetPortString(pActInfo, eIn_VariableCollectionName);
					EntityId entityID = GetPortEntityId(pActInfo, eIn_EntityID);

					DRS::IVariableCollection* variableCollection = GetVariableCollection(entityID, collectionName);

					if (variableCollection)
					{
						float newVariableValue = GetPortFloat(pActInfo, eIn_FloatValue);
						variableCollection->SetVariableValue(variableName, newVariableValue, true, GetPortFloat(pActInfo, eIn_ResetTime));
						ActivateOutput(pActInfo, eOut_VariableCollectionName, variableCollection->GetName().GetText());
					}
				}
				break;
			}
		}
	}
Exemplo n.º 10
0
void CFlashUIMCVisibleBaseNode::ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
{
	if (event == eFE_Initialize)
	{
		UpdateObjectDesc( GetPortString( pActInfo, GetInputPort(eI_UIMovieClip)), pActInfo, m_isTemplate );
	}
	else if (event == eFE_Activate)
	{
		if (IsPortActive( pActInfo, GetInputPort(eI_UIMovieClip)))
		{
			UpdateObjectDesc( GetPortString( pActInfo, GetInputPort(eI_UIMovieClip)), pActInfo, m_isTemplate );
		}

		if (IsTemplate() && !UpdateTmplDesc( GetPortString( pActInfo, GetInputPort(eI_TemplateInstanceName)), pActInfo ))
			return;

		if (GetElement())
		{
			const int instanceId = GetPortInt( pActInfo, GetInputPort(eI_InstanceID));
			if (IsPortActive ( pActInfo, GetInputPort(eI_Set)))
			{
				const bool  bVis  = GetPortBool( pActInfo, GetInputPort(eI_Visible));
				const float alpha = clamp_tpl( GetPortFloat( pActInfo, GetInputPort(eI_Alpha)), 0.0f, 1.f );

				SPerInstanceCall2< bool, float > caller;
				caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIMCVisibleBaseNode::SetValues), bVis, alpha );

				ActivateOutput( pActInfo, eO_OnSet, true );
				ActivateOutput( pActInfo, eO_Visible, bVis );
				ActivateOutput( pActInfo, eO_Alpha, alpha );
			}
			else if (IsPortActive( pActInfo, GetInputPort(eI_Get)))
			{
				bool  bVis  = false;
				float alpha = 0.f;

				SPerInstanceCall2< bool &, float & > caller;
				if (!caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIMCVisibleBaseNode::GetValues), bVis, alpha, false ))
				{
					UIACTION_WARNING( "FG: UIElement \"%s\" called get Array for multiple instances! (passed instanceId %i), referenced at node \"%s\"", GetElement()->GetName(),instanceId, pActInfo->pGraph->GetNodeTypeName( pActInfo->myID ));
				}

				ActivateOutput( pActInfo, eO_Visible, bVis );
				ActivateOutput( pActInfo, eO_Alpha, alpha );
			}
		}
	}
}
Exemplo n.º 11
0
	virtual void ProcessEvent( EFlowEvent event,SActivationInfo* pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
		{
			CreateView();
			return;
		}
		break;
		case eFE_Activate:
		{
			if (IsPortActive(pActInfo, EIP_Enable))
			{
				if (m_pView == NULL)
					CreateView();

				if (m_pView == NULL)
					return;

				if (pActInfo->pEntity == NULL)
					return;

				SViewParams params;

				params.justActivated  = true;
				params.fov            = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				params.blend          = GetPortBool(pActInfo, EIP_Blend);
				params.blendFOVOffset = DEG2RAD(GetPortFloat(pActInfo, EIP_BlendFOVOffset));
				params.blendFOVSpeed  = GetPortFloat(pActInfo, EIP_BlendFOVSpeed);
				params.blendPosOffset = GetPortVec3(pActInfo, EIP_BlendPosOffset);
				params.blendPosSpeed  = GetPortFloat(pActInfo, EIP_BlendPosSpeed);
				params.blendRotSpeed  = GetPortFloat(pActInfo, EIP_BlendRotSpeed);
				params.blendRotOffset = Quat::CreateRotationXYZ(static_cast<Ang3>(GetPortVec3(pActInfo, EIP_BlendRotOffset)));

				m_pView->SetCurrentParams(params);
				m_pView->LinkTo(pActInfo->pEntity);

				m_pViewSystem->SetActiveView(m_pView);
			}
			else if (IsPortActive(pActInfo, EIP_Disable))
			{
				if (m_pLocalPlayerView)
					m_pViewSystem->SetActiveView(m_pLocalPlayerView);
			}
			else if (IsPortActive(pActInfo, EIP_FOV))
			{
				SViewParams params;
				params.fov = DEG2RAD(GetPortFloat(pActInfo, EIP_FOV));
				m_pView->SetCurrentParams(params);
			}
		}
		break;
		}
	}
    virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
    {
        switch (event)
        {
        case eFE_Initialize:
        {
            bool bPaused = GetPortBool(pActInfo,IN_PAUSED);
            pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, !bPaused );
            m_last = gEnv->pTimer->GetFrameStartTime();
        }
        break;

        case eFE_Update:
        {
            if (GetPortBool(pActInfo,IN_PAUSED))
                return;

            float fPeriod = GetPortFloat(pActInfo,IN_PERIOD);
            CTimeValue time = gEnv->pTimer->GetFrameStartTime();
            CTimeValue dt = time - m_last;
            if (dt.GetSeconds() >= fPeriod)
            {
                m_last = time;
                int nMin = GetPortInt(pActInfo,IN_MIN);
                int nMax = GetPortInt(pActInfo,IN_MAX);
                m_nCurrentCount++;
                if (m_nCurrentCount < nMin)
                    m_nCurrentCount = nMin;
                if (m_nCurrentCount > nMax)
                {
                    m_nCurrentCount = nMin;
                }
                ActivateOutput( pActInfo,OUT_OUT,m_nCurrentCount );
            }
        }
        break;
        case eFE_Activate:
        {
            if (IsPortActive(pActInfo,IN_PAUSED))
            {
                bool bPaused = GetPortBool(pActInfo,IN_PAUSED);
                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, !bPaused );
            }
        }
        break;
        }
    }
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
			m_errorLogSent = false;
			break;

		case eFE_Activate:
			if (IsPortActive(pActInfo, 0)) 
			{
				IEntitySystem* pESys = gEnv->pEntitySystem;
				EntityId id1 = GetPortEntityId(pActInfo, 1);
				EntityId id2 = GetPortEntityId(pActInfo, 2);
				IEntity* pEnt1 = pESys->GetEntity( id1 );
				IEntity* pEnt2 = pESys->GetEntity( id2 );
				IEntity* pGraphEntity = pESys->GetEntity( pActInfo->pGraph->GetGraphEntity( 0 ) );
				if (pEnt1==NULL || pEnt2==NULL)
				{
					if (!m_errorLogSent)
					{
						GameWarning("[flow] Entity::EntitiesInRange - flowgraph entity: %d:'%s' - at least one of the input entities is invalid!. Entity1: %d:'%s'    Entity2:  %d:'%s'", 
							pActInfo->pGraph->GetGraphEntity( 0 ), pGraphEntity ? pGraphEntity->GetName() : "<NULL>",
							id1, pEnt1 ? pEnt1->GetName() : "<NULL>", id2, pEnt2 ? pEnt2->GetName() : "<NULL>" );
						m_errorLogSent = true;
					}
				}
				else
				{
					const float range = GetPortFloat(pActInfo, 3);
					const float distance = pEnt1->GetWorldPos().GetDistance(pEnt2->GetWorldPos()) ;
					const bool inRange = (distance <= range);
					ActivateOutput(pActInfo, 0, inRange);
					ActivateOutput(pActInfo, 1 + (inRange ? 1 : 0), true);
					ActivateOutput(pActInfo, 3, distance);

					const Vec3 distVector = pEnt2->GetPos() - pEnt1->GetPos();
					ActivateOutput(pActInfo, 4, distVector);
					m_errorLogSent = false;
				}
			}
			break;
		}
	}
Exemplo n.º 14
0
	void ProcessEvent(EFlowEvent event, SActivationInfo* pActivationInfo)
	{
		switch (event)
		{
		case eFE_Initialize:
		{
			SetAutoUpdate(pActivationInfo, GetPortBool(pActivationInfo, eIP_Auto));

			break;
		}

		case eFE_Activate:
		{
			if (IsPortActive(pActivationInfo, eIP_Auto))
			{
				SetAutoUpdate(pActivationInfo, GetPortBool(pActivationInfo, eIP_Auto));
			}
			else if (IsPortActive(pActivationInfo, eIP_Freq))
			{
				m_frequency = GetPortFloat(pActivationInfo, eIP_Freq);
			}
			else if (IsPortActive(pActivationInfo, eIP_Sync))
			{
				Sync(pActivationInfo);
			}

			break;
		}

		case eFE_Update:
		{
			CTimeValue delta = gEnv->pTimer->GetFrameStartTime() - m_prevTime;

			if (delta.GetSeconds() >= m_frequency)
			{
				Sync(pActivationInfo);
			}

			break;
		}
		}
	}
	//////////////////////////////////////////////////////////////////////////
	// when the inputs are set to work with "time" instead of speed, we just calculate speed from that time value
	void CalcSpeedFromTimeInput( SActivationInfo* pActInfo )
	{
		assert( GetPortInt(pActInfo, IN_VALUETYPE)==VT_TIME );
		float movementDuration = GetPortFloat( pActInfo, IN_VALUE );
		float timePassed = gEnv->pTimer->GetFrameStartTime().GetSeconds() - m_startTime;
		float movementDurationLeft = movementDuration - timePassed;
		if (movementDurationLeft < 0.0001f) movementDurationLeft = 0.0001f;
		Vec3 movement = m_destination - m_position;
		float distance = movement.len();

		if ( m_easeInDistance + m_easeOutDistance > distance )  // make sure they dont overlap
			m_easeInDistance = distance - m_easeOutDistance;
		float distanceNoEase = distance - ( m_easeInDistance + m_easeOutDistance );

		const float factorAverageSpeedEase = 0.5f; // not real because is not lineal, but is good enough for this
		float realEaseInDistance = max( m_easeInDistance - m_easeInDistance * EASE_MARGIN_FACTOR, 0.f );
		float realEaseOutDistance = max( m_easeOutDistance - m_easeOutDistance * EASE_MARGIN_FACTOR, 0.f );

 		m_topSpeed = ( ( realEaseInDistance  / factorAverageSpeedEase )  + distanceNoEase + ( realEaseOutDistance / factorAverageSpeedEase ) ) / movementDurationLeft;  // this comes just from V = S / T;
	}
Exemplo n.º 16
0
void CFlashUIDelayNode::ProcessEvent( EFlowEvent event, SActivationInfo * pActInfo )
{
	switch (event)
	{
	case eFE_Initialize:
		pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, false);
		break;
	case eFE_Activate:
		pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, true);
		m_fTime = gEnv->pTimer->GetAsyncCurTime();
		break;
	case eFE_Update:
		if (m_fTime + GetPortFloat(pActInfo, eI_Delay) < gEnv->pTimer->GetAsyncCurTime())
		{
			ActivateOutput(pActInfo, eO_Done, GetPortAny(pActInfo, eI_Start));
			pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID, false);
		}
		break;
	}
}
Exemplo n.º 17
0
	void StartFader(SActivationInfo * pActInfo)
	{
		CHUDFader* pFader = GetFader(pActInfo);
		if (pFader != 0)
		{
			const float fDuration = GetPortFloat(pActInfo, m_direction < 0 ? EIP_InTime : EIP_OutTime);
			ColorF col;
			const Vec3 fadeColor = GetPortVec3(pActInfo, EIP_Color);
			const bool bUseCurColor = GetPortBool(pActInfo, EIP_UseCurrentColor);
			col.r = fadeColor[0];
			col.g = fadeColor[1];
			col.b = fadeColor[2];
			col.a = m_direction < 0 ? 0.0f : 1.0f;
			if (m_direction < 0)
				m_ticket = pFader->FadeIn(col, fDuration, bUseCurColor);
			else
				m_ticket =pFader->FadeOut(col, fDuration, GetPortString(pActInfo, EIP_TextureName), bUseCurColor);
			m_bNeedFaderStop = true;
		}
	}
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
			{
				m_bActive = false;
				m_actInfo = *pActInfo;
				Register(true);
			}
			break;

		case eFE_Activate:
			{
				if (IsPortActive(pActInfo, EIP_Enable))
					Register(true);
				if (IsPortActive(pActInfo, EIP_Disable))
					Register(false);
			}
			break;

		case eFE_Update:
			{
				if (!m_bFinished)
				{
					float fTimeout = GetPortFloat(&m_actInfo, EIP_Timeout);
					CTimeValue curTime = gEnv->pTimer->GetFrameStartTime();
					float elapsedTime = (curTime - m_activationTime).GetSeconds();
					if (elapsedTime > fTimeout)
					{
						Finish();
						ActivateOutput(&m_actInfo, EOP_TimedOut, true);
					}
				}
			}
			break;
		}

	}
Exemplo n.º 19
0
void CFlowNode_ColorGradient::ProcessEvent(EFlowEvent event, SActivationInfo* activationInformation)
{
	//Preload texture
	if(event==IFlowNode::eFE_PrecacheResources && m_pTexture==NULL)
	{
		const string texturePath = GetPortString(activationInformation, eInputPorts_TexturePath);

		const uint32 COLORCHART_TEXFLAGS = FT_NOMIPS |  FT_DONT_STREAM | FT_DONT_RESIZE | FT_STATE_CLAMP;

		m_pTexture = gEnv->pRenderer->EF_LoadTexture(texturePath.c_str(), COLORCHART_TEXFLAGS);
		
		//CryLogAlways("CFlowNode_ColorGradient 0x%p: Precache texture %s", this, texturePath.c_str());
	}

	if (event==IFlowNode::eFE_Activate && IsPortActive(activationInformation, eIP_Trigger))
	{
		const string texturePath = GetPortString(activationInformation, eInputPorts_TexturePath);
		const float timeToFade = GetPortFloat(activationInformation, eInputPorts_TransitionTime);

		g_pGame->GetColorGradientManager().TriggerFadingColorGradient(texturePath, timeToFade);
	}
}
Exemplo n.º 20
0
/// Actually runs the test
bool CFlowNode_FeatureTest::Start()
{
	bool result = false;

	if(!m_ready)
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Test %s is being forced to run despite not being ready.", Name());

	if(!m_running)
	{
		if(m_labelProfileData)
		{
			string labelName = Name();
			labelName += "_start";
			AddUserMarker(labelName.c_str());
		}

		result = StartNextTestRun();

		if(result)
		{
			// Check the max time value to ensure a timeout is set
			float maxTime = GetPortFloat(&m_actInfo, eInputPorts_MaxTime);

			if(maxTime <= 0.0f)
				CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Test %s is been run with max time set to %f - test may never end!", Name(), maxTime);
		}
		else
		{
			CryWarning(VALIDATOR_MODULE_FLOWGRAPH, VALIDATOR_WARNING, "Test %s failed to start! Have you already run it?", Name());
		}
	}
	else
	{
		CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Feature test %s already running (ignoring run request).", Name());
	}

	return result;
}
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Activate:
			if (IsPortActive(pActInfo, 0)) 
			{
				IActor* pActor = GetAIActor(pActInfo);
				if(pActor)
				{
					if (!pActor->IsDead())
					{
						pActor->SetHealth( GetPortFloat(pActInfo, 1) );
						ActivateOutput(pActInfo, 0, pActor->GetHealth()); // use pActor->GetHealth (might have been clamped to maxhealth]
					}
				}
				else
				{
					GameWarning("CFlowActorSetHealth - No Entity or Entity not an actor!");
				}
			}
		}
	}
Exemplo n.º 22
0
	virtual void OnIterStart(SActivationInfo *pActInfo)
	{
		const int type = GetPortInt(pActInfo, EIP_Type);
		const Vec3& center(GetPortVec3(pActInfo, EIP_Pos));
		const float range = GetPortFloat(pActInfo, EIP_Range);
		const float rangeSq = range * range;

		const Vec3 min(center.x-range, center.y-range, center.z-range);
		const Vec3 max(center.x+range, center.y+range, center.z+range);

		IPhysicalWorld *pWorld = gEnv->pPhysicalWorld;
		IPhysicalEntity **ppList = NULL;
		int	numEnts = pWorld->GetEntitiesInBox(min,max,ppList,ent_all);
		for (int i = 0; i < numEnts; ++i)
		{
			const EntityId id = pWorld->GetPhysicalEntityId(ppList[i]);
			const EEntityType entityType = GetEntityType(id);
			if (IsValidType(type, entityType))
			{
				AddEntity(id);
			}
		}
	}
Exemplo n.º 23
0
void CFlashUIDisplayConfigNode::ProcessEvent( EFlowEvent event,SActivationInfo *pActInfo )
{
    if ( event == eFE_Initialize )
    {
        UpdateUIElement( GetPortString( pActInfo, eI_UIElement ), pActInfo );
    }
    else if ( event == eFE_Activate )
    {
        if ( IsPortActive( pActInfo, eI_UIElement ) )
        {
            UpdateUIElement( GetPortString( pActInfo, eI_UIElement ), pActInfo );
        }

        const int instanceId =  GetPortInt( pActInfo, eI_InstanceID );

        if ( IsPortActive( pActInfo, eI_Get ) )
        {
            SPerInstanceCall1< SActivationInfo* > caller;
            if ( !caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayConfigNode::GetFromInstance), pActInfo, false) )
            {
                UIACTION_WARNING( "FG: UIElement \"%s\" called get flags for multiple instances! (passed instanceId %i), referenced at node \"%s\"", GetPortString(pActInfo, eI_UIElement).c_str() ,instanceId, pActInfo->pGraph->GetNodeTypeName( pActInfo->myID ) );
            }
            ActivateOutput( pActInfo, eO_OnGet, true );
        }

        if ( IsPortActive( pActInfo, eI_Set ) )
        {
            const float alpha = GetPortFloat( pActInfo, eI_Alpha );
            const int layer = GetPortInt( pActInfo, eI_Layer );
            const uint64 flags = GetFlags( pActInfo );

            SPerInstanceCall3< uint64, float, int > caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayConfigNode::SetToInstance), flags, alpha, layer );
            ActivateOutput( pActInfo, eO_OnSet, true );
        }
    }
}
Exemplo n.º 24
0
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		if (event == eFE_Activate && IsPortActive(pActInfo, GO))
		{
			IEntity * pEntity = pActInfo->pEntity;
			if (pEntity)
			{
				ray_hit hit;
				IPhysicalEntity *pSkip = pEntity->GetPhysics();
				Vec3 direction = GetPortVec3(pActInfo, DIR).GetNormalized();
				if(GetPortBool(pActInfo, TRANSFORM_DIRECTION))
					direction = pEntity->GetWorldTM().TransformVector( GetPortVec3(pActInfo, DIR).GetNormalized() );
				IPhysicalWorld * pWorld = gEnv->pPhysicalWorld;
				int numHits = pWorld->RayWorldIntersection( 
					pEntity->GetPos() + GetPortVec3(pActInfo, POS),
					direction * GetPortFloat(pActInfo, MAXLENGTH),
					ent_all,
					rwi_stop_at_pierceable|rwi_colltype_any,
					&hit, 1, 
					&pSkip, 1 );
					
				if (numHits)
				{
					pEntity = (IEntity*)hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);    
					ActivateOutput( pActInfo, HIT,(bool)true );
					ActivateOutput( pActInfo, DIROUT, direction );
					ActivateOutput( pActInfo, DISTANCE, hit.dist );
					ActivateOutput( pActInfo, HITPOINT, hit.pt );
					ActivateOutput( pActInfo, NORMAL, hit.n );
					ActivateOutput( pActInfo, SURFTYPE, (int)hit.surface_idx );
					ActivateOutput( pActInfo, HIT_ENTITY, pEntity ? pEntity->GetId() : 0);
				}
				else
					ActivateOutput( pActInfo, NOHIT, false);
			}
		}
	}
Exemplo n.º 25
0
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
	{
		switch (event)
		{
		case eFE_Initialize:
			{
				break;
			}
		case eFE_Activate:
			{
				if (pActInfo->pEntity)
				{
					const string& signalName = GetPortString(pActInfo, eIn_SignalName);
					const float signalDelay = GetPortFloat(pActInfo, eIn_SignalDelay);
					IEntityDynamicResponseProxyPtr const pIEntityDrsProxy = crycomponent_cast<IEntityDynamicResponseProxyPtr>(pActInfo->pEntity->CreateProxy(ENTITY_PROXY_DYNAMICRESPONSE));

					if (IsPortActive(pActInfo, eIn_Send))
					{ 
						//DRS::IVariableCollectionSharedPtr contextCondition = gEnv->pDynamicResponseSystem->CreateContextCollection();  //add if context collections are needed

						pIEntityDrsProxy->QueueSignal(signalName.c_str(), nullptr, signalDelay);
						ActivateOutput(pActInfo, eOut_Done, true);
					}
					else if (IsPortActive(pActInfo, eIn_Cancel))
					{ 
						gEnv->pDynamicResponseSystem->CancelSignalProcessing(signalName, pIEntityDrsProxy->GetResponseActor(), signalDelay);
						ActivateOutput(pActInfo, eOut_Done, true);
					}
					break;
				}
				else
				{
					CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "CAction:DRS_SendSignal: Cannot send a signal without an specified EntityID.");
				}
			}
		}
	}
	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		
		switch (event)
		{
			case eFE_Initialize:
				{
					pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID,false);
				}
			case eFE_Activate:
				{
					if(GetPortBool(pActInfo, 1)) {
						EntityId id = GetPortEntityId(pActInfo,EIP_EntityID);
						IEntity * entity = gEnv->pEntitySystem->GetEntity(id);
						if(entity)
						{
							Matrix34 trans; // = entity->GetWorldTM();
							trans.CreateIdentity();
															
							Quat quat =  entity->GetRotation();
							quat.v = GetPortVec3( pActInfo, EIP_Rotation_XYZ);
							quat.w = GetPortFloat( pActInfo, EIP_Rotation_W);
							
							//quat.NormalizeFast();
					
							Vec3 position = entity->GetPos();
							trans.Set(Vec3(1,1,1),quat.GetNormalized(),position);
							
							entity->SetPosRotScale(position,quat,Vec3(1,1,1));

							
						}
					}
				}
			}
	}
Exemplo n.º 27
0
	virtual void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		if (event == eFE_Activate && IsPortActive(pActInfo, GO))
		{
			IEntity * pEntity = pActInfo->pEntity;
			// if (pEntity)
			{
				ray_hit hit;
				CCamera& cam = GetISystem()->GetViewCamera();
				Vec3 pos = cam.GetPosition()+cam.GetViewdir();
				Vec3 direction = cam.GetViewdir();
				IPhysicalWorld * pWorld = gEnv->pPhysicalWorld;
//				IPhysicalEntity *pSkip = 0; // pEntity->GetPhysics();
				int numHits = pWorld->RayWorldIntersection( 
				pos + GetPortVec3(pActInfo, POS),
				direction * GetPortFloat(pActInfo, MAXLENGTH),
				ent_all,
				rwi_stop_at_pierceable|rwi_colltype_any,
				&hit, 1
				/* ,&pSkip, 1 */  );
				if (numHits)
				{
					pEntity = (IEntity*)hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY);    
					ActivateOutput( pActInfo, HIT,(bool)true );
					ActivateOutput( pActInfo, DIROUT, direction );
					ActivateOutput( pActInfo, DISTANCE, hit.dist );
					ActivateOutput( pActInfo, HITPOINT, hit.pt );
					ActivateOutput( pActInfo, NORMAL, hit.n );
					ActivateOutput( pActInfo, SURFTYPE, (int)hit.surface_idx );
					ActivateOutput( pActInfo, HIT_ENTITY, pEntity ? pEntity->GetId() : 0);
				}
				else
					ActivateOutput( pActInfo, NOHIT, false );
			}
		}
	}
Exemplo n.º 28
0
	void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{
		switch (event)
		{
		case eFE_Initialize:
			{
				CGameRules* pGameRules = g_pGame->GetGameRules();
				if(pGameRules)
					pGameRules->AddGameRulesListener(this);

				CPlayer* pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor());
				if(pPlayer)
					m_localPlayerSpectatorMode = pPlayer->GetSpectatorMode();

				m_actInfo = *pActInfo;
			}
			break;
		case eFE_Activate:
			break;
		case eFE_Update:
			{
				CPlayer* pPlayer = static_cast<CPlayer*>(g_pGame->GetIGameFramework()->GetClientActor());
				if(!pPlayer)
					return;

				// first check: tac weapons trigger endgamenear / endgameinvalid
				if(m_MDList.empty() && m_endGameNear)
				{
					// if less than 3 min remaining don't return to normal
					bool cancel = true;
					if(g_pGame && g_pGame->GetGameRules() && g_pGame->GetGameRules()->IsTimeLimited() && m_timeRemainingTriggered)
					{
						float timeRemaining = g_pGame->GetGameRules()->GetRemainingGameTime();
						if(timeRemaining < GetPortFloat(pActInfo, EIP_GameEndTime) )
							cancel = false;
					}

					if(cancel)
					{
						if(g_pGame->GetCVars()->i_debug_mp_flowgraph != 0)
						{
							CryLog("MP flowgraph: EndGameInvalid");
						}
						ActivateOutput(&m_actInfo, EOP_EndGameInvalid, true);
						m_endGameNear = false;
					}
				}
				else if(!m_MDList.empty())
				{
					// go through the list of tac/sing weapons and check if they are still present
					std::list<EntityId>::iterator next;
					std::list<EntityId>::iterator it = m_MDList.begin();
					for(; it != m_MDList.end(); it = next)
					{
						next = it; ++next;
						if(gEnv->pEntitySystem->GetEntity(*it))
						{
							// entity exists so trigger loud music if not already done
							if(!m_endGameNear)
							{
								if(g_pGame->GetCVars()->i_debug_mp_flowgraph != 0)
								{
									CryLog("--MP flowgraph: EndGameNear");
								}
								ActivateOutput(&m_actInfo, EOP_EndGameNear, true);
								m_endGameNear = true;
							}

							// in the case of tanks, entity isn't removed for quite some time after destruction.
							//	Check vehicle health directly here...
							IVehicle* pVehicle = g_pGame->GetIGameFramework()->GetIVehicleSystem()->GetVehicle(*it);
							if(pVehicle && pVehicle->IsDestroyed())
							{
								m_MDList.erase(it);
							}
						}
						else
						{
							// entity no longer exists - remove from list.
 							m_MDList.erase(it);
						}
					}
				}

				// get the remaining time from game rules
				if(!m_timeRemainingTriggered && g_pGame->GetGameRules() && g_pGame->GetGameRules()->IsTimeLimited() && pPlayer->GetSpectatorMode() == 0 && !m_endGameNear)
				{
					float timeRemaining = g_pGame->GetGameRules()->GetRemainingGameTime();
					if(timeRemaining < GetPortFloat(pActInfo, EIP_GameEndTime) )
					{
						if(g_pGame->GetCVars()->i_debug_mp_flowgraph != 0)
						{
							CryLog("--MP flowgraph: EndGameNear");
						}
						ActivateOutput(&m_actInfo, EOP_EndGameNear, timeRemaining);
						m_timeRemainingTriggered = true;
						m_endGameNear = true;
					}
				}

				// also check whether the local player is in game yet
  				if(pPlayer->GetSpectatorMode() == 0 && m_localPlayerSpectatorMode != 0)
  				{
						if(g_pGame->GetCVars()->i_debug_mp_flowgraph != 0)
						{
							CryLog("--MP flowgraph: EnteredGame");
						}
  					ActivateOutput(&m_actInfo, EOP_EnteredGame, true);
  					m_localPlayerSpectatorMode = pPlayer->GetSpectatorMode();
  				}
			}
			break;
		}
	}
            virtual void ProcessEvent( EFlowEvent evt, SActivationInfo* pActInfo )
            {
                switch ( evt )
                {
                    case eFE_Suspend:
                        if ( m_pVideo && m_pVideo->IsPlaying() )
                        {
                            m_pVideo->Pause();
                            m_bWasPlaying = true;
                        }

                        pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, false );
                        break;

                    case eFE_Resume:
                        if ( m_pVideo && m_bWasPlaying )
                        {
                            m_pVideo->Resume();
                            m_bWasPlaying = false;
                        }

                        pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
                        break;

                    case eFE_Initialize:
                        INITIALIZE_OUTPUTS( pActInfo );
                        break;

                    case eFE_Activate:
                        if ( !m_pVideo )
                        {
                            m_pVideo = gVideoplayerSystem->CreateVideoplayer();

                            if ( m_pVideo )
                            {
                                m_pVideo->RegisterListener( this );
                                pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
                            }
                        }

                        if ( !m_pVideo )
                        {
                            return;
                        }

                        if ( IsPortActive( pActInfo, EIP_CLOSE ) )
                        {
                            m_pVideo->Close();
                            INITIALIZE_OUTPUTS( pActInfo );
                        }

                        if ( IsPortActive( pActInfo, EIP_PAUSE ) )
                        {
                            m_pVideo->Pause();
                            ActivateOutput<float>( pActInfo, EOP_POSITION, m_pVideo->GetPosition() );
                            ActivateOutput<bool>( pActInfo, EOP_PLAYING, m_pVideo->IsPlaying() );
                        }

                        if ( IsPortActive( pActInfo, EIP_OPEN ) )
                        {
                            if ( m_pVideo->Open(
                                        GetPortString( pActInfo, EIP_FILE ).c_str(),
                                        GetPortString( pActInfo, EIP_SOUND ).c_str(),
                                        GetPortBool( pActInfo, EIP_LOOP ),
                                        GetPortBool( pActInfo, EIP_SKIPPABLE ),
                                        GetPortBool( pActInfo, EIP_BLOCKGAME ),
                                        eTimeSource( GetPortInt( pActInfo, EIP_TIMESOURCE ) ),
                                        eDropMode( GetPortInt( pActInfo, EIP_DROPMODE ) ),
                                        GetPortFloat( pActInfo, EIP_STARTAT ),
                                        GetPortFloat( pActInfo, EIP_ENDAFTER ),
                                        GetPortInt( pActInfo, EIP_CUSTOMWIDTH ),
                                        GetPortInt( pActInfo, EIP_CUSTOMHEIGHT ) ) )
                            {
                                ActivateOutput<int>( pActInfo, EOP_VIDEOID, m_pVideo->GetId() );
                                ActivateOutput<float>( pActInfo, EOP_POSITION, m_pVideo->GetPosition() );
                                ActivateOutput<float>( pActInfo, EOP_DURATION, m_pVideo->GetDuration() );
                                ActivateOutput<float>( pActInfo, EOP_FPS, m_pVideo->GetFPS() );
                                ActivateOutput<int>( pActInfo, EOP_WIDTH, m_pVideo->GetWidth() );
                                ActivateOutput<int>( pActInfo, EOP_HEIGHT, m_pVideo->GetHeight() );
                                ActivateOutput<bool>( pActInfo, EOP_PLAYING, m_pVideo->IsPlaying() );
                                m_pVideo->SetSpeed( GetPortFloat( pActInfo, EIP_SPEED ) );
                            }

                            else
                            {
                                INITIALIZE_OUTPUTS( pActInfo );
                            }
                        }

                        if ( IsPortActive( pActInfo, EIP_RESUME ) )
                        {
                            m_pVideo->SetSpeed( GetPortFloat( pActInfo, EIP_SPEED ) );
                            m_pVideo->Resume();
                            ActivateOutput<float>( pActInfo, EOP_POSITION, m_pVideo->GetPosition() );
                            ActivateOutput<bool>( pActInfo, EOP_PLAYING, m_pVideo->IsPlaying() );
                            m_bStart = m_pVideo->IsPlaying();
                        }

                        if ( IsPortActive( pActInfo, EIP_SEEK ) )
                        {
                            m_pVideo->Seek( GetPortFloat( pActInfo, EIP_POSTION ) );
                            ActivateOutput<float>( pActInfo, EOP_POSITION, m_pVideo->GetPosition() );
                        }

                        if ( IsPortActive( pActInfo, EIP_SPEED ) )
                        {
                            m_pVideo->SetSpeed( GetPortFloat( pActInfo, EIP_SPEED ) );
                        }

                        if ( IsPortActive( pActInfo, EIP_TIMESOURCE ) )
                        {
                            m_pVideo->SetTimesource( eTimeSource( GetPortInt( pActInfo, EIP_TIMESOURCE ) ) );
                        }

                        break;

                    case eFE_Update:
                        if ( m_bEnd )
                        {
                            m_bEnd = false;
                            ActivateOutput( pActInfo, EOP_ONEND, true );
                        }

                        else if ( m_bStart )
                        {
                            m_bStart = false;
                            ActivateOutput( pActInfo, EOP_ONSTART, true );
                        }

                        if ( m_bFrame )
                        {
                            m_bFrame = false;
                            ActivateOutput<float>( pActInfo, EOP_POSITION, m_pVideo->GetPosition() );
                        }

                        break;
                }
            }
Exemplo n.º 30
0
void CFlowNode_AIStateGuard::OnEndActGoto()
{
	ResetGoalpipe();
	m_State = CryGetTicks() + GetPortFloat(&m_ActInfo, INPORT_DELAY) * gEnv->pTimer->GetTicksPerSecond(); //Pause
	SetIdle();
}