You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
968 B
30 lines
968 B
1 month ago
|
using System.Linq;
|
||
|
using BehaviorDesigner.Runtime.Tasks;
|
||
|
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace CoreGame.Render
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 视线x米内是否有敌人
|
||
|
/// </summary>
|
||
|
public class IsEnemyInsightCondition : Conditional
|
||
|
{
|
||
|
[SerializeField] private float range;
|
||
|
|
||
|
public override TaskStatus OnUpdate()
|
||
|
{
|
||
|
var ownerEnt = (CombatEntity)(Owner.GetEntity<CombatEntity>());
|
||
|
var ac = ownerEnt.aI;
|
||
|
var combatEntities = ListPool<CombatEntity>.Pop();
|
||
|
TargetSelectSrv.SelectDistanceEnts(ownerEnt, range, combatEntities);
|
||
|
ac.targetList.Clear();
|
||
|
for (var index = 0; index < combatEntities.Count; index++)
|
||
|
{
|
||
|
ac.targetList.Add(combatEntities[index].creationIndex);
|
||
|
}
|
||
|
ListPool<CombatEntity>.Push(ref combatEntities);
|
||
|
return ac.targetList.Count > 0 ? TaskStatus.Success : TaskStatus.Failure;
|
||
|
}
|
||
|
}
|
||
|
}
|