This commit is contained in:
CortexCore
2024-04-16 04:06:46 +08:00
parent 37e7fcea51
commit c798b224be
67 changed files with 1305 additions and 425 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -20,11 +21,13 @@ namespace BITKit
private static VFXService sinleton;
public VFX[] vfxs;
private readonly Dictionary<string, UnityPool<Transform>> pools = new();
private readonly ConcurrentDictionary<int, Transform> cache = new();
[SerializeField] private bool debug;
[SerializeField] private Optional<int> defaultCapacity;
private void Awake()
{
cache.Clear();
sinleton = this;
DI.Register(this);
}
@@ -68,16 +71,22 @@ namespace BITKit
public bool TryMatch(out Transform value, params string[] key)
{
foreach (var vfx in vfxs)
value=cache.GetOrAdd(MathE.GetHash(key),Add);
return value is not null;
Transform Add(int arg)
{
if (vfx.IsMatch(key))
foreach (var vfx in vfxs)
{
value = vfx.prefab;
return true;
if (vfx.IsMatch(key))
{
var x = vfx.prefab;
return x;
}
}
return null;
}
value = null;
return false;
}
}
}