This commit is contained in:
CortexCore
2024-04-19 21:43:30 +08:00
parent e12a6e5a46
commit 3cc6491973
46 changed files with 6792 additions and 23887 deletions

View File

@@ -17,13 +17,19 @@ namespace BITFALL.AI.States
public abstract class AIRuntimeState : AIState
{
[Inject,HideInInspector] public AIService Service;
private readonly ConcurrentDictionary<ulong, bool> _friends = new();
private readonly ConcurrentDictionary<ulong, bool> _enemies = new();
private readonly ConcurrentDictionary<int, bool> _friends = new();
private readonly ConcurrentDictionary<int, bool> _enemies = new();
protected readonly HashSet<int> ignoreNoises = new();
protected readonly CacheList<IEntity> detectedEnemies = new();
protected readonly CacheList<IEntity> hearEnemies = new();
public bool IsFriend(IEntity target) => _friends.GetOrAdd(target.Id, IsFriendInternal);
public bool IsEnemy(IEntity target) => _enemies.GetOrAdd(target.Id, IsEnemyInternal);
public bool IsFriend(IEntity target)
{
return _friends.GetOrAdd(target.Id, IsFriendInternal);
}
public bool IsEnemy(IEntity target)
{
return _enemies.GetOrAdd(target.Id, IsEnemyInternal);
}
public override void OnStateUpdate(float deltaTime)
{
base.OnStateUpdate(deltaTime);
@@ -57,7 +63,7 @@ namespace BITFALL.AI.States
}
}
private bool IsEnemyInternal(ulong id)
private bool IsEnemyInternal(int id)
{
var target = UnityEntitiesService.Get(id);
var tags = target.As<MonoBehaviour>().GetComponent<ITag>().GetTags();
@@ -69,7 +75,7 @@ namespace BITFALL.AI.States
return false;
}
private bool IsFriendInternal(ulong id)
private bool IsFriendInternal(int id)
{
var target = UnityEntitiesService.Get(id);
var tags = target.As<MonoBehaviour>().GetComponent<ITag>().GetTags();