Fire stacks trigger (#39530)

* Simple as

* whoops

* not gonna work

* chopped

* missed something

* Better name

* formatting

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
āda
2025-08-10 14:59:32 -05:00
committed by GitHub
parent 2aca7f62dc
commit 7825d30562
4 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Trigger;
using Content.Shared.Trigger.Components.Effects;
namespace Content.Server.Trigger.Systems;
/// <summary>
/// Trigger system for setting something on fire.
/// </summary>
/// <seealso cref="IgniteOnTriggerSystem"/>
public sealed class FlameStackOnTriggerSystem : EntitySystem
{
[Dependency] private readonly FlammableSystem _flame = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FlameStackOnTriggerComponent, TriggerEvent>(OnTrigger);
}
private void OnTrigger(Entity<FlameStackOnTriggerComponent> ent, ref TriggerEvent args)
{
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
return;
var target = ent.Comp.TargetUser ? args.User : ent.Owner;
if (target == null)
return;
_flame.AdjustFireStacks(target.Value, ent.Comp.FireStacks, ignite: ent.Comp.DoIgnite);
args.Handled = true;
}
}

View File

@@ -8,6 +8,7 @@ namespace Content.Server.Trigger.Systems;
/// <summary>
/// Handles igniting when triggered and stopping ignition after the delay.
/// </summary>
/// <seealso cref="FlameStackOnTriggerSystem"/>
public sealed class IgniteOnTriggerSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;

View File

@@ -0,0 +1,26 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Trigger.Components.Effects;
/// <summary>
/// Adjusts fire stacks on trigger, optionally setting them on fire as well.
/// Requires <see cref="FlammableComponent"/> to ignite the target.
/// If TargetUser is true they will have their firestacks adjusted instead.
/// </summary>
/// <seealso cref="IgniteOnTriggerComponent"/>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class FlameStackOnTriggerComponent : BaseXOnTriggerComponent
{
/// <summary>
/// How many fire stacks to add or remove.
/// </summary>
[DataField, AutoNetworkedField]
public float FireStacks;
/// <summary>
/// If true, the target will be set on fire if it isn't already.
/// If false does nothing.
/// </summary>
[DataField, AutoNetworkedField]
public bool DoIgnite = true;
}

View File

@@ -8,6 +8,7 @@ namespace Content.Shared.Trigger.Components.Effects;
/// Requires <see cref="IgnitionSourceComponent"/> along with triggering components.
/// The if TargetUser is true they will be ignited instead (they need IgnitionSourceComponent as well).
/// </summary>
/// <seealso cref="FlameStackOnTriggerComponent"/>
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState, AutoGenerateComponentPause]
public sealed partial class IgniteOnTriggerComponent : BaseXOnTriggerComponent