Files
OldThink/Content.Server/Chemistry/ReagentEntityReactions/ExtinguishReaction.cs
Vera Aguilera Puerto a6f04e22e4 Entity Reagent Reactions v2 (#3714)
* Refactors reactions to be more POWERFUL and DATA-ORIENTED
2021-03-26 12:02:41 +01:00

28 lines
1.0 KiB
C#

using System.Collections.Generic;
using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Chemistry.ReagentEntityReactions
{
[UsedImplicitly]
[DataDefinition]
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;
flammable.Extinguish();
flammable.AdjustFireStacks(-1.5f);
}
}
}