Files
Cielonos/Assets/Scripts/Core/Interaction/InteractionTrigger.cs
SoulliesOfficial 50ee502684 完善
2026-02-13 09:22:11 -05:00

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);
}
}
}
}