removed r3
This commit is contained in:
31
Runtime/Engine/Code/Foundation/AppLoopManager.cs
Normal file
31
Runtime/Engine/Code/Foundation/AppLoopManager.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKit.Engine.Foundation {
|
||||
public class AppLoopManager : MonoBehaviour {
|
||||
static readonly Logger s_Logger = new Logger(nameof(AppLoopManager));
|
||||
|
||||
public delegate void TickDelegate(float dt);
|
||||
|
||||
readonly List<TickDelegate> m_Delegates = new List<TickDelegate>();
|
||||
|
||||
void Update() {
|
||||
float dt = Time.deltaTime;
|
||||
foreach (TickDelegate tick in m_Delegates) {
|
||||
tick(dt);
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(TickDelegate tick) {
|
||||
if (m_Delegates.Contains(tick)) {
|
||||
s_Logger.Warning("Tick is already registered!");
|
||||
}
|
||||
|
||||
m_Delegates.Add(tick);
|
||||
}
|
||||
|
||||
public void Remove(TickDelegate tick) {
|
||||
m_Delegates.Remove(tick);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Runtime/Engine/Code/Foundation/AppLoopManager.cs.meta
Normal file
3
Runtime/Engine/Code/Foundation/AppLoopManager.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64a923b7732440d1ab5505b4dd250fc2
|
||||
timeCreated: 1759181550
|
||||
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using ZLinq;
|
||||
|
||||
namespace RebootKit.Engine.Foundation {
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
@@ -49,7 +48,7 @@ namespace RebootKit.Engine.Foundation {
|
||||
static readonly List<ConfigVar> s_configVars = new List<ConfigVar>();
|
||||
|
||||
public static void Register(ConfigVar cvar) {
|
||||
if (s_configVars.AsValueEnumerable().Any(c => c.name.Equals(cvar.name, StringComparison.Ordinal))) {
|
||||
if (Get(cvar.name) != null) {
|
||||
throw new Exception($"CVar with name '{cvar.name}' already exists");
|
||||
}
|
||||
|
||||
@@ -63,7 +62,13 @@ namespace RebootKit.Engine.Foundation {
|
||||
}
|
||||
|
||||
public static ConfigVar Get(string name) {
|
||||
return s_configVars.AsValueEnumerable().FirstOrDefault(c => c.name.Equals(name, StringComparison.Ordinal));
|
||||
foreach (ConfigVar configVar in s_configVars) {
|
||||
if (configVar.name.Equals(name, StringComparison.Ordinal)) {
|
||||
return configVar;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IEnumerable<ConfigVar> All() => s_configVars;
|
||||
|
||||
Reference in New Issue
Block a user