Files
AppleHillsProduction/Assets/Scripts/Interactions/OneClickInteraction.cs

38 lines
882 B
C#
Raw Normal View History

2025-09-09 13:38:03 +02:00
using UnityEngine;
using System;
using Input;
using Interactions;
2025-09-09 13:38:03 +02:00
/// <summary>
/// MonoBehaviour that immediately completes an interaction when started.
/// </summary>
public class OneClickInteraction : MonoBehaviour
{
private Interactable interactable;
void Awake()
{
interactable = GetComponent<Interactable>();
if (interactable != null)
{
interactable.interactionStarted.AddListener(OnInteractionStarted);
2025-09-09 13:38:03 +02:00
}
}
void OnDestroy()
{
if (interactable != null)
{
interactable.interactionStarted.RemoveListener(OnInteractionStarted);
2025-09-09 13:38:03 +02:00
}
}
private void OnInteractionStarted(PlayerTouchController playerRef, FollowerController followerRef)
2025-09-09 13:38:03 +02:00
{
if (interactable != null)
{
interactable.BroadcastInteractionComplete(true);
2025-09-09 13:38:03 +02:00
}
}
}