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.");
					break;
				}

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

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

				if (variableCollection)
				{
					SET_DRS_USER_SCOPED("SetDrsVariable FlowGraphNode");
					const string &newVariableValue = GetPortString(pActInfo, eIn_StringValue);
					variableCollection->SetVariableValue(variableName, CHashedString(newVariableValue), true, GetPortFloat(pActInfo, eIn_ResetTime));
					ActivateOutput(pActInfo, eOut_VariableCollectionName, variableCollection->GetName().GetText());
				}
			}
			break;
		}
		}
	}
예제 #2
0
DRS::IResponseActionInstanceUniquePtr CActionSwitch::Execute(DRS::IResponseInstance* pResponseInstance)
{
	auto pResponseActor = pResponseInstance->GetCurrentActor();
	auto pContextVariables = pResponseInstance->GetContextVariables();

	if (pResponseActor && pContextVariables)
	{
		IEntity* const pEntity = pResponseActor->GetLinkedEntity();

		if (pEntity)
		{
			// They may have sent us a different verb to the standard one.
			CHashedString verb = DRSUtility::GetValueOrDefault(pContextVariables, "Verb", CHashedString(""));

			// This allows us to select between being switched on and off.
			// #TODO: Put this into use and look into what else we can add.
			bool isSwitchOn = DRSUtility::GetValueOrDefault(pContextVariables, "IsSwitchedOn", false);

			if (auto pInteractor = pEntity->GetComponent<CEntityInteractionComponent>())
			{
				// Simple option is to play the verb.
				// #TODO: This should be a little more nuanced.
				auto pInteraction = pInteractor->GetInteraction(verb.GetText()).lock();
				if (pInteraction)
				{
					if (auto pActorComponent = CPlayerComponent::GetLocalActor())
						pInteraction->OnInteractionStart(*pActorComponent);
				}
			}
		}

		return DRS::IResponseActionInstanceUniquePtr(new CActionSwitchInstance());
	}

	return nullptr;
}