Skip to content

Commit

Permalink
Use new ComponentPauseGenerator (#25183)
Browse files Browse the repository at this point in the history
Also includes some (non critical) changes to the solution file to re-organize the Roslyn components.
  • Loading branch information
Pieter-Jan Briers authored Feb 26, 2024
1 parent 2a2324e commit e00f745
Show file tree
Hide file tree
Showing 130 changed files with 150 additions and 539 deletions.
12 changes: 0 additions & 12 deletions Content.Server/Anomaly/AnomalySystem.Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ private void InitializeGenerator()
SubscribeLocalEvent<AnomalyGeneratorComponent, MaterialAmountChangedEvent>(OnGeneratorMaterialAmountChanged);
SubscribeLocalEvent<AnomalyGeneratorComponent, AnomalyGeneratorGenerateButtonPressedEvent>(OnGenerateButtonPressed);
SubscribeLocalEvent<AnomalyGeneratorComponent, PowerChangedEvent>(OnGeneratorPowerChanged);
SubscribeLocalEvent<AnomalyGeneratorComponent, EntityUnpausedEvent>(OnGeneratorUnpaused);
SubscribeLocalEvent<GeneratingAnomalyGeneratorComponent, ComponentStartup>(OnGeneratingStartup);
SubscribeLocalEvent<GeneratingAnomalyGeneratorComponent, EntityUnpausedEvent>(OnGeneratingUnpaused);
}

private void OnGeneratorPowerChanged(EntityUid uid, AnomalyGeneratorComponent component, ref PowerChangedEvent args)
Expand All @@ -58,11 +56,6 @@ private void OnGenerateButtonPressed(EntityUid uid, AnomalyGeneratorComponent co
TryGeneratorCreateAnomaly(uid, component);
}

private void OnGeneratorUnpaused(EntityUid uid, AnomalyGeneratorComponent component, ref EntityUnpausedEvent args)
{
component.CooldownEndTime += args.PausedTime;
}

