Fix smoke fork bomb (#7401)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.ReactionEffects;
|
||||
using Content.Shared.Chemistry.Reaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -8,6 +10,13 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public sealed class SolutionAreaEffectSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SolutionAreaEffectComponent, ReactionAttemptEvent>(OnReactionAttempt);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var inception in EntityManager.EntityQuery<SolutionAreaEffectInceptionComponent>().ToArray())
|
||||
@@ -15,5 +24,21 @@ namespace Content.Server.Chemistry.EntitySystems
|
||||
inception.InceptionUpdate(frameTime);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,10 @@ public sealed partial class SolutionContainerSystem
|
||||
public static string ToPrettyString(Solution solution)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("[");
|
||||
if (solution.Name == null)
|
||||
sb.Append("[");
|
||||
else
|
||||
sb.Append($"{solution.Name}:[");
|
||||
var first = true;
|
||||
foreach (var (id, quantity) in solution.Contents)
|
||||
{
|
||||
|
||||
@@ -41,9 +41,9 @@ public sealed partial class SolutionContainerSystem : EntitySystem
|
||||
|
||||
private void InitSolution(EntityUid uid, SolutionContainerManagerComponent component, ComponentInit args)
|
||||
{
|
||||
foreach (var keyValue in component.Solutions)
|
||||
foreach (var (name, solutionHolder) in component.Solutions)
|
||||
{
|
||||
var solutionHolder = keyValue.Value;
|
||||
solutionHolder.Name = name;
|
||||
if (solutionHolder.MaxVolume == FixedPoint2.Zero)
|
||||
{
|
||||
solutionHolder.MaxVolume = solutionHolder.TotalVolume > solutionHolder.InitialMaxVolume
|
||||
@@ -283,7 +283,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
|
||||
|
||||
if (!solutionsMgr.Solutions.ContainsKey(name))
|
||||
{
|
||||
var newSolution = new Solution();
|
||||
var newSolution = new Solution() { Name = name };
|
||||
solutionsMgr.Solutions.Add(name, newSolution);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user