void CFlowNode_AISequenceAction_WeaponHolster::HandleSequenceEvent(AIActionSequence::SequenceEvent sequenceEvent)
{
	switch(sequenceEvent)
	{
	case AIActionSequence::StartAction:
		{
			CRY_ASSERT_MESSAGE(m_actInfo.pEntity, "entity has magically gone");
			if (!m_actInfo.pEntity)
			{
				// the entity has gone for some reason, at least make sure the action gets finished properly and the FG continues
				CancelSequenceAndActivateOutputPort(OutputPort_Done);
				return;
			}

			assert(gEnv && gEnv->pGame && gEnv->pGame->GetIGameFramework() && gEnv->pGame->GetIGameFramework()->GetIActorSystem());
			IActor* pActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_actInfo.pEntity->GetId());
			if (!pActor)
			{
				CRY_ASSERT_MESSAGE(0, "Provided entity must be an IActor");
				CryWarning(VALIDATOR_MODULE_AI, VALIDATOR_WARNING, "Provided entity %s must be an IActor", m_actInfo.pEntity->GetName());
				CancelSequenceAndActivateOutputPort(OutputPort_Done);
				return;
			}

			const bool skipHolsterAnimation = GetPortBool(&m_actInfo, InputPort_SkipHolsterAnimation);
			pActor->HolsterItem(true, !skipHolsterAnimation);
			FinishSequenceActionAndActivateOutputPort(OutputPort_Done);
		}
		break;
	}
}
void CFlowNode_AISequenceAction_ApproachAndEnterVehicle::OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
{
	if (event == eVE_PassengerEnter)
	{
		UnregisterFromVehicleEvent(NULL);
		FinishSequenceActionAndActivateOutputPort(OutputPort_Done);
	}
}
void CFlowNode_AISequenceAction_WeaponDrawFromInventory::HandleSequenceEvent(AIActionSequence::SequenceEvent sequenceEvent)
{
	switch(sequenceEvent)
	{
	case AIActionSequence::StartAction:
		{
			CRY_ASSERT_MESSAGE(m_actInfo.pEntity, "entity has magically gone");
			if (!m_actInfo.pEntity)
			{
				// the entity has gone for some reason, at least make sure the action gets finished properly and the FG continues
				CancelSequenceAndActivateOutputPort(OutputPort_Done);
				return;
			}

			assert(gEnv && gEnv->pGame && gEnv->pGame->GetIGameFramework() && gEnv->pGame->GetIGameFramework()->GetIActorSystem());
			IActor* pActor = gEnv->pGame->GetIGameFramework()->GetIActorSystem()->GetActor(m_actInfo.pEntity->GetId());
			if (!pActor)
			{
				CRY_ASSERT_MESSAGE(0, "Provided entity must be an IActor");
				CryWarning(VALIDATOR_MODULE_AI, VALIDATOR_WARNING, "Provided entity %s must be an IActor", m_actInfo.pEntity->GetName());
				CancelSequenceAndActivateOutputPort(OutputPort_Done);
				return;
			}

			assert(gEnv && gEnv->pGame && gEnv->pGame->GetIGameFramework() && gEnv->pGame->GetIGameFramework()->GetIItemSystem());
			IItemSystem* pItemSystem = gEnv->pGame->GetIGameFramework()->GetIItemSystem();

			IInventory* pInventory = pActor->GetInventory();
			if (!pInventory)
			{
				CRY_ASSERT_MESSAGE(0, "Actor has no inventory");
				CryWarning(VALIDATOR_MODULE_AI, VALIDATOR_WARNING, "Actor %s has no inventory", m_actInfo.pEntity->GetName());
				CancelSequenceAndActivateOutputPort(OutputPort_Done);
				return;
			}

			pInventory->SetHolsteredItem(EntityId(0));	// otherwise trying to holster the new weapon later on will not work (i. e. will do nothing)

			// draw the weapon
			const string& weaponName = GetPortString(&m_actInfo, InputPort_WeaponName);
			pItemSystem->SetActorItem(pActor, weaponName.c_str(), false);

			FinishSequenceActionAndActivateOutputPort(OutputPort_Done);
		}
		break;
	}
}
void CFlowNode_AISequenceAction_VehicleRotateTurret::ProcessEvent(IFlowNode::EFlowEvent event, IFlowNode::SActivationInfo* pActInfo)
{
	if (!pActInfo->pEntity)
		return;

	switch(event)
	{
	case eFE_Activate:
		{
			m_actInfo = *pActInfo;
			m_stopFlowGraphNodeFromGettingUpdatedWhenSequenceActionFinishesOrCancels = true;
			m_pActionRotateTurret = NULL;

			if (IsPortActive(pActInfo, InputPort_Start))
			{
				if (const AIActionSequence::SequenceId assignedSequenceId = GetAssignedSequenceId())
				{
					gEnv->pAISystem->GetSequenceManager()->RequestActionStart(assignedSequenceId, pActInfo->myID);
					m_actInfo.pGraph->SetRegularlyUpdated(m_actInfo.myID, true);
				}
			}
		}
		break;

	case eFE_Update:
		{
			if (m_pActionRotateTurret)
			{
				float pitch, yaw;
				m_pActionRotateTurret->GetRemainingAnglesToAimGoalInDegrees(pitch, yaw);
				if (fabsf(pitch) <= m_pitchThreshold && fabs(yaw) <= m_yawThreshold)
				{
					FinishSequenceActionAndActivateOutputPort(OutputPort_Done);
				}
			}
		}
		break;
	}
}