Remove 700 usages of Component.Owner (#21100)

This commit is contained in:
DrSmugleaf
2023-10-19 12:34:31 -07:00
committed by GitHub
parent 5825ffb95c
commit f560f88eb5
261 changed files with 2291 additions and 2036 deletions

View File

@@ -1,8 +1,7 @@
using System.Linq;
using Content.Server.Atmos.Monitor.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.Atmos.Monitor.Components;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.Power.Components;
@@ -87,7 +86,7 @@ public sealed class AtmosMonitorSystem : EntitySystem
if (!HasComp<ApcPowerReceiverComponent>(uid)
&& TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
{
_atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
_atmosDeviceSystem.LeaveAtmosphere((uid, atmosDeviceComponent));
}
}
@@ -155,18 +154,18 @@ public sealed class AtmosMonitorSystem : EntitySystem
}
}
private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, ref PowerChangedEvent args)
private void OnPowerChangedEvent(Entity<AtmosMonitorComponent> ent, ref PowerChangedEvent args)
{
if (TryComp<AtmosDeviceComponent>(uid, out var atmosDeviceComponent))
if (TryComp<AtmosDeviceComponent>(ent, out var atmosDeviceComponent))
{
if (!args.Powered)
{
_atmosDeviceSystem.LeaveAtmosphere(atmosDeviceComponent);
_atmosDeviceSystem.LeaveAtmosphere((ent, atmosDeviceComponent));
}
else
{
_atmosDeviceSystem.JoinAtmosphere(atmosDeviceComponent);
Alert(uid, component.LastAlarmState);
_atmosDeviceSystem.JoinAtmosphere((ent, atmosDeviceComponent));
Alert(ent, ent.Comp.LastAlarmState);
}
}
}
@@ -305,12 +304,13 @@ public sealed class AtmosMonitorSystem : EntitySystem
/// <param name="alarms">The alarms that caused this alarm state.</param>
public void Alert(EntityUid uid, AtmosAlarmType state, HashSet<AtmosMonitorThresholdType>? alarms = null, AtmosMonitorComponent? monitor = null)
{
if (!Resolve(uid, ref monitor)) return;
if (!Resolve(uid, ref monitor))
return;
monitor.LastAlarmState = state;
monitor.TrippedThresholds = alarms ?? monitor.TrippedThresholds;
BroadcastAlertPacket(monitor);
BroadcastAlertPacket((uid, monitor));
// TODO: Central system that grabs *all* alarms from wired network
}
@@ -336,11 +336,13 @@ public sealed class AtmosMonitorSystem : EntitySystem
/// is synced between monitors the moment a monitor sends out an alarm,
/// or if it is explicitly synced (see ResetAll/Sync).
/// </remarks>
private void BroadcastAlertPacket(AtmosMonitorComponent monitor, TagComponent? tags = null)
private void BroadcastAlertPacket(Entity<AtmosMonitorComponent> ent, TagComponent? tags = null)
{
if (!monitor.NetEnabled) return;
var (owner, monitor) = ent;
if (!monitor.NetEnabled)
return;
if (!Resolve(monitor.Owner, ref tags, false))
if (!Resolve(owner, ref tags, false))
{
return;
}
@@ -355,7 +357,7 @@ public sealed class AtmosMonitorSystem : EntitySystem
foreach (var addr in monitor.RegisteredDevices)
{
_deviceNetSystem.QueuePacket(monitor.Owner, addr, payload);
_deviceNetSystem.QueuePacket(owner, addr, payload);
}
}
@@ -367,7 +369,8 @@ public sealed class AtmosMonitorSystem : EntitySystem
/// <param name="gas">Gas, if applicable.</param>
public void SetThreshold(EntityUid uid, AtmosMonitorThresholdType type, AtmosAlarmThreshold threshold, Gas? gas = null, AtmosMonitorComponent? monitor = null)
{
if (!Resolve(uid, ref monitor)) return;
if (!Resolve(uid, ref monitor))
return;
switch (type)
{
@@ -378,7 +381,8 @@ public sealed class AtmosMonitorSystem : EntitySystem
monitor.TemperatureThreshold = threshold;
break;
case AtmosMonitorThresholdType.Gas:
if (gas == null || monitor.GasThresholds == null) return;
if (gas == null || monitor.GasThresholds == null)
return;
monitor.GasThresholds[(Gas) gas] = threshold;
break;
}