更改文件架构

This commit is contained in:
CortexCore
2023-06-07 18:38:07 +08:00
parent 93292b1a59
commit ed84166723
720 changed files with 297 additions and 65 deletions

View File

@@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Concurrent;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.TestTools;
namespace BITKit
{
using SubSystems;
public class BITTimer
{
internal BITTimer() { }
public static BITTimer Create(float addTime = 1, UnityAction action = null)
{
BITTimer timer = new();
timer.excuteTime = Utility.Time.time + addTime;
timer.onExcute = action;
TimerSystem.queue.Enqueue(timer);
return timer;
}
public float excuteTime;
public bool isActive { get; internal set; }
public UnityAction onExcute;
public void Cancel()
{
isActive = false;
}
}
}
namespace BITKit.SubSystems
{
public class TimerSystem : SubBITSystem
{
internal static List<BITTimer> timers = new();
internal static ConcurrentQueue<BITTimer> queue = new();
public override void OnUpdate(float deltaTime)
{
List<BITTimer> nexts = new();
lock (timers)
{
timers.ForEach(x =>
{
if (x.excuteTime > Utility.Time.time)
{
if (x.onExcute is not null) x.onExcute();
x.isActive = false;
}
else
{
nexts.Add(x);
}
});
while (queue.TryDequeue(out var timer))
{
nexts.Add(timer);
}
timers = nexts;
}
}
}
}

View File

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