From b24cff72c9502fb3840e05cbb5a92b9b8be9a615 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:27:22 +0000 Subject: [PATCH] - fix: Revert flammable changes. (#408) --- .../Systems/AdminVerbSystem.Smites.cs | 2 +- .../Atmos/Components/FlammableComponent.cs | 34 ++---- .../Atmos/EntitySystems/FlammableSystem.cs | 102 ++++++++++-------- 3 files changed, 65 insertions(+), 73 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index 042bac3956..942882f7ae 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -152,7 +152,7 @@ public sealed partial class AdminVerbSystem Act = () => { // Fuck you. Burn Forever. - flammable.FireStacks = flammable.MaximumFireStacks; + flammable.FireStacks = FlammableSystem.MaximumFireStacks; _flammableSystem.Ignite(args.Target, args.User); var xform = Transform(args.Target); _popupSystem.PopupEntity(Loc.GetString("admin-smite-set-alight-self"), args.Target, diff --git a/Content.Server/Atmos/Components/FlammableComponent.cs b/Content.Server/Atmos/Components/FlammableComponent.cs index e00f5efbdc..679b551058 100644 --- a/Content.Server/Atmos/Components/FlammableComponent.cs +++ b/Content.Server/Atmos/Components/FlammableComponent.cs @@ -11,65 +11,49 @@ namespace Content.Server.Atmos.Components [ViewVariables(VVAccess.ReadWrite)] [DataField] - public bool OnFire; + public bool OnFire { get; set; } [ViewVariables(VVAccess.ReadWrite)] [DataField] - public float FireStacks; + public float FireStacks { get; set; } [ViewVariables(VVAccess.ReadWrite)] - [DataField] - public float MaximumFireStacks = 10f; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField] - public float MinimumFireStacks = -10f; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField] - public string FlammableFixtureID = "flammable"; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField] - public float MinIgnitionTemperature = 373.15f; - - [ViewVariables(VVAccess.ReadWrite)] - [DataField] + [DataField("fireSpread")] public bool FireSpread { get; private set; } = false; [ViewVariables(VVAccess.ReadWrite)] - [DataField] + [DataField("canResistFire")] public bool CanResistFire { get; private set; } = false; - [DataField(required: true)] + [DataField("damage", required: true)] [ViewVariables(VVAccess.ReadWrite)] public DamageSpecifier Damage = new(); // Empty by default, we don't want any funny NREs. /// /// Used for the fixture created to handle passing firestacks when two flammable objects collide. /// - [DataField] + [DataField("flammableCollisionShape")] public IPhysShape FlammableCollisionShape = new PhysShapeCircle(0.35f); /// /// Should the component be set on fire by interactions with isHot entities /// [ViewVariables(VVAccess.ReadWrite)] - [DataField] + [DataField("alwaysCombustible")] public bool AlwaysCombustible = false; /// /// Can the component anyhow lose its FireStacks? /// [ViewVariables(VVAccess.ReadWrite)] - [DataField] + [DataField("canExtinguish")] public bool CanExtinguish = true; /// /// How many firestacks should be applied to component when being set on fire? /// [ViewVariables(VVAccess.ReadWrite)] - [DataField] + [DataField("firestacksOnIgnite")] public float FirestacksOnIgnite = 2.0f; /// diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index bc6e56e765..84f7616675 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -52,11 +52,13 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SpellBladeSystem _spellBlade = default!; // WD - private EntityQuery _physicsQuery; - - // This should probably be moved to the component, requires a rewrite, all fires tick at the same time + public const float MinimumFireStacks = -10f; + public const float MaximumFireStacks = 20f; private const float UpdateTime = 1f; + public const float MinIgnitionTemperature = 373.15f; + public const string FlammableFixtureID = "flammable"; + private float _timer; private readonly Dictionary, float> _fireEvents = new(); @@ -65,8 +67,6 @@ namespace Content.Server.Atmos.EntitySystems { UpdatesAfter.Add(typeof(AtmosphereSystem)); - _physicsQuery = GetEntityQuery(); - SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnInteractUsing); SubscribeLocalEvent(OnCollide); @@ -141,7 +141,7 @@ namespace Content.Server.Atmos.EntitySystems if (!TryComp(uid, out var body)) return; - _fixture.TryCreateFixture(uid, component.FlammableCollisionShape, component.FlammableFixtureID, hard: false, + _fixture.TryCreateFixture(uid, component.FlammableCollisionShape, FlammableFixtureID, hard: false, collisionMask: (int) CollisionGroup.FullTileLayer, body: body); } @@ -199,7 +199,7 @@ namespace Content.Server.Atmos.EntitySystems // Normal hard collisions, though this isn't generally possible since most flammable things are mobs // which don't collide with one another, shouldn't work here. - if (args.OtherFixtureId != flammable.FlammableFixtureID && args.OurFixtureId != flammable.FlammableFixtureID) + if (args.OtherFixtureId != FlammableFixtureID && args.OurFixtureId != FlammableFixtureID) return; if (!flammable.FireSpread) @@ -211,30 +211,49 @@ namespace Content.Server.Atmos.EntitySystems if (!flammable.OnFire && !otherFlammable.OnFire) return; // Neither are on fire - // Both are on fire -> equalize fire stacks. - // Weight each thing's firestacks by its mass - var mass1 = 1f; - var mass2 = 1f; - if (_physicsQuery.TryComp(uid, out var physics) && _physicsQuery.TryComp(otherUid, out var otherPhys)) + // WD START + var weHold = _spellBlade.IsHoldingItemWithComponent(uid); + var theyHold = _spellBlade.IsHoldingItemWithComponent(otherUid); + // WD END + + if (flammable.OnFire && otherFlammable.OnFire) { - mass1 = physics.Mass; - mass2 = otherPhys.Mass; + if (weHold && !theyHold || theyHold && !weHold) // WD + return; + // Both are on fire -> equalize fire stacks. + var avg = (flammable.FireStacks + otherFlammable.FireStacks) / 2; + flammable.FireStacks = flammable.CanExtinguish ? avg : Math.Max(flammable.FireStacks, avg); + otherFlammable.FireStacks = otherFlammable.CanExtinguish ? avg : Math.Max(otherFlammable.FireStacks, avg); + UpdateAppearance(uid, flammable); + UpdateAppearance(otherUid, otherFlammable); + return; } - // when the thing on fire is more massive than the other, the following happens: - // - the thing on fire loses a small number of firestacks - // - the other thing gains a large number of firestacks - // so a person on fire engulfs a mouse, but an engulfed mouse barely does anything to a person - var total = mass1 + mass2; - var avg = (flammable.FireStacks + otherFlammable.FireStacks) / total; - - // swap the entity losing stacks depending on whichever has the most firestack kilos - var (src, dest) = flammable.FireStacks * mass1 > otherFlammable.FireStacks * mass2 - ? (-1f, 1f) - : (1f, -1f); - // bring each entity to the same firestack mass, firestacks being scaled by the other's mass - AdjustFireStacks(uid, src * avg * mass2, flammable, ignite: true); - AdjustFireStacks(otherUid, dest * avg * mass1, otherFlammable, ignite: true); + // Only one is on fire -> attempt to spread the fire. + if (flammable.OnFire) + { + if (theyHold) // WD + return; + otherFlammable.FireStacks += flammable.FireStacks / 2; + Ignite(otherUid, uid, otherFlammable); + if (flammable.CanExtinguish) + { + flammable.FireStacks /= 2; + UpdateAppearance(uid, flammable); + } + } + else + { + if (weHold) // WD + return; + flammable.FireStacks += otherFlammable.FireStacks / 2; + Ignite(uid, otherUid, flammable); + if (otherFlammable.CanExtinguish) + { + otherFlammable.FireStacks /= 2; + UpdateAppearance(otherUid, otherFlammable); + } + } } private void OnIsHot(EntityUid uid, FlammableComponent flammable, IsHotEvent args) @@ -244,7 +263,7 @@ namespace Content.Server.Atmos.EntitySystems private void OnTileFire(Entity ent, ref TileFireEvent args) { - var tempDelta = args.Temperature - ent.Comp.MinIgnitionTemperature; + var tempDelta = args.Temperature - MinIgnitionTemperature; _fireEvents.TryGetValue(ent, out var maxTemp); @@ -272,30 +291,17 @@ namespace Content.Server.Atmos.EntitySystems _appearance.SetData(uid, ToggleableLightVisuals.Enabled, flammable.OnFire, appearance); } - public void AdjustFireStacks(EntityUid uid, float relativeFireStacks, FlammableComponent? flammable = null, bool ignite = false) + public void AdjustFireStacks(EntityUid uid, float relativeFireStacks, FlammableComponent? flammable = null) { if (!Resolve(uid, ref flammable)) return; - SetFireStacks(uid, flammable.FireStacks + relativeFireStacks, flammable, ignite); - } + flammable.FireStacks = MathF.Min(MathF.Max(MinimumFireStacks, flammable.FireStacks + relativeFireStacks), MaximumFireStacks); - public void SetFireStacks(EntityUid uid, float stacks, FlammableComponent? flammable = null, bool ignite = false) - { - if (!Resolve(uid, ref flammable)) - return; - - flammable.FireStacks = MathF.Min(MathF.Max(flammable.MinimumFireStacks, stacks), flammable.MaximumFireStacks); - - if (flammable.FireStacks <= 0) - { + if (flammable.OnFire && flammable.FireStacks <= 0) Extinguish(uid, flammable); - } else - { - flammable.OnFire = ignite; UpdateAppearance(uid, flammable); - } } public void Extinguish(EntityUid uid, FlammableComponent? flammable = null) @@ -444,11 +450,13 @@ namespace Content.Server.Atmos.EntitySystems EnsureComp(uid); _ignitionSourceSystem.SetIgnited(uid); + var damageScale = MathF.Min( flammable.FireStacks, 5); + if (TryComp(uid, out TemperatureComponent? temp)) - _temperatureSystem.ChangeHeat(uid, 12500 * flammable.FireStacks, false, temp); + _temperatureSystem.ChangeHeat(uid, 12500 * damageScale, false, temp); if (!_spellBlade.IsHoldingItemWithComponent(uid)) // WD EDIT - _damageableSystem.TryChangeDamage(uid, flammable.Damage * flammable.FireStacks, interruptsDoAfters: false); + _damageableSystem.TryChangeDamage(uid, flammable.Damage * damageScale, interruptsDoAfters: false); AdjustFireStacks(uid, flammable.FirestackFade * (flammable.Resisting ? 10f : 1f), flammable); }