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

38 lines
882 B
C#

using UnityEngine;
using System;
using Input;
using Interactions;
/// <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);
}
}
void OnDestroy()
{
if (interactable != null)
{
interactable.interactionStarted.RemoveListener(OnInteractionStarted);
}
}
private void OnInteractionStarted(PlayerTouchController playerRef, FollowerController followerRef)
{
if (interactable != null)
{
interactable.BroadcastInteractionComplete(true);
}
}
}