34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Cielonos.MainGame.Characters;
|
|
using SLSUtilities.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.Core.Interaction
|
|
{
|
|
[RequireComponent(typeof(Collider))]
|
|
public class InteractionTrigger : MonoBehaviour
|
|
{
|
|
public InteractableObjectBase interactableObject;
|
|
|
|
protected void OnTriggerEnter(Collider other)
|
|
{
|
|
interactableObject.EnterTriggerAction();
|
|
|
|
if(other.TryGetComponent<PlayerInteractionSubcontroller>(out var interactionSc))
|
|
{
|
|
Debug.Log("Player entered interactable area.");
|
|
interactionSc.currentChoices.AddRange(interactableObject.choices);
|
|
}
|
|
}
|
|
|
|
protected void OnTriggerExit(Collider other)
|
|
{
|
|
interactableObject.ExitTriggerAction();
|
|
|
|
if(other.TryGetComponent<PlayerInteractionSubcontroller>(out var interactionSc))
|
|
{
|
|
Debug.Log("Player exited interactable area.");
|
|
interactionSc.currentChoices.Remove(interactableObject.choices);
|
|
}
|
|
}
|
|
}
|
|
} |