using System;
using Chernobyl.Destruction;
using UnityEngine;
using UnityEngine.Events;
namespace Chernobyl.Unity.Event
{
///
/// Forwards events from a to a .
///
public class UnityEventRelay : MonoBehaviour
{
///
/// The input source for events
///
[Tooltip("The input source for events.")]
public EventSource Source;
///
/// The to invoke when an event is received.
///
[Tooltip("The UnityEvent to invoke when an event is received.")]
public UnityEvent Response;
/// See Unity docs for more info.
public void OnEnable() => _subscription = Source.Observable.Subscribe(arg => Response.Invoke());
/// See Unity docs for more info.
public void OnDisable() => _subscription.Dispose();
/// See Unity docs for more info.
public void OnDestroy() => _subscription.Dispose();
IDisposable _subscription = Disposable.Empty;
}
}