public void UpdateGeneratorUi(EntityUid uid, AnomalyGeneratorComponent component)
{
var materialAmount = _material.GetMaterialAmount(uid, component.RequiredMaterial);
Expand Down Expand Up @@ -169,11 +162,6 @@ private void OnGeneratingStartup(EntityUid uid, GeneratingAnomalyGeneratorCompon
Appearance.SetData(uid, AnomalyGeneratorVisuals.Generating, true);
}

private void OnGeneratingUnpaused(EntityUid uid, GeneratingAnomalyGeneratorComponent component, ref EntityUnpausedEvent args)
{
component.EndTime += args.PausedTime;
}

private void OnGeneratingFinished(EntityUid uid, AnomalyGeneratorComponent component)
{
var xform = Transform(uid);
Expand Down
6 changes: 0 additions & 6 deletions Content.Server/Anomaly/AnomalySystem.Vessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ private void InitializeVessel()
SubscribeLocalEvent<AnomalyVesselComponent, InteractUsingEvent>(OnVesselInteractUsing);
SubscribeLocalEvent<AnomalyVesselComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<AnomalyVesselComponent, ResearchServerGetPointsPerSecondEvent>(OnVesselGetPointsPerSecond);
SubscribeLocalEvent<AnomalyVesselComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<AnomalyShutdownEvent>(OnShutdown);
SubscribeLocalEvent<AnomalyStabilityChangedEvent>(OnStabilityChanged);
}
Expand Down Expand Up @@ -92,11 +91,6 @@ private void OnVesselGetPointsPerSecond(EntityUid uid, AnomalyVesselComponent co
args.Points += (int) (GetAnomalyPointValue(anomaly) * component.PointMultiplier);
}

private void OnUnpaused(EntityUid uid, AnomalyVesselComponent component, ref EntityUnpausedEvent args)
{
component.NextBeep += args.PausedTime;
}

private void OnVesselAnomalyShutdown(ref AnomalyShutdownEvent args)
{
var query = EntityQueryEnumerator<AnomalyVesselComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ namespace Content.Server.Anomaly.Components;
/// This is used for a machine that is able to generate
/// anomalies randomly on the station.
/// </summary>
[RegisterComponent, Access(typeof(SharedAnomalySystem))]
[RegisterComponent, Access(typeof(SharedAnomalySystem)), AutoGenerateComponentPause]
public sealed partial class AnomalyGeneratorComponent : Component
{
/// <summary>
/// The time at which the cooldown for generating another anomaly will be over
/// </summary>
[DataField("cooldownEndTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan CooldownEndTime = TimeSpan.Zero;

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Anomaly/Components/AnomalyVesselComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Content.Server.Anomaly.Components;
/// they generate points for the selected server based on
/// the anomaly's stability and severity.
/// </summary>
[RegisterComponent, Access(typeof(SharedAnomalySystem))]
[RegisterComponent, Access(typeof(SharedAnomalySystem)), AutoGenerateComponentPause]
public sealed partial class AnomalyVesselComponent : Component
{
/// <summary>
Expand Down Expand Up @@ -42,6 +42,7 @@ public sealed partial class AnomalyVesselComponent : Component
/// When the next beep sound will play
/// </summary>
[DataField("nextBeep", customTypeSerializer:typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextBeep = TimeSpan.Zero;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

namespace Content.Server.Anomaly.Components;

[RegisterComponent, Access(typeof(SharedAnomalySystem))]
[RegisterComponent, Access(typeof(SharedAnomalySystem)), AutoGenerateComponentPause]
public sealed partial class GeneratingAnomalyGeneratorComponent : Component
{
/// <summary>
/// When the generating period will end.
/// </summary>
[DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan EndTime = TimeSpan.Zero;

public EntityUid? AudioStream;
Expand Down
12 changes: 0 additions & 12 deletions Content.Server/Atmos/Rotting/RottingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<PerishableComponent, MapInitEvent>(OnPerishableMapInit);
SubscribeLocalEvent<PerishableComponent, EntityUnpausedEvent>(OnPerishableUnpaused);
SubscribeLocalEvent<PerishableComponent, MobStateChangedEvent>(OnMobStateChanged);
SubscribeLocalEvent<PerishableComponent, ExaminedEvent>(OnPerishableExamined);

SubscribeLocalEvent<RottingComponent, EntityUnpausedEvent>(OnRottingUnpaused);
SubscribeLocalEvent<RottingComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<RottingComponent, MobStateChangedEvent>(OnRottingMobStateChanged);
SubscribeLocalEvent<RottingComponent, BeingGibbedEvent>(OnGibbed);
Expand All @@ -47,11 +45,6 @@ private void OnPerishableMapInit(EntityUid uid, PerishableComponent component, M
component.RotNextUpdate = _timing.CurTime + component.PerishUpdateRate;
}

private void OnPerishableUnpaused(EntityUid uid, PerishableComponent component, ref EntityUnpausedEvent args)
{
component.RotNextUpdate += args.PausedTime;
}

private void OnMobStateChanged(EntityUid uid, PerishableComponent component, MobStateChangedEvent args)
{
if (args.NewMobState != MobState.Dead && args.OldMobState != MobState.Dead)
Expand All @@ -64,11 +57,6 @@ private void OnMobStateChanged(EntityUid uid, PerishableComponent component, Mob
component.RotNextUpdate = _timing.CurTime + component.PerishUpdateRate;
}

private void OnRottingUnpaused(EntityUid uid, RottingComponent component, ref EntityUnpausedEvent args)
{
component.NextRotUpdate += args.PausedTime;
}

private void OnShutdown(EntityUid uid, RottingComponent component, ComponentShutdown args)
{
if (TryComp<PerishableComponent>(uid, out var perishable))
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Charges/Components/AutoRechargeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Content.Server.Charges.Components;
/// Something with limited charges that can be recharged automatically.
/// Requires LimitedChargesComponent to function.
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
[Access(typeof(ChargesSystem))]
public sealed partial class AutoRechargeComponent : Component
{
Expand All @@ -21,5 +21,6 @@ public sealed partial class AutoRechargeComponent : Component
/// The time when the next charge will be added
/// </summary>
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextChargeTime;
}
12 changes: 0 additions & 12 deletions Content.Server/Charges/Systems/ChargesSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ public sealed class ChargesSystem : SharedChargesSystem
{
[Dependency] private readonly IGameTiming _timing = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AutoRechargeComponent, EntityUnpausedEvent>(OnUnpaused);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand All @@ -32,11 +25,6 @@ public override void Update(float frameTime)
}
}

private void OnUnpaused(EntityUid uid, AutoRechargeComponent comp, ref EntityUnpausedEvent args)
{
comp.NextChargeTime += args.PausedTime;
}

protected override void OnExamine(EntityUid uid, LimitedChargesComponent comp, ExaminedEvent args)
{
base.OnExamine(uid, comp, args);
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Chat/EmoteOnDamageComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Content.Server.Chat;
/// <summary>
/// Causes an entity to automatically emote when taking damage.
/// </summary>
[RegisterComponent, Access(typeof(EmoteOnDamageSystem))]
[RegisterComponent, Access(typeof(EmoteOnDamageSystem)), AutoGenerateComponentPause]
public sealed partial class EmoteOnDamageComponent : Component
{
/// <summary>
Expand Down Expand Up @@ -41,6 +41,7 @@ public sealed partial class EmoteOnDamageComponent : Component
/// The simulation time of the last emote preformed due to taking damage.
/// </summary>
[DataField("lastEmoteTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan LastEmoteTime = TimeSpan.Zero;

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions Content.Server/Chat/Systems/EmoteOnDamageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<EmoteOnDamageComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<EmoteOnDamageComponent, DamageChangedEvent>(OnDamage);
}

private void OnUnpaused(EntityUid uid, EmoteOnDamageComponent emoteOnDamage, ref EntityUnpausedEvent args)
{
emoteOnDamage.LastEmoteTime += args.PausedTime;
}

private void OnDamage(EntityUid uid, EmoteOnDamageComponent emoteOnDamage, DamageChangedEvent args)
{
if (!args.DamageIncreased)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Content.Server.Chemistry.Components;
/// <summary>
/// Passively decreases a solution's quantity of reagent(s).
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
[Access(typeof(SolutionPurgeSystem))]
public sealed partial class SolutionPurgeComponent : Component
{
Expand Down Expand Up @@ -42,5 +42,6 @@ public sealed partial class SolutionPurgeComponent : Component
/// The time when the next purge will occur.
/// </summary>
[DataField("nextPurgeTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan NextPurgeTime = TimeSpan.FromSeconds(0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Content.Server.Chemistry.Components;
/// <summary>
/// Passively increases a solution's quantity of a reagent.
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
[Access(typeof(SolutionRegenerationSystem))]
public sealed partial class SolutionRegenerationComponent : Component
{
Expand Down Expand Up @@ -39,5 +39,6 @@ public sealed partial class SolutionRegenerationComponent : Component
/// The time when the next regeneration will occur.
/// </summary>
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
[AutoPausedField]
public TimeSpan NextRegenTime = TimeSpan.FromSeconds(0);
}
12 changes: 0 additions & 12 deletions Content.Server/Chemistry/EntitySystems/SolutionPurgeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ public sealed class SolutionPurgeSystem : EntitySystem
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly IGameTiming _timing = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SolutionPurgeComponent, EntityUnpausedEvent>(OnUnpaused);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand All @@ -33,9 +26,4 @@ public override void Update(float frameTime)
_solutionContainer.SplitSolutionWithout(solution.Value, purge.Quantity, purge.Preserve.ToArray());
}
}

private void OnUnpaused(Entity<SolutionPurgeComponent> entity, ref EntityUnpausedEvent args)
{
entity.Comp.NextPurgeTime += args.PausedTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ public sealed class SolutionRegenerationSystem : EntitySystem
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
[Dependency] private readonly IGameTiming _timing = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SolutionRegenerationComponent, EntityUnpausedEvent>(OnUnpaused);
}

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand Down Expand Up @@ -52,9 +45,4 @@ public override void Update(float frameTime)
}
}
}

private void OnUnpaused(Entity<SolutionRegenerationComponent> entity, ref EntityUnpausedEvent args)
{
entity.Comp.NextRegenTime += args.PausedTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public override void Initialize()

// Shouldn't need re-anchoring.
SubscribeLocalEvent<DisposalUnitComponent, AnchorStateChangedEvent>(OnAnchorChanged);
SubscribeLocalEvent<DisposalUnitComponent, EntityUnpausedEvent>(OnUnpaused);
// TODO: Predict me when hands predicted
SubscribeLocalEvent<DisposalUnitComponent, ContainerRelayMovementEntityEvent>(OnMovement);
SubscribeLocalEvent<DisposalUnitComponent, PowerChangedEvent>(OnPowerChange);
Expand Down Expand Up @@ -103,14 +102,6 @@ private void OnGetState(EntityUid uid, DisposalUnitComponent component, ref Comp
GetNetEntityList(component.RecentlyEjected));
}

private void OnUnpaused(EntityUid uid, SharedDisposalUnitComponent component, ref EntityUnpausedEvent args)
{
if (component.NextFlush != null)
component.NextFlush = component.NextFlush.Value + args.PausedTime;

component.NextPressurized += args.PausedTime;
}

private void AddDisposalAltVerbs(EntityUid uid, SharedDisposalUnitComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
Expand Down
7 changes: 0 additions & 7 deletions Content.Server/Emp/EmpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public sealed class EmpSystem : SharedEmpSystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EmpDisabledComponent, EntityUnpausedEvent>(OnUnpaused);
SubscribeLocalEvent<EmpDisabledComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<EmpOnTriggerComponent, TriggerEvent>(HandleEmpTrigger);

Expand Down Expand Up @@ -96,12 +95,6 @@ public override void Update(float frameTime)
}
}

private void OnUnpaused(EntityUid uid, EmpDisabledComponent component, ref EntityUnpausedEvent args)
{
component.DisabledUntil += args.PausedTime;
component.TargetTime += args.PausedTime;
}

private void OnExamine(EntityUid uid, EmpDisabledComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("emp-disabled-comp-on-examine"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Content.Server.Explosion.Components.OnTrigger;
/// <summary>
/// After being triggered applies the specified components and runs triggers again.
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class TwoStageTriggerComponent : Component
{
/// <summary>
Expand All @@ -23,6 +23,7 @@ public sealed partial class TwoStageTriggerComponent : Component
public ComponentRegistry SecondStageComponents = new();

[DataField("nextTriggerTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan? NextTriggerTime;

[DataField("triggered")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Content.Server.Explosion.Components
/// <summary>
/// Raises a <see cref="TriggerEvent"/> whenever an entity collides with a fixture attached to the owner of this component.
/// </summary>
[RegisterComponent]
[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class TriggerOnProximityComponent : SharedTriggerOnProximityComponent
{
public const string FixtureID = "trigger-on-proximity-fixture";
Expand Down Expand Up @@ -58,13 +58,15 @@ public sealed partial class TriggerOnProximityComponent : SharedTriggerOnProximi
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("nextTrigger", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextTrigger = TimeSpan.Zero;

/// <summary>
/// When will the visual state be updated again after activation?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("nextVisualUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField]
public TimeSpan NextVisualUpdate = TimeSpan.Zero;

/// <summary>
Expand Down
Loading

0 comments on commit e00f745

Please sign in to comment.