Files
OldThink/Content.Server/Chemistry/ReagentEntityReactions/ExtinguishReaction.cs
Vera Aguilera Puerto 6cea9cb973 Refactor Flammable to be ECS. (#4671)
- Refactor IHotItem into IsHotEvent.
- Refactor IFireAct into TileFireEvent.
2021-09-22 11:05:33 +02:00

30 lines
1.2 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 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, ReagentUnit 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);
}
}
}