diff --git a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickEntityNearMobOperator.cs b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickEntityNearMobOperator.cs index 878388c62d..1f10633ae7 100644 --- a/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickEntityNearMobOperator.cs +++ b/Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/PickEntityNearMobOperator.cs @@ -5,7 +5,6 @@ using Content.Shared.Interaction; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; using Content.Shared.Whitelist; -using Robust.Server.Containers; namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific; @@ -17,7 +16,6 @@ public sealed partial class PickEntityNearMobOperator : HTNOperator [Dependency] private IEntityManager _entManager = default!; private EntityLookupSystem _lookup = default!; private PathfindingSystem _pathfinding = default!; - private ContainerSystem _container = default!; private EntityWhitelistSystem _entityWhitelist = default!; /// @@ -73,7 +71,6 @@ public sealed partial class PickEntityNearMobOperator : HTNOperator base.Initialize(sysManager); _lookup = sysManager.GetEntitySystem(); _pathfinding = sysManager.GetEntitySystem(); - _container = sysManager.GetEntitySystem(); _entityWhitelist = sysManager.GetEntitySystem(); } @@ -85,47 +82,42 @@ public sealed partial class PickEntityNearMobOperator : HTNOperator if (!blackboard.TryGetValue(RangeKey, out var range, _entManager)) return (false, null); - if (!blackboard.TryGetValue(RangeKey, out var mobRange, _entManager)) + if (!blackboard.TryGetValue(MobRangeKey, out var mobRange, _entManager)) return (false, null); var mobState = _entManager.GetEntityQuery(); - foreach (var entity in _lookup.GetEntitiesInRange(owner, range)) + foreach (var mob in _lookup.GetEntitiesInRange(owner, mobRange, LookupFlags.Uncontained & ~LookupFlags.Sensors)) { - if (!_entityWhitelist.CheckBoth(entity, Blacklist, Whitelist)) + if (mob == owner) continue; - //checking if there is anyone NEAR the entity we found - foreach (var mob in _lookup.GetEntitiesInRange(entity, mobRange)) + if (!mobState.TryGetComponent(mob, out var state)) + continue; + + if (MobState != null && state.CurrentState != MobState) + continue; + + foreach (var entity in _lookup.GetEntitiesInRange(mob, range)) { - if (mob == owner) + if (!_entityWhitelist.CheckBoth(entity, Blacklist, Whitelist)) continue; - if (_container.IsEntityInContainer(mob)) - continue; + var pathRange = SharedInteractionSystem.InteractionRange; + var path = await _pathfinding.GetPath(owner, mob, pathRange, cancelToken); - if (mobState.TryGetComponent(mob, out var state)) + if (path.Result == PathResult.NoPath) + return (false, null); + + return (true, new Dictionary() { - if (MobState != null && state.CurrentState != MobState) - continue; - - var pathRange = SharedInteractionSystem.InteractionRange; - var path = await _pathfinding.GetPath(owner, mob, pathRange, cancelToken); - - if (path.Result == PathResult.NoPath) - return (false, null); - - return (true, new Dictionary() - { - {TargetKey, mob}, - {NearbyEntityTargetKey, entity}, - {TargetMoveKey, _entManager.GetComponent(mob).Coordinates}, - {NPCBlackboard.PathfindKey, path}, - }); - } + {TargetKey, mob}, + {NearbyEntityTargetKey, entity}, + {TargetMoveKey, _entManager.GetComponent(mob).Coordinates}, + {NPCBlackboard.PathfindKey, path}, + }); } } - return (false, null); } } diff --git a/Resources/Prototypes/NPCs/monkey.yml b/Resources/Prototypes/NPCs/monkey.yml index 3e321a2d38..1e1bf09056 100644 --- a/Resources/Prototypes/NPCs/monkey.yml +++ b/Resources/Prototypes/NPCs/monkey.yml @@ -14,12 +14,12 @@ - tasks: - !type:HTNPrimitiveTask operator: !type:PickEntityNearMobOperator - rangeKey: VisionRadius + rangeKey: InteractRange targetKey: FlushableTarget nearbyEntityTargetKey: DisposalBinTarget targetMoveKey: TargetCoordinates mobState: Critical - mobRangeKey: InteractRange + mobRangeKey: VisionRadius whitelist: components: - DisposalUnit