From 6fa9104ad7cd616410788fc4fdf84bf8905d0e05 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 14 Dec 2022 11:55:51 +1100 Subject: [PATCH] Update content for pause event changes (#12970) --- .../NPC/Pathfinding/PathfindingSystem.Grid.cs | 8 ++-- .../Power/EntitySystems/PowerNetSystem.cs | 46 +++++++++++++++---- .../Systems/ShuttleSystem.FasterThanLight.cs | 2 +- Content.Shared/Stealth/SharedStealthSystem.cs | 19 ++++---- Content.Shared/Timing/UseDelaySystem.cs | 24 +++++----- 5 files changed, 63 insertions(+), 36 deletions(-) diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs index f502d7b4c5..d9d2fb4033 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs @@ -45,18 +45,16 @@ public sealed partial class PathfindingSystem { SubscribeLocalEvent(OnGridInit); SubscribeLocalEvent(OnGridRemoved); - SubscribeLocalEvent(OnGridPathPause); + SubscribeLocalEvent(OnGridPathPause); SubscribeLocalEvent(OnGridPathShutdown); SubscribeLocalEvent(OnCollisionChange); SubscribeLocalEvent(OnBodyTypeChange); SubscribeLocalEvent(OnMoveEvent); } - private void OnGridPathPause(EntityUid uid, GridPathfindingComponent component, EntityPausedEvent args) + private void OnGridPathPause(EntityUid uid, GridPathfindingComponent component, ref EntityUnpausedEvent args) { - // TODO: Need the offsets + time serializer. Mainly just need this here to ensure it gets update after load - if (!args.Paused && component.NextUpdate < _timing.CurTime) - component.NextUpdate = _timing.CurTime; + component.NextUpdate += args.PausedTime; } private void OnGridPathShutdown(EntityUid uid, GridPathfindingComponent component, ComponentShutdown args) diff --git a/Content.Server/Power/EntitySystems/PowerNetSystem.cs b/Content.Server/Power/EntitySystems/PowerNetSystem.cs index 94f736df9d..a9898f8cce 100644 --- a/Content.Server/Power/EntitySystems/PowerNetSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerNetSystem.cs @@ -34,15 +34,22 @@ namespace Content.Server.Power.EntitySystems SubscribeLocalEvent(ApcPowerReceiverInit); SubscribeLocalEvent(ApcPowerReceiverShutdown); SubscribeLocalEvent(ApcPowerReceiverPaused); + SubscribeLocalEvent(ApcPowerReceiverUnpaused); + SubscribeLocalEvent(BatteryInit); SubscribeLocalEvent(BatteryShutdown); SubscribeLocalEvent(BatteryPaused); + SubscribeLocalEvent(BatteryUnpaused); + SubscribeLocalEvent(PowerConsumerInit); SubscribeLocalEvent(PowerConsumerShutdown); SubscribeLocalEvent(PowerConsumerPaused); + SubscribeLocalEvent(PowerConsumerUnpaused); + SubscribeLocalEvent(PowerSupplierInit); SubscribeLocalEvent(PowerSupplierShutdown); SubscribeLocalEvent(PowerSupplierPaused); + SubscribeLocalEvent(PowerSupplierUnpaused); } private void ApcPowerReceiverInit(EntityUid uid, ApcPowerReceiverComponent component, ComponentInit args) @@ -59,9 +66,17 @@ namespace Content.Server.Power.EntitySystems private static void ApcPowerReceiverPaused( EntityUid uid, ApcPowerReceiverComponent component, - EntityPausedEvent args) + ref EntityPausedEvent args) { - component.NetworkLoad.Paused = args.Paused; + component.NetworkLoad.Paused = true; + } + + private static void ApcPowerReceiverUnpaused( + EntityUid uid, + ApcPowerReceiverComponent component, + ref EntityUnpausedEvent args) + { + component.NetworkLoad.Paused = false; } private void BatteryInit(EntityUid uid, PowerNetworkBatteryComponent component, ComponentInit args) @@ -74,9 +89,14 @@ namespace Content.Server.Power.EntitySystems _powerState.Batteries.Free(component.NetworkBattery.Id); } - private static void BatteryPaused(EntityUid uid, PowerNetworkBatteryComponent component, EntityPausedEvent args) + private static void BatteryPaused(EntityUid uid, PowerNetworkBatteryComponent component, ref EntityPausedEvent args) { - component.NetworkBattery.Paused = args.Paused; + component.NetworkBattery.Paused = true; + } + + private static void BatteryUnpaused(EntityUid uid, PowerNetworkBatteryComponent component, ref EntityUnpausedEvent args) + { + component.NetworkBattery.Paused = false; } private void PowerConsumerInit(EntityUid uid, PowerConsumerComponent component, ComponentInit args) @@ -89,9 +109,14 @@ namespace Content.Server.Power.EntitySystems _powerState.Loads.Free(component.NetworkLoad.Id); } - private static void PowerConsumerPaused(EntityUid uid, PowerConsumerComponent component, EntityPausedEvent args) + private static void PowerConsumerPaused(EntityUid uid, PowerConsumerComponent component, ref EntityPausedEvent args) { - component.NetworkLoad.Paused = args.Paused; + component.NetworkLoad.Paused = true; + } + + private static void PowerConsumerUnpaused(EntityUid uid, PowerConsumerComponent component, ref EntityUnpausedEvent args) + { + component.NetworkLoad.Paused = false; } private void PowerSupplierInit(EntityUid uid, PowerSupplierComponent component, ComponentInit args) @@ -104,9 +129,14 @@ namespace Content.Server.Power.EntitySystems _powerState.Supplies.Free(component.NetworkSupply.Id); } - private static void PowerSupplierPaused(EntityUid uid, PowerSupplierComponent component, EntityPausedEvent args) + private static void PowerSupplierPaused(EntityUid uid, PowerSupplierComponent component, ref EntityPausedEvent args) { - component.NetworkSupply.Paused = args.Paused; + component.NetworkSupply.Paused = true; + } + + private static void PowerSupplierUnpaused(EntityUid uid, PowerSupplierComponent component, ref EntityUnpausedEvent args) + { + component.NetworkSupply.Paused = false; } public void InitPowerNet(PowerNet powerNet) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index ca293d7b98..7e47f9a06b 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -73,7 +73,7 @@ public sealed partial class ShuttleSystem SubscribeLocalEvent(OnDestinationPause); } - private void OnDestinationPause(EntityUid uid, FTLDestinationComponent component, EntityPausedEvent args) + private void OnDestinationPause(EntityUid uid, FTLDestinationComponent component, ref EntityPausedEvent args) { _console.RefreshShuttleConsoles(); } diff --git a/Content.Shared/Stealth/SharedStealthSystem.cs b/Content.Shared/Stealth/SharedStealthSystem.cs index 7d5840c9a2..89f848f3c0 100644 --- a/Content.Shared/Stealth/SharedStealthSystem.cs +++ b/Content.Shared/Stealth/SharedStealthSystem.cs @@ -18,6 +18,7 @@ public abstract class SharedStealthSystem : EntitySystem SubscribeLocalEvent(OnMove); SubscribeLocalEvent(OnGetVisibilityModifiers); SubscribeLocalEvent(OnPaused); + SubscribeLocalEvent(OnUnpaused); SubscribeLocalEvent(OnInit); SubscribeLocalEvent(OnExamineAttempt); SubscribeLocalEvent(OnExamined); @@ -57,18 +58,16 @@ public abstract class SharedStealthSystem : EntitySystem Dirty(component); } - private void OnPaused(EntityUid uid, StealthComponent component, EntityPausedEvent args) + private void OnPaused(EntityUid uid, StealthComponent component, ref EntityPausedEvent args) { - if (args.Paused) - { - component.LastVisibility = GetVisibility(uid, component); - component.LastUpdated = null; - } - else - { - component.LastUpdated = _timing.CurTime; - } + component.LastVisibility = GetVisibility(uid, component); + component.LastUpdated = null; + Dirty(component); + } + private void OnUnpaused(EntityUid uid, StealthComponent component, ref EntityUnpausedEvent args) + { + component.LastUpdated = _timing.CurTime; Dirty(component); } diff --git a/Content.Shared/Timing/UseDelaySystem.cs b/Content.Shared/Timing/UseDelaySystem.cs index 974c245a0c..3626370d89 100644 --- a/Content.Shared/Timing/UseDelaySystem.cs +++ b/Content.Shared/Timing/UseDelaySystem.cs @@ -20,23 +20,23 @@ public sealed class UseDelaySystem : EntitySystem SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnPaused); + SubscribeLocalEvent(OnUnpaused); } - private void OnPaused(EntityUid uid, UseDelayComponent component, EntityPausedEvent args) + private void OnPaused(EntityUid uid, UseDelayComponent component, ref EntityPausedEvent args) { - if (args.Paused) - { - // This entity just got paused, but wasn't before - if (component.DelayEndTime != null) - component.RemainingDelay = _gameTiming.CurTime - component.DelayEndTime; + // This entity just got paused, but wasn't before + if (component.DelayEndTime != null) + component.RemainingDelay = _gameTiming.CurTime - component.DelayEndTime; - _activeDelays.Remove(component); - } - else if (component.RemainingDelay == null) - { - // Got unpaused, but had no active delay + _activeDelays.Remove(component); + Dirty(component); + } + + private void OnUnpaused(EntityUid uid, UseDelayComponent component, ref EntityUnpausedEvent args) + { + if (component.RemainingDelay == null) return; - } // We got unpaused, resume the delay/cooldown. Currently this takes for granted that ItemCooldownComponent // handles the pausing on its own. I'm not even gonna check, because I CBF fixing it if it doesn't.