mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
namespace NewHorizons.Components.Volumes
|
|
{
|
|
public class NHInteractionVolume : MonoBehaviour
|
|
{
|
|
public bool Reusable { get; set; }
|
|
public string Condition { get; set; }
|
|
public bool Persistent { get; set; }
|
|
public Animator TargetAnimator { get; set; }
|
|
public string AnimationTrigger { get; set; }
|
|
|
|
InteractReceiver _interactReceiver;
|
|
OWAudioSource _audioSource;
|
|
|
|
protected void Awake()
|
|
{
|
|
_interactReceiver = GetComponent<InteractReceiver>();
|
|
_audioSource = GetComponent<OWAudioSource>();
|
|
|
|
_interactReceiver.OnPressInteract += OnInteract;
|
|
}
|
|
|
|
protected void OnDestroy()
|
|
{
|
|
_interactReceiver.OnPressInteract -= OnInteract;
|
|
}
|
|
|
|
protected void OnInteract()
|
|
{
|
|
if (!string.IsNullOrEmpty(Condition))
|
|
{
|
|
if (Persistent)
|
|
{
|
|
PlayerData.SetPersistentCondition(Condition, true);
|
|
}
|
|
else
|
|
{
|
|
DialogueConditionManager.SharedInstance.SetConditionState(Condition, true);
|
|
}
|
|
}
|
|
|
|
if (_audioSource != null)
|
|
{
|
|
_audioSource.Play();
|
|
}
|
|
|
|
if (TargetAnimator)
|
|
{
|
|
TargetAnimator.SetTrigger(AnimationTrigger);
|
|
}
|
|
|
|
if (Reusable)
|
|
{
|
|
_interactReceiver.ResetInteraction();
|
|
_interactReceiver.EnableInteraction();
|
|
}
|
|
else
|
|
{
|
|
_interactReceiver.DisableInteraction();
|
|
}
|
|
}
|
|
}
|
|
}
|