diff --git a/Content.Server/Atmos/Components/FlammableComponent.cs b/Content.Server/Atmos/Components/FlammableComponent.cs index 88ca5255b7..99aa2402f8 100644 --- a/Content.Server/Atmos/Components/FlammableComponent.cs +++ b/Content.Server/Atmos/Components/FlammableComponent.cs @@ -18,24 +18,22 @@ using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Physics; -using Robust.Shared.Physics.Collision; -using Robust.Shared.Physics.Dynamics; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.Components { [RegisterComponent] - public class FlammableComponent : SharedFlammableComponent, IStartCollide, IFireAct, IInteractUsing + public class FlammableComponent : SharedFlammableComponent, IFireAct, IInteractUsing { private bool _resisting = false; private readonly List _collided = new(); [ViewVariables(VVAccess.ReadWrite)] - public bool OnFire { get; private set; } + public bool OnFire { get; set; } [ViewVariables(VVAccess.ReadWrite)] - public float FireStacks { get; private set; } + public float FireStacks { get; set; } [ViewVariables(VVAccess.ReadWrite)] [DataField("fireSpread")] @@ -45,17 +43,6 @@ namespace Content.Server.Atmos.Components [DataField("canResistFire")] public bool CanResistFire { get; private set; } = false; - public void Ignite() - { - if (FireStacks > 0 && !OnFire) - { - OnFire = true; - - } - - UpdateAppearance(); - } - public void Extinguish() { if (!OnFire) return; @@ -145,37 +132,7 @@ namespace Content.Server.Atmos.Components } } - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - if (!otherFixture.Body.Owner.TryGetComponent(out FlammableComponent? otherFlammable)) - return; - - if (!FireSpread || !otherFlammable.FireSpread) - return; - - if (OnFire) - { - if (otherFlammable.OnFire) - { - var fireSplit = (FireStacks + otherFlammable.FireStacks) / 2; - FireStacks = fireSplit; - otherFlammable.FireStacks = fireSplit; - } - else - { - FireStacks /= 2; - otherFlammable.FireStacks += FireStacks; - otherFlammable.Ignite(); - } - } else if (otherFlammable.OnFire) - { - otherFlammable.FireStacks /= 2; - FireStacks += otherFlammable.FireStacks; - Ignite(); - } - } - - private void UpdateAppearance() + public void UpdateAppearance() { if (Owner.Deleted || !Owner.TryGetComponent(out AppearanceComponent? appearanceComponent)) return; appearanceComponent.SetData(FireVisuals.OnFire, OnFire); @@ -185,7 +142,7 @@ namespace Content.Server.Atmos.Components public void FireAct(float temperature, float volume) { AdjustFireStacks(3); - Ignite(); + EntitySystem.Get().Ignite(this); } // This needs some improvements... @@ -212,7 +169,7 @@ namespace Content.Server.Atmos.Components { if (hotItem.IsCurrentlyHot()) { - Ignite(); + EntitySystem.Get().Ignite(this); return true; } } diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs new file mode 100644 index 0000000000..3a253f64e9 --- /dev/null +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -0,0 +1,56 @@ +using Content.Server.Atmos.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.Physics.Dynamics; + +namespace Content.Server.Atmos.EntitySystems +{ + internal sealed class FlammableSystem : EntitySystem + { + // TODO: Port the rest of Flammable. + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(HandleCollide); + } + + private void HandleCollide(EntityUid uid, FlammableComponent component, StartCollideEvent args) + { + if (!args.OtherFixture.Body.Owner.TryGetComponent(out FlammableComponent? otherFlammable)) + return; + + if (!component.FireSpread || !otherFlammable.FireSpread) + return; + + if (component.OnFire) + { + if (otherFlammable.OnFire) + { + var fireSplit = (component.FireStacks + otherFlammable.FireStacks) / 2; + component.FireStacks = fireSplit; + otherFlammable.FireStacks = fireSplit; + } + else + { + component.FireStacks /= 2; + otherFlammable.FireStacks += component.FireStacks; + Ignite(otherFlammable); + } + } else if (otherFlammable.OnFire) + { + otherFlammable.FireStacks /= 2; + component.FireStacks += otherFlammable.FireStacks; + Ignite(component); + } + } + + internal void Ignite(FlammableComponent component) + { + if (component.FireStacks > 0 && !component.OnFire) + { + component.OnFire = true; + } + + component.UpdateAppearance(); + } + } +}