NPC utility queries (#15843)
This commit is contained in:
@@ -35,7 +35,6 @@ public sealed class RangedOperator : HTNOperator
|
||||
}
|
||||
|
||||
if (_entManager.TryGetComponent<MobStateComponent>(target, out var mobState) &&
|
||||
mobState.CurrentState != null &&
|
||||
mobState.CurrentState > TargetState)
|
||||
{
|
||||
return (false, null);
|
||||
@@ -72,13 +71,15 @@ public sealed class RangedOperator : HTNOperator
|
||||
{
|
||||
base.Update(blackboard, frameTime);
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
var status = HTNOperatorStatus.Continuing;
|
||||
HTNOperatorStatus status;
|
||||
|
||||
if (_entManager.TryGetComponent<NPCRangedCombatComponent>(owner, out var combat))
|
||||
if (_entManager.TryGetComponent<NPCRangedCombatComponent>(owner, out var combat) &&
|
||||
blackboard.TryGetValue<EntityUid>(TargetKey, out var target, _entManager))
|
||||
{
|
||||
combat.Target = target;
|
||||
|
||||
// Success
|
||||
if (_entManager.TryGetComponent<MobStateComponent>(combat.Target, out var mobState) &&
|
||||
mobState.CurrentState != null &&
|
||||
mobState.CurrentState > TargetState)
|
||||
{
|
||||
status = HTNOperatorStatus.Finished;
|
||||
@@ -100,6 +101,10 @@ public sealed class RangedOperator : HTNOperator
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = HTNOperatorStatus.Failed;
|
||||
}
|
||||
|
||||
if (status != HTNOperatorStatus.Continuing)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user