Fix cleanbots (#16922)

This commit is contained in:
metalgearsloth
2023-05-29 16:53:28 +10:00
committed by GitHub
parent c3e369cbdd
commit f308a1b31e
7 changed files with 75 additions and 125 deletions

View File

@@ -1,5 +1,7 @@
using System.Linq;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Examine;
using Content.Server.Fluids.EntitySystems;
using Content.Server.NPC.Queries;
using Content.Server.NPC.Queries.Considerations;
using Content.Server.NPC.Queries.Curves;
@@ -8,8 +10,10 @@ using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Server.Storage.Components;
using Content.Shared.Examine;
using Content.Shared.Fluids.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Containers;
using Robust.Shared.Collections;
using Robust.Shared.Prototypes;
namespace Content.Server.NPC.Systems;
@@ -23,9 +27,11 @@ public sealed class NPCUtilitySystem : EntitySystem
[Dependency] private readonly ContainerSystem _container = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FactionSystem _faction = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly FoodSystem _food = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PuddleSystem _puddle = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
/// <summary>
/// Runs the UtilityQueryPrototype and returns the best-matching entities.
@@ -269,10 +275,31 @@ public sealed class NPCUtilitySystem : EntitySystem
private void Filter(NPCBlackboard blackboard, HashSet<EntityUid> entities, UtilityQueryFilter filter)
{
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
switch (filter)
{
case PuddleFilter:
{
var puddleQuery = GetEntityQuery<PuddleComponent>();
var toRemove = new ValueList<EntityUid>();
foreach (var ent in entities)
{
if (!puddleQuery.TryGetComponent(ent, out var puddleComp) ||
!_solutions.TryGetSolution(ent, puddleComp.SolutionName, out var sol) ||
_puddle.CanFullyEvaporate(sol))
{
toRemove.Add(ent);
}
}
foreach (var ent in toRemove)
{
entities.Remove(ent);
}
break;
}
default:
throw new NotImplementedException();
}