Files
Cielonos/Assets/Scripts/Core/Interaction/InteractionTrigger.cs
2026-05-10 11:47:55 -04:00

36 lines
1.2 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);
interactionSc.SetCurrentInteractable(interactableObject);
}
}
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);
interactionSc.RemoveCurrentInteractable(interactableObject);
}
}
}
}