From fe7dbb42b3a6a94bcf1a9c90396eb4e4ed5eb492 Mon Sep 17 00:00:00 2001 From: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:14:38 -0500 Subject: [PATCH] Allow Flares to light cigarettes (#29476) * Allow Flares to light cigarettes * !IsHot check * nicer looking(and I think the right way to do that...) * heh, whoops * Adds IgnitionEvent, IgnitionSource now functions as IsHot when Ignited * Fixes + remove redundancy * Hows this? * press enter Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> * Flare is not forever hot anymore * Formatting fixes * Make IgnitionEvent readonly --------- Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> --- Content.Server/IgnitionSource/IgnitionEvent.cs | 7 +++++++ Content.Server/IgnitionSource/IgnitionSourceSystem.cs | 9 ++++++++- .../Light/EntitySystems/ExpendableLightSystem.cs | 9 +++++---- Resources/Prototypes/Entities/Objects/Tools/flare.yml | 1 - 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 Content.Server/IgnitionSource/IgnitionEvent.cs diff --git a/Content.Server/IgnitionSource/IgnitionEvent.cs b/Content.Server/IgnitionSource/IgnitionEvent.cs new file mode 100644 index 0000000000..b86bf52b2d --- /dev/null +++ b/Content.Server/IgnitionSource/IgnitionEvent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.IgnitionSource; + +/// +/// Raised in order to toggle the ignitionSourceComponent on an entity on or off +/// +[ByRefEvent] +public readonly record struct IgnitionEvent(bool Ignite = false); diff --git a/Content.Server/IgnitionSource/IgnitionSourceSystem.cs b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs index c20e5207a4..3925cc86b5 100644 --- a/Content.Server/IgnitionSource/IgnitionSourceSystem.cs +++ b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs @@ -19,18 +19,25 @@ public sealed class IgnitionSourceSystem : EntitySystem SubscribeLocalEvent(OnIsHot); SubscribeLocalEvent(OnItemToggle); + SubscribeLocalEvent(OnIgnitionEvent); } private void OnIsHot(Entity ent, ref IsHotEvent args) { - SetIgnited((ent.Owner, ent.Comp), args.IsHot); + args.IsHot = ent.Comp.Ignited; } + private void OnItemToggle(Entity ent, ref ItemToggledEvent args) { if (TryComp(ent, out var comp)) SetIgnited((ent.Owner, comp), args.Activated); } + private void OnIgnitionEvent(Entity ent, ref IgnitionEvent args) + { + SetIgnited((ent.Owner, ent.Comp), args.Ignite); + } + /// /// Simply sets the ignited field to the ignited param. /// diff --git a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs index 571c23c5db..ba44b42ead 100644 --- a/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Server/Light/EntitySystems/ExpendableLightSystem.cs @@ -1,3 +1,4 @@ +using Content.Server.IgnitionSource; using Content.Server.Light.Components; using Content.Shared.Clothing.Components; using Content.Shared.Clothing.EntitySystems; @@ -99,8 +100,8 @@ namespace Content.Server.Light.EntitySystems _item.SetHeldPrefix(ent, "lit", component: item); } - var isHotEvent = new IsHotEvent() {IsHot = true}; - RaiseLocalEvent(ent, isHotEvent); + var ignite = new IgnitionEvent(true); + RaiseLocalEvent(ent, ref ignite); component.CurrentState = ExpendableLightState.Lit; component.StateExpiryTime = component.GlowDuration; @@ -134,8 +135,8 @@ namespace Content.Server.Light.EntitySystems case ExpendableLightState.Dead: _appearance.SetData(ent, ExpendableLightVisuals.Behavior, string.Empty, appearance); - var isHotEvent = new IsHotEvent() {IsHot = true}; - RaiseLocalEvent(ent, isHotEvent); + var ignite = new IgnitionEvent(false); + RaiseLocalEvent(ent, ref ignite); break; } } diff --git a/Resources/Prototypes/Entities/Objects/Tools/flare.yml b/Resources/Prototypes/Entities/Objects/Tools/flare.yml index fdf5314863..d36f67d00d 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/flare.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/flare.yml @@ -26,7 +26,6 @@ loop: true volume: -10 maxDistance: 5 - - type: Sprite sprite: Objects/Misc/flare.rsi layers: