From: Tayrtahn Date: Mon, 23 Jun 2025 20:41:41 +0000 (-0400) Subject: Remove excess `SingularityLevelChangedEvent` subscriptions (#38536) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=b68c6b37ac8244552e675145f86a0b2654a26846;p=space-station-14.git Remove excess `SingularityLevelChangedEvent` subscriptions (#38536) * Remove excess SingularityLevelChangedEvent subscriptions * RadiationSourceComponent too * Cleanup commented out code --- diff --git a/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs b/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs index acac1dfd84..b7bf071457 100644 --- a/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs +++ b/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs @@ -45,10 +45,6 @@ public abstract class SharedSingularitySystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnSingularityStartup); - SubscribeLocalEvent(UpdateAppearance); - SubscribeLocalEvent(UpdateRadiation); - SubscribeLocalEvent(UpdateBody); - SubscribeLocalEvent(UpdateEventHorizon); SubscribeLocalEvent(UpdateDistortion); SubscribeLocalEvent(UpdateDistortion); SubscribeLocalEvent(UpdateDistortion); @@ -121,9 +117,32 @@ public abstract class SharedSingularitySystem : EntitySystem /// The state of the singularity which's level has changed. public void UpdateSingularityLevel(EntityUid uid, byte oldValue, SingularityComponent? singularity = null) { - if(!Resolve(uid, ref singularity)) + if (!Resolve(uid, ref singularity)) return; + if (TryComp(uid, out var eventHorizon)) + { + _horizons.SetRadius(uid, EventHorizonRadius(singularity), false, eventHorizon); + _horizons.SetCanBreachContainment(uid, CanBreachContainment(singularity), false, eventHorizon); + _horizons.UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon); + } + + if (TryComp(uid, out var body)) + { + if (singularity.Level <= 1 && oldValue > 1) // Apparently keeps singularities from getting stuck in the corners of containment fields. + _physics.SetLinearVelocity(uid, Vector2.Zero, body: body); // No idea how stopping the singularities movement keeps it from getting stuck though. + } + + if (TryComp(uid, out var appearance)) + { + _visualizer.SetData(uid, SingularityAppearanceKeys.Singularity, singularity.Level, appearance); + } + + if (TryComp(uid, out var radiationSource)) + { + UpdateRadiation(uid, singularity, radiationSource); + } + RaiseLocalEvent(uid, new SingularityLevelChangedEvent(singularity.Level, oldValue, singularity)); if (singularity.Level <= 0) QueueDel(uid); @@ -274,21 +293,6 @@ public abstract class SharedSingularitySystem : EntitySystem UpdateSingularityLevel(uid, comp); } - // TODO: Figure out which systems should have control of which coupling. - /// - /// Syncs the radius of an event horizon associated with a singularity that just changed levels. - /// - /// The entity that the event horizon and singularity are attached to. - /// The event horizon associated with the singularity. - /// The event arguments. - private void UpdateEventHorizon(EntityUid uid, EventHorizonComponent comp, SingularityLevelChangedEvent args) - { - var singulo = args.Singularity; - _horizons.SetRadius(uid, EventHorizonRadius(singulo), false, comp); - _horizons.SetCanBreachContainment(uid, CanBreachContainment(singulo), false, comp); - _horizons.UpdateEventHorizonFixture(uid, eventHorizon: comp); - } - /// /// Updates the distortion shader associated with a singularity when the singuarity changes levels. /// @@ -346,40 +350,6 @@ public abstract class SharedSingularitySystem : EntitySystem comp.Intensity = absIntensity > 1 ? comp.Intensity * MathF.Pow(absIntensity, factor) : comp.Intensity; } - /// - /// Updates the state of the physics body associated with a singularity when the singualrity changes levels. - /// - /// The entity that the physics body and singularity are attached to. - /// The physics body associated with the singularity. - /// The event arguments. - private void UpdateBody(EntityUid uid, PhysicsComponent comp, SingularityLevelChangedEvent args) - { - if (args.NewValue <= 1 && args.OldValue > 1) // Apparently keeps singularities from getting stuck in the corners of containment fields. - _physics.SetLinearVelocity(uid, Vector2.Zero, body: comp); // No idea how stopping the singularities movement keeps it from getting stuck though. - } - - /// - /// Updates the appearance of a singularity when the singularities level changes. - /// - /// The entity that the singularity is attached to. - /// The appearance associated with the singularity. - /// The event arguments. - private void UpdateAppearance(EntityUid uid, AppearanceComponent comp, SingularityLevelChangedEvent args) - { - _visualizer.SetData(uid, SingularityAppearanceKeys.Singularity, args.NewValue, comp); - } - - /// - /// Updates the amount of radiation a singularity emits when the singularities level changes. - /// - /// The entity that the singularity is attached to. - /// The radiation source associated with the singularity. - /// The event arguments. - private void UpdateRadiation(EntityUid uid, RadiationSourceComponent comp, SingularityLevelChangedEvent args) - { - UpdateRadiation(uid, args.Singularity, comp); - } - #endregion EventHandlers }