Files
tbd-station-14/Content.Server/Anomaly/Effects/PyroclasticAnomalySystem.cs
Ed a4ec01d471 Anomalies behaviours (#24683)
* Added new anomaly particle

* Add basic anomaly behaviour

* +2 parametres

* add functional to new particle

* add components to behaviours

* big content

* add shuffle, moved thing to server

* clean up

* fixes

* random pick redo

* bonjour behavioUr

* fix AJCM

* fix

* add some new behaviours

* power modifier behaviour

* rmeove timer

* new event for update ui fix

* refactor!

* fixes

* enum

* Fix mapinit

* Minor touches

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2024-04-01 19:29:13 +11:00

51 lines
2.0 KiB
C#

using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects.Components;
using Robust.Shared.Map;
namespace Content.Server.Anomaly.Effects;
/// <summary>
/// This handles <see cref="PyroclasticAnomalyComponent"/> and the events from <seealso cref="AnomalySystem"/>
/// </summary>
public sealed class PyroclasticAnomalySystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FlammableSystem _flammable = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<PyroclasticAnomalyComponent, AnomalyPulseEvent>(OnPulse);
SubscribeLocalEvent<PyroclasticAnomalyComponent, AnomalySupercriticalEvent>(OnSupercritical);
}
private void OnPulse(EntityUid uid, PyroclasticAnomalyComponent component, ref AnomalyPulseEvent args)
{
var xform = Transform(uid);
var ignitionRadius = component.MaximumIgnitionRadius * args.Stability * args.PowerModifier;
IgniteNearby(uid, xform.Coordinates, args.Severity, ignitionRadius);
}
private void OnSupercritical(EntityUid uid, PyroclasticAnomalyComponent component, ref AnomalySupercriticalEvent args)
{
var xform = Transform(uid);
IgniteNearby(uid, xform.Coordinates, 1, component.MaximumIgnitionRadius * 2 * args.PowerModifier);
}
public void IgniteNearby(EntityUid uid, EntityCoordinates coordinates, float severity, float radius)
{
var flammables = new HashSet<Entity<FlammableComponent>>();
_lookup.GetEntitiesInRange(coordinates, radius, flammables);
foreach (var flammable in flammables)
{
var ent = flammable.Owner;
var stackAmount = 1 + (int) (severity / 0.15f);
_flammable.AdjustFireStacks(ent, stackAmount, flammable);
_flammable.Ignite(ent, uid, flammable);
}
}
}