2025-09-09 13:38:03 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using System;
|
2025-09-11 13:00:26 +02:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
2025-09-11 13:00:26 +02:00
|
|
|
|
interactable.interactionStarted.AddListener(OnInteractionStarted);
|
2025-09-09 13:38:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (interactable != null)
|
|
|
|
|
|
{
|
2025-09-11 13:00:26 +02:00
|
|
|
|
interactable.interactionStarted.RemoveListener(OnInteractionStarted);
|
2025-09-09 13:38:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 13:00:26 +02:00
|
|
|
|
private void OnInteractionStarted(PlayerTouchController playerRef, FollowerController followerRef)
|
2025-09-09 13:38:03 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (interactable != null)
|
|
|
|
|
|
{
|
2025-09-11 13:00:26 +02:00
|
|
|
|
interactable.BroadcastInteractionComplete(true);
|
2025-09-09 13:38:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|