Update content for pause event changes (#12970)

This commit is contained in:
metalgearsloth 2022-12-14 11:55:51 +11:00 committed by GitHub
parent c64b8cec4c
commit 6fa9104ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 36 deletions

View File

@ -45,18 +45,16 @@ public sealed partial class PathfindingSystem
{
SubscribeLocalEvent<GridInitializeEvent>(OnGridInit);
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
SubscribeLocalEvent<GridPathfindingComponent, EntityPausedEvent>(OnGridPathPause);
SubscribeLocalEvent<GridPathfindingComponent, EntityUnpausedEvent>(OnGridPathPause);
SubscribeLocalEvent<GridPathfindingComponent, ComponentShutdown>(OnGridPathShutdown);
SubscribeLocalEvent<CollisionChangeEvent>(OnCollisionChange);
SubscribeLocalEvent<PhysicsBodyTypeChangedEvent>(OnBodyTypeChange);
SubscribeLocalEvent<MoveEvent>(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)

View File

@ -34,15 +34,22 @@ namespace Content.Server.Power.EntitySystems
SubscribeLocalEvent<ApcPowerReceiverComponent, ComponentInit>(ApcPowerReceiverInit);
SubscribeLocalEvent<ApcPowerReceiverComponent, ComponentShutdown>(ApcPowerReceiverShutdown);
SubscribeLocalEvent<ApcPowerReceiverComponent, EntityPausedEvent>(ApcPowerReceiverPaused);
SubscribeLocalEvent<ApcPowerReceiverComponent, EntityUnpausedEvent>(ApcPowerReceiverUnpaused);
SubscribeLocalEvent<PowerNetworkBatteryComponent, ComponentInit>(BatteryInit);
SubscribeLocalEvent<PowerNetworkBatteryComponent, ComponentShutdown>(BatteryShutdown);
SubscribeLocalEvent<PowerNetworkBatteryComponent, EntityPausedEvent>(BatteryPaused);
SubscribeLocalEvent<PowerNetworkBatteryComponent, EntityUnpausedEvent>(BatteryUnpaused);
SubscribeLocalEvent<PowerConsumerComponent, ComponentInit>(PowerConsumerInit);
SubscribeLocalEvent<PowerConsumerComponent, ComponentShutdown>(PowerConsumerShutdown);
SubscribeLocalEvent<PowerConsumerComponent, EntityPausedEvent>(PowerConsumerPaused);
SubscribeLocalEvent<PowerConsumerComponent, EntityUnpausedEvent>(PowerConsumerUnpaused);
SubscribeLocalEvent<PowerSupplierComponent, ComponentInit>(PowerSupplierInit);
SubscribeLocalEvent<PowerSupplierComponent, ComponentShutdown>(PowerSupplierShutdown);
SubscribeLocalEvent<PowerSupplierComponent, EntityPausedEvent>(PowerSupplierPaused);
SubscribeLocalEvent<PowerSupplierComponent, EntityUnpausedEvent>(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)

View File

@ -73,7 +73,7 @@ public sealed partial class ShuttleSystem
SubscribeLocalEvent<FTLDestinationComponent, EntityPausedEvent>(OnDestinationPause);
}
private void OnDestinationPause(EntityUid uid, FTLDestinationComponent component, EntityPausedEvent args)
private void OnDestinationPause(EntityUid uid, FTLDestinationComponent component, ref EntityPausedEvent args)
{
_console.RefreshShuttleConsoles();
}

View File

@ -18,6 +18,7 @@ public abstract class SharedStealthSystem : EntitySystem
SubscribeLocalEvent<StealthOnMoveComponent, MoveEvent>(OnMove);
SubscribeLocalEvent<StealthOnMoveComponent, GetVisibilityModifiersEvent>(OnGetVisibilityModifiers);
SubscribeLocalEvent<StealthComponent, EntityPausedEvent>(OnPaused);
SubscribeLocalEvent<StealthComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<StealthComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<StealthComponent, ExamineAttemptEvent>(OnExamineAttempt);
SubscribeLocalEvent<StealthComponent, ExaminedEvent>(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);
}

View File

@ -20,23 +20,23 @@ public sealed class UseDelaySystem : EntitySystem
SubscribeLocalEvent<UseDelayComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<UseDelayComponent, EntityPausedEvent>(OnPaused);
SubscribeLocalEvent<UseDelayComponent, EntityUnpausedEvent>(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.