1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.Mod;
|
||||
using UnityEngine;
|
||||
@@ -15,6 +16,7 @@ namespace BITKit.Animations
|
||||
public class ScriptableMotionMatchingService : MonoBehaviour,IMotionMatchingService
|
||||
{
|
||||
internal static ScriptableMotionMatchingService Singleton { get; private set; }
|
||||
internal static readonly ConcurrentDictionary<int, IMotionMatchingObject> Cache = new();
|
||||
|
||||
private ObjectMatcher<string,IMotionMatchingObject> _objects;
|
||||
|
||||
@@ -40,16 +42,23 @@ namespace BITKit.Animations
|
||||
|
||||
public bool TryMatch(out IMotionMatchingObject value, string[] key)
|
||||
{
|
||||
if (_objects.TryMatch(out value, key))
|
||||
value = Cache.GetOrAdd(MathE.GetHash(key),Add);
|
||||
return value is not null;
|
||||
|
||||
IMotionMatchingObject Add(int hash)
|
||||
{
|
||||
return true;
|
||||
if (_objects.TryMatch(out IMotionMatchingObject x, key) is false)
|
||||
{
|
||||
BIT4Log.Log<ScriptableMotionMatchingService>($"找不到对应的MotionMatchingObject:{string.Join(",", key)}");
|
||||
return null;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
BIT4Log.Log<ScriptableMotionMatchingService>($"找不到对应的MotionMatchingObject:{string.Join(",", key)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
Cache.Clear();
|
||||
var list = new List<ScriptableMotionMatchingObject>();
|
||||
var tags = new []{nameof(IMotionMatchingObject)};
|
||||
foreach (var x in YooAssets.GetAssetInfos(tags))
|
||||
|
Reference in New Issue
Block a user