36 lines
754 B
C#
36 lines
754 B
C#
|
|
using UnityEngine;
|
|||
|
|
using System;
|
|||
|
|
|
|||
|
|
/// <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.StartedInteraction += OnStartedInteraction;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void OnDestroy()
|
|||
|
|
{
|
|||
|
|
if (interactable != null)
|
|||
|
|
{
|
|||
|
|
interactable.StartedInteraction -= OnStartedInteraction;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnStartedInteraction()
|
|||
|
|
{
|
|||
|
|
if (interactable != null)
|
|||
|
|
{
|
|||
|
|
interactable.CompleteInteraction(true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|