2021-05-08 03:26:07 +02:00
|
|
|
using System.Linq;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Chemistry.Components;
|
2022-04-05 04:02:33 +12:00
|
|
|
using Content.Server.Chemistry.ReactionEffects;
|
|
|
|
|
using Content.Shared.Chemistry.Reaction;
|
2021-02-03 11:26:46 -03:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Chemistry.EntitySystems
|
2021-02-03 11:26:46 -03:00
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class SolutionAreaEffectSystem : EntitySystem
|
2021-02-03 11:26:46 -03:00
|
|
|
{
|
2022-04-05 04:02:33 +12:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<SolutionAreaEffectComponent, ReactionAttemptEvent>(OnReactionAttempt);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-03 11:26:46 -03:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
2021-09-28 13:35:29 +02:00
|
|
|
foreach (var inception in EntityManager.EntityQuery<SolutionAreaEffectInceptionComponent>().ToArray())
|
2021-02-03 11:26:46 -03:00
|
|
|
{
|
|
|
|
|
inception.InceptionUpdate(frameTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-05 04:02:33 +12:00
|
|
|
|
|
|
|
|
private void OnReactionAttempt(EntityUid uid, SolutionAreaEffectComponent component, ReactionAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Solution.Name != SolutionAreaEffectComponent.SolutionName)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Prevent smoke/foam fork bombs (smoke creating more smoke).
|
|
|
|
|
foreach (var effect in args.Reaction.Effects)
|
|
|
|
|
{
|
|
|
|
|
if (effect is AreaReactionEffect)
|
|
|
|
|
{
|
|
|
|
|
args.Cancel();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-03 11:26:46 -03:00
|
|
|
}
|
|
|
|
|
}
|