|
|
|
|
|
|
[Header("Listening to")] |
|
|
|
//Check if the interaction ended
|
|
|
|
[SerializeField] private VoidEventChannelSO _onInteractionEnded = default; |
|
|
|
|
|
|
|
[SerializeField] private VoidEventChannelSO _oninteractResponsed = default; |
|
|
|
_oninteractResponsed.OnEventRaised += OninteractionResponseActivated; |
|
|
|
|
|
|
|
_oninteractResponsed.OnEventRaised -= OninteractionResponseActivated; |
|
|
|
_onInteractionEnded.OnEventRaised -= OnInteractionEnd; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnInteractionButtonPress() |
|
|
|
// interaction button press event handler activated by the StateMachine
|
|
|
|
void OninteractionResponseActivated() |
|
|
|
{ |
|
|
|
//remove interaction after press
|
|
|
|
Interaction onGoingInteraction = _ongoingInteractions.Count > 0 ? |
|
|
|
|
|
|
Item currentItem = itemObject.GetComponent<CollectibleItem>().GetItem(); |
|
|
|
_onObjectPickUp.RaiseEvent(currentItem); |
|
|
|
//Debug.Log("PickUp event raised");
|
|
|
|
//set current interaction for state machine
|
|
|
|
currentInteraction = InteractionType.PickUp; |
|
|
|
//destroy the GO
|
|
|
|
|
|
|
|
Destroy(itemObject); |
|
|
|
break; |
|
|
|
case InteractionType.Cook: |
|
|
|
|
|
|
//Change the action map
|
|
|
|
_inputReader.EnableMenuInput(); |
|
|
|
//set current interaction for state machine
|
|
|
|
currentInteraction = InteractionType.Cook; |
|
|
|
if (_onCookingStart != null) |
|
|
|
if (_startTalking != null) |
|
|
|
{ |
|
|
|
//raise an event with an actor as parameter
|
|
|
|
//Actor currentActor = currentInteractableObject.GetComponent<Dialogue>().GetActor();
|
|
|
|
|
|
|
_inputReader.EnableDialogueInput(); |
|
|
|
//set current interaction for state machine
|
|
|
|
currentInteraction = InteractionType.Talk; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void OnInteractionButtonPress() |
|
|
|
{ |
|
|
|
Interaction onGoingInteraction = _ongoingInteractions.Count > 0 ? |
|
|
|
_ongoingInteractions.First.Value : Interaction.NONE; |
|
|
|
//set current interaction for state machine
|
|
|
|
if (onGoingInteraction.Type != InteractionType.None) |
|
|
|
{ |
|
|
|
currentInteraction = onGoingInteraction.Type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|