Convert atmos device events to ref events (#22843)

This commit is contained in:
Kara
2023-12-21 18:48:18 -07:00
committed by GitHub
parent ee0c3c4a69
commit bc1f8b0e40
25 changed files with 111 additions and 93 deletions

View File

@@ -16,6 +16,9 @@ namespace Content.Server.Atmos.Piping.EntitySystems
// Set of atmos devices that are off-grid but have JoinSystem set.
private readonly HashSet<Entity<AtmosDeviceComponent>> _joinedDevices = new();
private static AtmosDeviceDisabledEvent _disabledEv = new();
private static AtmosDeviceEnabledEvent _enabledEv = new();
public override void Initialize()
{
base.Initialize();
@@ -45,7 +48,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
}
component.LastProcess = _gameTiming.CurTime;
RaiseLocalEvent(ent, new AtmosDeviceEnabledEvent());
RaiseLocalEvent(ent, ref _enabledEv);
}
public void LeaveAtmosphere(Entity<AtmosDeviceComponent> ent)
@@ -66,7 +69,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
}
component.LastProcess = TimeSpan.Zero;
RaiseLocalEvent(ent, new AtmosDeviceDisabledEvent());
RaiseLocalEvent(ent, ref _disabledEv);
}
public void RejoinAtmosphere(Entity<AtmosDeviceComponent> component)
@@ -116,9 +119,10 @@ namespace Content.Server.Atmos.Piping.EntitySystems
_timer -= _atmosphereSystem.AtmosTime;
var time = _gameTiming.CurTime;
var ev = new AtmosDeviceUpdateEvent(_atmosphereSystem.AtmosTime);
foreach (var device in _joinedDevices)
{
RaiseLocalEvent(device, new AtmosDeviceUpdateEvent(_atmosphereSystem.AtmosTime));
RaiseLocalEvent(device, ref ev);
device.Comp.LastProcess = time;
}
}