using System;
using Chernobyl.Destruction;
using UnityEngine;
namespace Chernobyl.Unity.Event
{
///
/// Logs a message to the console when an event is received.
///
public class EventConsoleLog : MonoBehaviour
{
///
/// The event that causes the logging.
///
[Tooltip("The event that causes the logging.")]
public EventSource EventSource;
///
/// See Unity docs for more info.
///
public void Start()
{
EventSource.ThrowIfNull(nameof(EventSource));
_eventSubscription = EventSource.Observable.Subscribe(OnEventReceived);
}
///
/// See Unity docs for more info.
///
public void OnDestroy() => _eventSubscription.Dispose();
void OnEventReceived(object obj) => Debug.Log("Event received.", gameObject);
IDisposable _eventSubscription = Disposable.Empty;
}
}