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:
37
Content.Server/Trigger/Systems/FlameStackOnTriggerSystem.cs
Normal file
37
Content.Server/Trigger/Systems/FlameStackOnTriggerSystem.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace Content.Server.Trigger.Systems;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles igniting when triggered and stopping ignition after the delay.
|
/// Handles igniting when triggered and stopping ignition after the delay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <seealso cref="FlameStackOnTriggerSystem"/>
|
||||||
public sealed class IgniteOnTriggerSystem : EntitySystem
|
public sealed class IgniteOnTriggerSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace Content.Shared.Trigger.Components.Effects;
|
|||||||
/// Requires <see cref="IgnitionSourceComponent"/> along with triggering components.
|
/// Requires <see cref="IgnitionSourceComponent"/> along with triggering components.
|
||||||
/// The if TargetUser is true they will be ignited instead (they need IgnitionSourceComponent as well).
|
/// The if TargetUser is true they will be ignited instead (they need IgnitionSourceComponent as well).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <seealso cref="FlameStackOnTriggerComponent"/>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
[AutoGenerateComponentState, AutoGenerateComponentPause]
|
[AutoGenerateComponentState, AutoGenerateComponentPause]
|
||||||
public sealed partial class IgniteOnTriggerComponent : BaseXOnTriggerComponent
|
public sealed partial class IgniteOnTriggerComponent : BaseXOnTriggerComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user