Browse Source

Added simple TimeTickSystem

James Peret 2 years ago
parent
commit
3423e4d8e4
2 changed files with 39 additions and 0 deletions
  1. 28 0
      Runtime/TimeTickSystem.cs
  2. 11 0
      Runtime/TimeTickSystem.cs.meta

+ 28 - 0
Runtime/TimeTickSystem.cs

@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace KairoEngine.Core
+{
+    public class TimeTickSystem : MonoBehaviour
+    {
+        public const float TICK_TIMER_MAX = .2f;
+        private int tick;
+        private float tickTimer;
+
+        private void Awake () => tick = 0;
+
+        private void Update ()
+        {
+            tickTimer += Time.deltaTime;
+            if(tickTimer >= TICK_TIMER_MAX)
+            {
+                tickTimer -= TICK_TIMER_MAX;
+                tick++;
+                // Debug.Log(tick);
+                GenericEvents.Trigger("Tick", tick);
+            }
+        }
+    }
+}
+

+ 11 - 0
Runtime/TimeTickSystem.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 17153349eaea87945aac9e752b4a8ccc
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: