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>
This commit is contained in:
Cojoke
2024-07-01 16:14:38 -05:00
committed by GitHub
parent ed2789a0e4
commit fe7dbb42b3
4 changed files with 20 additions and 6 deletions

View File

@@ -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);

View File

@@ -19,18 +19,25 @@ public sealed class IgnitionSourceSystem : EntitySystem
SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot); SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot);
SubscribeLocalEvent<ItemToggleHotComponent, ItemToggledEvent>(OnItemToggle); SubscribeLocalEvent<ItemToggleHotComponent, ItemToggledEvent>(OnItemToggle);
SubscribeLocalEvent<IgnitionSourceComponent, IgnitionEvent>(OnIgnitionEvent);
} }
private void OnIsHot(Entity<IgnitionSourceComponent> ent, ref IsHotEvent args) 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) private void OnItemToggle(Entity<ItemToggleHotComponent> ent, ref ItemToggledEvent args)
{ {
if (TryComp<IgnitionSourceComponent>(ent, out var comp)) if (TryComp<IgnitionSourceComponent>(ent, out var comp))
SetIgnited((ent.Owner, comp), args.Activated); SetIgnited((ent.Owner, comp), args.Activated);
} }
private void OnIgnitionEvent(Entity<IgnitionSourceComponent> ent, ref IgnitionEvent args)
{
SetIgnited((ent.Owner, ent.Comp), args.Ignite);
}
/// <summary> /// <summary>
/// Simply sets the ignited field to the ignited param. /// Simply sets the ignited field to the ignited param.
/// </summary> /// </summary>

View File

@@ -1,3 +1,4 @@
using Content.Server.IgnitionSource;
using Content.Server.Light.Components; using Content.Server.Light.Components;
using Content.Shared.Clothing.Components; using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems; using Content.Shared.Clothing.EntitySystems;
@@ -99,8 +100,8 @@ namespace Content.Server.Light.EntitySystems
_item.SetHeldPrefix(ent, "lit", component: item); _item.SetHeldPrefix(ent, "lit", component: item);
} }
var isHotEvent = new IsHotEvent() {IsHot = true}; var ignite = new IgnitionEvent(true);
RaiseLocalEvent(ent, isHotEvent); RaiseLocalEvent(ent, ref ignite);
component.CurrentState = ExpendableLightState.Lit; component.CurrentState = ExpendableLightState.Lit;
component.StateExpiryTime = component.GlowDuration; component.StateExpiryTime = component.GlowDuration;
@@ -134,8 +135,8 @@ namespace Content.Server.Light.EntitySystems
case ExpendableLightState.Dead: case ExpendableLightState.Dead:
_appearance.SetData(ent, ExpendableLightVisuals.Behavior, string.Empty, appearance); _appearance.SetData(ent, ExpendableLightVisuals.Behavior, string.Empty, appearance);
var isHotEvent = new IsHotEvent() {IsHot = true}; var ignite = new IgnitionEvent(false);
RaiseLocalEvent(ent, isHotEvent); RaiseLocalEvent(ent, ref ignite);
break; break;
} }
} }

View File

@@ -26,7 +26,6 @@
loop: true loop: true
volume: -10 volume: -10
maxDistance: 5 maxDistance: 5
- type: Sprite - type: Sprite
sprite: Objects/Misc/flare.rsi sprite: Objects/Misc/flare.rsi
layers: layers: