]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow Flares to light cigarettes (#29476)
authorCojoke <83733158+Cojoke-dot@users.noreply.github.com>
Mon, 1 Jul 2024 21:14:38 +0000 (16:14 -0500)
committerGitHub <noreply@github.com>
Mon, 1 Jul 2024 21:14:38 +0000 (14:14 -0700)
* 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 [new file with mode: 0644]
Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Content.Server/Light/EntitySystems/ExpendableLightSystem.cs
Resources/Prototypes/Entities/Objects/Tools/flare.yml

diff --git a/Content.Server/IgnitionSource/IgnitionEvent.cs b/Content.Server/IgnitionSource/IgnitionEvent.cs
new file mode 100644 (file)
index 0000000..b86bf52
--- /dev/null
@@ -0,0 +1,7 @@
+namespace Content.Server.IgnitionSource;
+
+/// <summary>
+///     Raised in order to toggle the ignitionSourceComponent on an entity on or off
+/// </summary>
+[ByRefEvent]
+public readonly record struct IgnitionEvent(bool Ignite = false);
index c20e5207a4126639b68aafeee9784b763d676b90..3925cc86b5aa7f139102c05ffdd4bd39d02ce103 100644 (file)
@@ -19,18 +19,25 @@ public sealed class IgnitionSourceSystem : EntitySystem
 
         SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot);
         SubscribeLocalEvent<ItemToggleHotComponent, ItemToggledEvent>(OnItemToggle);
+        SubscribeLocalEvent<IgnitionSourceComponent, IgnitionEvent>(OnIgnitionEvent);
     }
 
     private void OnIsHot(Entity<IgnitionSourceComponent> ent, ref IsHotEvent args)
     {
-        SetIgnited((ent.Owner, ent.Comp), args.IsHot);
+        args.IsHot = ent.Comp.Ignited;
     }
+
     private void OnItemToggle(Entity<ItemToggleHotComponent> ent, ref ItemToggledEvent args)
     {
         if (TryComp<IgnitionSourceComponent>(ent, out var comp))
             SetIgnited((ent.Owner, comp), args.Activated);
     }
 
+    private void OnIgnitionEvent(Entity<IgnitionSourceComponent> ent, ref IgnitionEvent args)
+    {
+        SetIgnited((ent.Owner, ent.Comp), args.Ignite);
+    }
+
     /// <summary>
     /// Simply sets the ignited field to the ignited param.
     /// </summary>
index 571c23c5dbd613525d52c9e573eeac454662e00d..ba44b42ead1658113ef68b94fe3751eb412b86cc 100644 (file)
@@ -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;
             }
         }
index fdf531486316a3b9cf0d47bff285c6a21d736b59..d36f67d00d4f42e63da3071401ba5d91b30cf05c 100644 (file)
@@ -26,7 +26,6 @@
         loop: true
         volume: -10
         maxDistance: 5
-
   - type: Sprite
     sprite: Objects/Misc/flare.rsi
     layers: