Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Fluids;
|
||||
using Content.Shared.Fluids.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Fluids.Components;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -96,7 +95,7 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
|
||||
if (drainSolution.MaxVolume == drainSolution.Volume)
|
||||
{
|
||||
_puddleSystem.TrySpillAt(Transform(target).Coordinates, containerSolution, out var puddle);
|
||||
_puddleSystem.TrySpillAt(Transform(target).Coordinates, containerSolution, out _);
|
||||
_popupSystem.PopupEntity(
|
||||
Loc.GetString("drain-component-empty-verb-target-is-full-message", ("object", target)),
|
||||
container);
|
||||
@@ -111,7 +110,8 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
var puddleQuery = GetEntityQuery<PuddleComponent>();
|
||||
var puddles = new ValueList<(EntityUid Entity, string Solution)>();
|
||||
|
||||
foreach (var drain in EntityQuery<DrainComponent>())
|
||||
var query = EntityQueryEnumerator<DrainComponent>();
|
||||
while (query.MoveNext(out var uid, out var drain))
|
||||
{
|
||||
drain.Accumulator += frameTime;
|
||||
if (drain.Accumulator < drain.DrainFrequency)
|
||||
@@ -123,32 +123,32 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
// Disable ambient sound from emptying manually
|
||||
if (!drain.AutoDrain)
|
||||
{
|
||||
_ambientSoundSystem.SetAmbience(drain.Owner, false);
|
||||
_ambientSoundSystem.SetAmbience(uid, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!managerQuery.TryGetComponent(drain.Owner, out var manager))
|
||||
if (!managerQuery.TryGetComponent(uid, out var manager))
|
||||
continue;
|
||||
|
||||
// Best to do this one every second rather than once every tick...
|
||||
_solutionSystem.TryGetSolution(drain.Owner, DrainComponent.SolutionName, out var drainSolution, manager);
|
||||
_solutionSystem.TryGetSolution(uid, DrainComponent.SolutionName, out var drainSolution, manager);
|
||||
|
||||
if (drainSolution is null)
|
||||
continue;
|
||||
|
||||
if (drainSolution.AvailableVolume <= 0)
|
||||
{
|
||||
_ambientSoundSystem.SetAmbience(drain.Owner, false);
|
||||
_ambientSoundSystem.SetAmbience(uid, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove a bit from the buffer
|
||||
_solutionSystem.SplitSolution(drain.Owner, drainSolution, (drain.UnitsDestroyedPerSecond * drain.DrainFrequency));
|
||||
_solutionSystem.SplitSolution(uid, drainSolution, (drain.UnitsDestroyedPerSecond * drain.DrainFrequency));
|
||||
|
||||
// This will ensure that UnitsPerSecond is per second...
|
||||
var amount = drain.UnitsPerSecond * drain.DrainFrequency;
|
||||
|
||||
if (!xformQuery.TryGetComponent(drain.Owner, out var xform))
|
||||
if (!xformQuery.TryGetComponent(uid, out var xform))
|
||||
continue;
|
||||
|
||||
puddles.Clear();
|
||||
@@ -165,11 +165,11 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
|
||||
if (puddles.Count == 0)
|
||||
{
|
||||
_ambientSoundSystem.SetAmbience(drain.Owner, false);
|
||||
_ambientSoundSystem.SetAmbience(uid, false);
|
||||
continue;
|
||||
}
|
||||
|
||||
_ambientSoundSystem.SetAmbience(drain.Owner, true);
|
||||
_ambientSoundSystem.SetAmbience(uid, true);
|
||||
|
||||
amount /= puddles.Count;
|
||||
|
||||
@@ -190,7 +190,7 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
var transferSolution = _solutionSystem.SplitSolution(puddle, puddleSolution,
|
||||
FixedPoint2.Min(FixedPoint2.New(amount), puddleSolution.Volume, drainSolution.AvailableVolume));
|
||||
|
||||
_solutionSystem.TryAddSolution(drain.Owner, drainSolution, transferSolution);
|
||||
_solutionSystem.TryAddSolution(uid, drainSolution, transferSolution);
|
||||
|
||||
if (puddleSolution.Volume <= 0)
|
||||
{
|
||||
@@ -203,13 +203,15 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
private void OnExamined(EntityUid uid, DrainComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!args.IsInDetailsRange ||
|
||||
!TryComp(uid, out SolutionContainerManagerComponent? solutionComp) ||
|
||||
!HasComp<SolutionContainerManagerComponent>(uid) ||
|
||||
!_solutionSystem.TryGetSolution(uid, DrainComponent.SolutionName, out var drainSolution))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var text = drainSolution.AvailableVolume != 0 ?
|
||||
Loc.GetString("drain-component-examine-volume", ("volume", drainSolution.AvailableVolume)) :
|
||||
Loc.GetString("drain-component-examine-hint-full");
|
||||
var text = drainSolution.AvailableVolume != 0
|
||||
? Loc.GetString("drain-component-examine-volume", ("volume", drainSolution.AvailableVolume))
|
||||
: Loc.GetString("drain-component-examine-hint-full");
|
||||
args.Message.AddMarkup($"\n\n{text}");
|
||||
}
|
||||
|
||||
@@ -218,7 +220,9 @@ public sealed class DrainSystem : SharedDrainSystem
|
||||
if (!args.CanReach || args.Target == null ||
|
||||
!_tagSystem.HasTag(args.Used, DrainComponent.PlungerTag) ||
|
||||
!_solutionSystem.TryGetSolution(args.Target.Value, DrainComponent.SolutionName, out var drainSolution))
|
||||
{ return; }
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (drainSolution.AvailableVolume > 0)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Numerics;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Fluids;
|
||||
using Content.Shared.Fluids.Components;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems;
|
||||
@@ -15,7 +15,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
|
||||
[Dependency] private readonly PuddleSystem _puddle = default!;
|
||||
|
||||
private readonly HashSet<IPlayerSession> _playerObservers = new();
|
||||
|
||||
private List<Entity<MapGridComponent>> _grids = new();
|
||||
|
||||
public bool ToggleObserver(IPlayerSession observer)
|
||||
{
|
||||
@@ -58,8 +58,10 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
|
||||
var worldBounds = Box2.CenteredAround(transform.WorldPosition,
|
||||
new Vector2(LocalViewRange, LocalViewRange));
|
||||
|
||||
_grids.Clear();
|
||||
_mapManager.FindGridsIntersecting(transform.MapID, worldBounds, ref _grids);
|
||||
|
||||
foreach (var grid in _mapManager.FindGridsIntersecting(transform.MapID, worldBounds))
|
||||
foreach (var grid in _grids)
|
||||
{
|
||||
var data = new List<PuddleDebugOverlayData>();
|
||||
var gridUid = grid.Owner;
|
||||
@@ -67,7 +69,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
|
||||
if (!Exists(gridUid))
|
||||
continue;
|
||||
|
||||
foreach (var uid in grid.GetAnchoredEntities(worldBounds))
|
||||
foreach (var uid in grid.Comp.GetAnchoredEntities(worldBounds))
|
||||
{
|
||||
PuddleComponent? puddle = null;
|
||||
TransformComponent? xform = null;
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Server.Spreader;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Effects;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Fluids;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Slippery;
|
||||
using Content.Shared.Fluids.Components;
|
||||
using Content.Shared.Friction;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Slippery;
|
||||
using Content.Shared.StepTrigger.Components;
|
||||
using Content.Shared.StepTrigger.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -22,14 +27,9 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Solution = Content.Shared.Chemistry.Components.Solution;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Effects;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems;
|
||||
|
||||
@@ -509,8 +509,11 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
|
||||
return false;
|
||||
|
||||
var targets = new List<EntityUid>();
|
||||
var reactive = new HashSet<Entity<ReactiveComponent>>();
|
||||
_lookup.GetEntitiesInRange(coordinates, 1.0f, reactive);
|
||||
|
||||
// Get reactive entities nearby--if there are some, it'll spill a bit on them instead.
|
||||
foreach (var ent in _lookup.GetComponentsInRange<ReactiveComponent>(coordinates, 1.0f))
|
||||
foreach (var ent in reactive)
|
||||
{
|
||||
// sorry! no overload for returning uid, so .owner must be used
|
||||
var owner = ent.Owner;
|
||||
|
||||
@@ -130,14 +130,15 @@ public sealed class SpraySystem : EntitySystem
|
||||
|
||||
// Add the solution to the vapor and actually send the thing
|
||||
var vaporComponent = Comp<VaporComponent>(vapor);
|
||||
_vapor.TryAddSolution(vaporComponent, newSolution);
|
||||
var ent = (vapor, vaporComponent);
|
||||
_vapor.TryAddSolution(ent, newSolution);
|
||||
|
||||
// impulse direction is defined in world-coordinates, not local coordinates
|
||||
var impulseDirection = rotation.ToVec();
|
||||
var time = diffLength / component.SprayVelocity;
|
||||
cooldownTime = MathF.Max(time, cooldownTime);
|
||||
|
||||
_vapor.Start(vaporComponent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
|
||||
_vapor.Start(ent, vaporXform, impulseDirection * diffLength, component.SprayVelocity, target, time, args.User);
|
||||
|
||||
if (TryComp<PhysicsComponent>(args.User, out var body))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user