// Copyright (c) 2015 - 2023 Doozy Entertainment. All Rights Reserved.
// This code can only be used under the standard Unity Asset Store End User License Agreement
// A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
using Doozy.Runtime.Reactor.Internal;
// ReSharper disable UnusedMember.Global
namespace Doozy.Runtime.Reactor.Ticker
{
/// Registers to the Runtime Ticker Service and ticks a target callback (when registered)
public class RuntimeHeartbeat : Heartbeat
{
/// Construct a runtime Heartbeat with no target callback
public RuntimeHeartbeat() : base(null) {}
/// Construct a runtime Heartbeat with a target callback
/// Target callback
public RuntimeHeartbeat(ReactionCallback onTickCallback) : base(onTickCallback) {}
/// Time.realtimeSinceStartup
public override double timeSinceStartup => RuntimeTicker.timeSinceStartup;
/// Register to the Runtime Ticker Service Start ticking the callback
public override void RegisterToTickService()
{
base.RegisterToTickService();
RuntimeTicker.service?.Register(this);
}
/// Unregister from the Runtime Ticker Service Stop ticking the callback
public override void UnregisterFromTickService()
{
base.UnregisterFromTickService();
RuntimeTicker.service?.Unregister(this);
}
}
}