bingo 项目提交

This commit is contained in:
2026-04-20 13:49:36 +08:00
commit ad5920ac6a
5585 changed files with 1216243 additions and 0 deletions
@@ -0,0 +1,147 @@
using BingoBrain;
namespace BingoBrain.Core
{
using System;
using UnityEngine;
using System.Collections.Generic;
internal class IsfvBehaviour : SingletonUnity<IsfvBehaviour>
{
private readonly Dictionary<string, IsfvData> _asyncDataDict = new Dictionary<string, IsfvData>();
private readonly Dictionary<string, IsfvData> _asyncTmpDataDict = new Dictionary<string, IsfvData>();
private readonly Dictionary<string, IsfvData> _updateActionDict = new Dictionary<string, IsfvData>();
private readonly List<string> _keyClean = new List<string>();
private void Update()
{
_asyncTmpDataDict.ForEachSafe((s, data) => data.PassTime(Time.deltaTime));
_asyncDataDict.ForEachSafe((s, data) => data.PassTime(Time.deltaTime));
try
{
_updateActionDict.ForEachSafe((k, v) => { v?.dealMethod?.Invoke(); });
}
catch (Exception)
{
}
ClearTempFinished();
ClearFinished();
ClearUpdateActionFinished();
}
private void ClearFinished()
{
_keyClean.Clear();
foreach (var dealData in _asyncDataDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_asyncDataDict.Remove(key);
}
}
private void ClearTempFinished()
{
_keyClean.Clear();
foreach (var dealData in _asyncTmpDataDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_asyncTmpDataDict.Remove(key);
}
}
public void AddAsyncData(string key, IsfvData isfvData)
{
RemoveAsyncData(key);
_asyncDataDict.Add(key, isfvData);
}
public void AddAsyncTempData(string key, IsfvData isfvData)
{
RemoveAsyncTempData(key);
_asyncTmpDataDict.Add(key, isfvData);
}
public void RemoveAsyncTempData(string key)
{
if (_asyncTmpDataDict.ContainsKey(key))
{
_asyncTmpDataDict.Remove(key);
}
}
public void RemoveAsyncData(string key)
{
if (_asyncDataDict.ContainsKey(key))
{
_asyncDataDict.Remove(key);
}
}
public void AddUpdateAction(string key, IsfvData isfvData)
{
RemoveAsyncData(key);
_updateActionDict.Add(key, isfvData);
}
public void RemoveUpdateAction(string key)
{
if (_updateActionDict.ContainsKey(key))
{
_updateActionDict.Remove(key);
}
}
public void ClearUpdateActionFinished()
{
_keyClean.Clear();
foreach (var dealData in _updateActionDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_updateActionDict.Remove(key);
}
}
public void RemoveAllAction()
{
_updateActionDict.Clear();
_asyncDataDict.Clear();
_asyncTmpDataDict.Clear();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 984d18c5a4974e729d72276896426930
timeCreated: 1682577036
+52
View File
@@ -0,0 +1,52 @@
namespace BingoBrain.Core
{
public class IsfvData
{
public delegate void DealMethod();
private float _currentTime;
public float DelayTime = 1f;
public DealMethod dealMethod;
public int RepeatCount = 1;
public bool IsComplete => RepeatCount == 0;
public void PassTime(float time)
{
_currentTime += time;
if (!(_currentTime >= DelayTime))
{
return;
}
_currentTime -= DelayTime;
Run();
}
private void Run()
{
if (RepeatCount == -1)
{
dealMethod?.Invoke();
}
else
{
if (RepeatCount > 0)
{
dealMethod?.Invoke();
RepeatCount--;
}
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e51ff91679a44d1b1efe3438d508e74
timeCreated: 1682577036
+139
View File
@@ -0,0 +1,139 @@
using System;
namespace BingoBrain.Core
{
using UnityEngine;
using System.Collections;
public static class IsfvKit
{
private static IsfvBehaviour _sIsfvBehaviour;
private static readonly object SynClock = new object();
private static IsfvBehaviour MIsfvBehaviour
{
get
{
if (_sIsfvBehaviour != null)
{
return _sIsfvBehaviour;
}
lock (SynClock)
{
if (_sIsfvBehaviour != null)
{
return _sIsfvBehaviour;
}
_sIsfvBehaviour = IsfvBehaviour.Instance;
if (_sIsfvBehaviour != null)
{
_sIsfvBehaviour.name = "[ AsyncKit ]";
}
}
return _sIsfvBehaviour;
}
}
public static Coroutine StartCoroutine(IEnumerator enumerator)
{
return MIsfvBehaviour.StartCoroutine(enumerator);
}
public static void StopCoroutine(Coroutine methodName)
{
MIsfvBehaviour.StopCoroutine(methodName);
}
public static void StopAllCoroutine()
{
MIsfvBehaviour.StopAllCoroutines();
}
public static void StartAction(string key, IsfvData.DealMethod method, float delayTime, int repeat = 1)
{
var temp = new IsfvData { dealMethod = method, DelayTime = delayTime, RepeatCount = repeat };
MIsfvBehaviour.AddAsyncData(key, temp);
}
public static void StopAction(string key)
{
MIsfvBehaviour.RemoveAsyncData(key);
}
public static void StopAllAction()
{
MIsfvBehaviour.RemoveAllAction();
}
public static void StartUpdateAction(string key, IsfvData.DealMethod method, float time)
{
var temp = new IsfvData { dealMethod = method, DelayTime = time, RepeatCount = -1 };
MIsfvBehaviour.AddUpdateAction(key, temp);
}
public static void StopUpdateAction(string key)
{
MIsfvBehaviour.RemoveUpdateAction(key);
}
public static void DelayedAction(float delayTime, IsfvData.DealMethod method, int repeat = 1,
string key = null)
{
key ??= $"{nameof(DelayedAction)}{DateTime.Now.Millisecond}";
var temp = new IsfvData
{
dealMethod = () =>
{
method?.Invoke();
ClearDelayedAction(key);
},
DelayTime = delayTime, RepeatCount = repeat
};
MIsfvBehaviour.AddAsyncTempData(key, temp);
}
public static void ClearDelayedAction(string key)
{
MIsfvBehaviour.RemoveAsyncTempData(key);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 93122ca4429e463aba586a345558ed8e
timeCreated: 1682577036