Files
tbd-station-14/Content.Server/Chemistry/ReagentEntityReactions/ExtinguishReaction.cs
2021-11-03 16:48:03 -07:00

31 lines
1.3 KiB
C#

using System.Collections.Generic;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Server.Chemistry.ReagentEntityReactions
{
[UsedImplicitly]
public class ExtinguishReaction : ReagentEntityReaction
{
[DataField("reagents", true, customTypeSerializer:typeof(PrototypeIdHashSetSerializer<ReagentPrototype>))]
// ReSharper disable once CollectionNeverUpdated.Local
private readonly HashSet<string> _reagents = new ();
protected override void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Solution? source)
{
if (!entity.TryGetComponent(out FlammableComponent? flammable) || !_reagents.Contains(reagent.ID)) return;
var flammableSystem = EntitySystem.Get<FlammableSystem>();
flammableSystem.Extinguish(entity.Uid, flammable);
flammableSystem.AdjustFireStacks(entity.Uid, -1.5f, flammable);
}
}
}