Firestarter fixes (#24647)

* Firestarter fixes

- Actually networks the action.
- Namespace fixes.

* No networky for you
This commit is contained in:
metalgearsloth
2024-02-01 00:01:52 +11:00
committed by GitHub
parent 1f389d7a39
commit a6ea8b210d
4 changed files with 33 additions and 22 deletions

View File

@@ -0,0 +1,8 @@
using Content.Shared.Atmos.EntitySystems;
namespace Content.Client.Atmos.EntitySystems;
public sealed class FirestarterSystem : SharedFirestarterSystem
{
}

View File

@@ -1,24 +1,26 @@
using Content.Server.Atmos.Components;
using Content.Shared.Actions.Events; using Content.Shared.Actions.Events;
using Content.Shared.Atmos.Components;
using Content.Shared.Atmos.EntitySystems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map; using Robust.Shared.Map;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems; namespace Content.Server.Atmos.EntitySystems;
using Robust.Shared.Audio.Systems;
using Content.Shared.Abilities.Firestarter;
/// <summary> /// <summary>
/// Adds an action ability that will cause all flammable targets in a radius to ignite, also heals the owner /// Adds an action ability that will cause all flammable targets in a radius to ignite, also heals the owner
/// of the component when used. /// of the component when used.
/// </summary> /// </summary>
namespace Content.Server.Abilities.Firestarter; public sealed class FirestarterSystem : SharedFirestarterSystem
public sealed class FirestarterSystem : EntitySystem
{ {
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FlammableSystem _flammable = default!; [Dependency] private readonly FlammableSystem _flammable = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly SharedContainerSystem _container = default!;
private readonly HashSet<Entity<FlammableComponent>> _flammables = new();
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -26,11 +28,10 @@ public sealed class FirestarterSystem : EntitySystem
} }
/// <summary> /// <summary>
/// Checks Radius for igniting nearby flammable objects . /// Checks Radius for igniting nearby flammable objects
/// </summary> /// </summary>
private void OnStartFire(EntityUid uid, FirestarterComponent component, FireStarterActionEvent args) private void OnStartFire(EntityUid uid, FirestarterComponent component, FireStarterActionEvent args)
{ {
if (_container.IsEntityOrParentInContainer(uid)) if (_container.IsEntityOrParentInContainer(uid))
return; return;
@@ -47,10 +48,10 @@ public sealed class FirestarterSystem : EntitySystem
/// </summary> /// </summary>
public void IgniteNearby(EntityUid uid, EntityCoordinates coordinates, float severity, float radius) public void IgniteNearby(EntityUid uid, EntityCoordinates coordinates, float severity, float radius)
{ {
var flammables = new HashSet<Entity<FlammableComponent>>(); _flammables.Clear();
_lookup.GetEntitiesInRange(coordinates, radius, flammables); _lookup.GetEntitiesInRange(coordinates, radius, _flammables);
foreach (var flammable in flammables) foreach (var flammable in _flammables)
{ {
var ent = flammable.Owner; var ent = flammable.Owner;
var stackAmount = 2 + (int) (severity / 0.15f); var stackAmount = 2 + (int) (severity / 0.15f);

View File

@@ -1,9 +1,9 @@
using Robust.Shared.Prototypes; using Content.Shared.Atmos.EntitySystems;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Abilities.Firestarter; namespace Content.Shared.Atmos.Components;
/// <summary> /// <summary>
/// Lets its owner entity ignite flammables around it and also heal some damage. /// Lets its owner entity ignite flammables around it and also heal some damage.
@@ -14,21 +14,21 @@ public sealed partial class FirestarterComponent : Component
/// <summary> /// <summary>
/// Radius of objects that will be ignited if flammable. /// Radius of objects that will be ignited if flammable.
/// </summary> /// </summary>
[DataField("ignitionRadius")] [DataField]
public float IgnitionRadius = 4f; public float IgnitionRadius = 4f;
/// <summary> /// <summary>
/// The action entity. /// The action entity.
/// </summary> /// </summary>
[DataField("fireStarterAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] [DataField]
public string? FireStarterAction = "ActionFireStarter"; public EntProtoId? FireStarterAction = "ActionFireStarter";
[DataField("fireStarterActionEntity")] public EntityUid? FireStarterActionEntity; [DataField] public EntityUid? FireStarterActionEntity;
/// <summary> /// <summary>
/// Radius of objects that will be ignited if flammable. /// Radius of objects that will be ignited if flammable.
/// </summary> /// </summary>
[DataField("igniteSound")] [DataField]
public SoundSpecifier IgniteSound = new SoundPathSpecifier("/Audio/Magic/rumble.ogg"); public SoundSpecifier IgniteSound = new SoundPathSpecifier("/Audio/Magic/rumble.ogg");
} }

View File

@@ -1,8 +1,9 @@
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Atmos.Components;
namespace Content.Shared.Abilities.Firestarter; namespace Content.Shared.Atmos.EntitySystems;
public sealed class SharedFirestarterSystem : EntitySystem public abstract class SharedFirestarterSystem : EntitySystem
{ {
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
@@ -18,5 +19,6 @@ public sealed class SharedFirestarterSystem : EntitySystem
private void OnComponentInit(EntityUid uid, FirestarterComponent component, ComponentInit args) private void OnComponentInit(EntityUid uid, FirestarterComponent component, ComponentInit args)
{ {
_actionsSystem.AddAction(uid, ref component.FireStarterActionEntity, component.FireStarterAction, uid); _actionsSystem.AddAction(uid, ref component.FireStarterActionEntity, component.FireStarterAction, uid);
Dirty(uid, component);
} }
} }