Minor spill refactors (#5569)

This commit is contained in:
Ygg01
2021-12-05 04:18:30 +01:00
committed by GitHub
parent 5d63411113
commit d1ab9592aa
12 changed files with 248 additions and 253 deletions

View File

@@ -1,5 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Text;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Database;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
@@ -128,5 +130,27 @@ namespace Content.Server.Chemistry.EntitySystems
return true;
}
public static string ToPrettyString(Solution solution)
{
var sb = new StringBuilder();
sb.Append("Solution content: [");
var first = true;
foreach (var (id, quantity) in solution.Contents)
{
if (first)
{
first = false;
}
else
{
sb.Append(", ");
}
sb.AppendFormat("{0}: {1}u", id, quantity);
}
sb.Append(']');
return sb.ToString();
}
}
}

View File

@@ -1,9 +1,11 @@
using Content.Server.Fluids.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -15,9 +17,12 @@ namespace Content.Server.Chemistry.TileReactions
{
public FixedPoint2 TileReact(TileRef tile, ReagentPrototype reagent, FixedPoint2 reactVolume)
{
if (reactVolume < 5 || !tile.TryGetPuddle(null, out _)) return FixedPoint2.Zero;
var spillSystem = EntitySystem.Get<SpillableSystem>();
if (reactVolume < 5 || !spillSystem.TryGetPuddle(tile, out _)) return FixedPoint2.Zero;
return tile.SpillAt(new Solution(reagent.ID, reactVolume), "PuddleSmear", true, false, true) != null ? reactVolume : FixedPoint2.Zero;
return spillSystem.SpillAt(tile,new Solution(reagent.ID, reactVolume), "PuddleSmear", true, false, true) != null
? reactVolume
: FixedPoint2.Zero;
}
}
}

View File

@@ -1,10 +1,12 @@
using Content.Server.Fluids.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.FixedPoint;
using Content.Shared.Slippery;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -24,7 +26,8 @@ namespace Content.Server.Chemistry.TileReactions
if (reactVolume < 5) return FixedPoint2.Zero;
// TODO Make this not puddle smear.
var puddle = tile.SpillAt(new Solution(reagent.ID, reactVolume), "PuddleSmear", _overflow, false, true);
var puddle = EntitySystem.Get<SpillableSystem>()
.SpillAt(tile, new Solution(reagent.ID, reactVolume), "PuddleSmear", _overflow, false, true);
if (puddle != null)
{