From e4cf2c5fb7172fdca012f4ab78ca9f1268d30edb Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Tue, 27 May 2025 21:25:30 -0400 Subject: [PATCH] Flammable Performance Improvements (#2462) # Description ![image](https://github.com/user-attachments/assets/8d33ca00-9ad7-4c51-8cbd-5ea09a3067a8) I'm yeeting the server costs for the flammable system. This system will no longer querry every entity that might be on fire to check if they're on fire, and is instead querrying only entities that have a new OnFireComponent, which is used to tell them that they're on fire. 99% cost reductions are fun. I have verified in testing that this works. # Changelog :cl: - fix: Dramatically improved performance of the flammable system. --- .../Atmos/EntitySystems/FlammableSystem.cs | 17 +++++++++++++---- .../Atmos/Components/OnFireComponent.cs | 6 ++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Content.Shared/Atmos/Components/OnFireComponent.cs diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index 9fdfc70ac0..a5c47efb8a 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -292,10 +292,11 @@ namespace Content.Server.Atmos.EntitySystems public void Extinguish(EntityUid uid, FlammableComponent? flammable = null) { - if (!Resolve(uid, ref flammable)) + if (!Resolve(uid, ref flammable) || !flammable.CanExtinguish) return; - if (!flammable.OnFire || !flammable.CanExtinguish) + RemCompDeferred(uid); + if (!flammable.OnFire) return; _adminLogger.Add(LogType.Flammable, $"{ToPrettyString(uid):entity} stopped being on fire damage"); @@ -314,6 +315,7 @@ namespace Content.Server.Atmos.EntitySystems if (!Resolve(uid, ref flammable, false)) // Lavaland Change: SHUT THE FUCK UP FLAMMABLE return; + EnsureComp(uid); if (flammable.AlwaysCombustible) { flammable.FireStacks = Math.Max(flammable.FirestacksOnIgnite, flammable.FireStacks); @@ -407,9 +409,15 @@ namespace Content.Server.Atmos.EntitySystems _timer -= UpdateTime; // TODO: This needs cleanup to take off the crust from TemperatureComponent and shit. - var query = EntityQueryEnumerator(); - while (query.MoveNext(out var uid, out var flammable, out _)) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out _)) { + if (!TryComp(uid, out FlammableComponent? flammable)) + { + RemCompDeferred(uid); + continue; + } + // Slowly dry ourselves off if wet. if (flammable.FireStacks < 0) { @@ -420,6 +428,7 @@ namespace Content.Server.Atmos.EntitySystems { _alertsSystem.ClearAlert(uid, flammable.FireAlert); RaiseLocalEvent(uid, new MoodRemoveEffectEvent("OnFire")); + RemCompDeferred(uid); continue; } diff --git a/Content.Shared/Atmos/Components/OnFireComponent.cs b/Content.Shared/Atmos/Components/OnFireComponent.cs new file mode 100644 index 0000000000..141aa4acd5 --- /dev/null +++ b/Content.Shared/Atmos/Components/OnFireComponent.cs @@ -0,0 +1,6 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Atmos.Components; + +[RegisterComponent, NetworkedComponent] +public sealed partial class OnFireComponent : Component { }