39 lines
936 B
C#
39 lines
936 B
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster.Scripts
|
|
{
|
|
public interface ITickable
|
|
{
|
|
bool Tick(uint dwDeltaTime);
|
|
}
|
|
public class TickInvoker : MonoSingleton<TickInvoker>
|
|
{
|
|
List<ITickable> tickables = new List<ITickable>();
|
|
|
|
protected override void Initialize()
|
|
{
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
public void RegisterTickable(ITickable tickable)
|
|
{
|
|
if (!tickables.Contains(tickable))
|
|
tickables.Add(tickable);
|
|
}
|
|
|
|
public void UnregisterTickable(ITickable tickable)
|
|
{
|
|
tickables.Remove(tickable);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
for (int i=0; i<tickables.Count; i++)
|
|
{
|
|
tickables[i].Tick( (uint)(Time.deltaTime * 1000)); // Convert to milliseconds
|
|
}
|
|
|
|
}
|
|
}
|
|
} |