Bandaid medibots (#11718)

This commit is contained in:
metalgearsloth
2022-10-13 21:36:29 +11:00
committed by GitHub
parent 8e1d599656
commit fa59983bd9
11 changed files with 67 additions and 14 deletions

View File

@@ -2,7 +2,9 @@ using System.Threading;
using System.Threading.Tasks;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.NPC.Components;
using Content.Server.NPC.Pathfinding;
using Content.Shared.Damage;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
@@ -11,6 +13,7 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
{
[Dependency] private readonly IEntityManager _entManager = default!;
private EntityLookupSystem _lookup = default!;
private PathfindingSystem _pathfinding = default!;
[ViewVariables, DataField("rangeKey")] public string RangeKey = NPCBlackboard.MedibotInjectRange;
@@ -30,6 +33,7 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
{
base.Initialize(sysManager);
_lookup = sysManager.GetEntitySystem<EntityLookupSystem>();
_pathfinding = sysManager.GetEntitySystem<PathfindingSystem>();
}
public override async Task<(bool Valid, Dictionary<string, object>? Effects)> Plan(NPCBlackboard blackboard,
@@ -53,10 +57,16 @@ public sealed class PickNearbyInjectableOperator : HTNOperator
damage.TotalDamage > 0 &&
!recentlyInjected.HasComponent(entity))
{
var path = await _pathfinding.GetPath(owner, entity, SharedInteractionSystem.InteractionRange, cancelToken);
if (path.Result == PathResult.NoPath)
continue;
return (true, new Dictionary<string, object>()
{
{TargetKey, entity},
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates}
{TargetMoveKey, _entManager.GetComponent<TransformComponent>(entity).Coordinates},
{NPCBlackboard.PathfindKey, path},
});
}
}