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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user