Allow solutions to store extra reagent data (#19323)

This commit is contained in:
Leon Friedrich
2023-09-05 09:55:10 +12:00
committed by GitHub
parent a6b81058d0
commit e4ca6f4fb9
52 changed files with 932 additions and 538 deletions

View File

@@ -56,6 +56,17 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
[Dependency] private readonly SlowContactsSystem _slowContacts = default!;
[Dependency] private readonly TileFrictionController _tile = default!;
[ValidatePrototypeId<ReagentPrototype>]
private const string Blood = "Blood";
[ValidatePrototypeId<ReagentPrototype>]
private const string Slime = "Slime";
[ValidatePrototypeId<ReagentPrototype>]
private const string SpiderBlood = "SpiderBlood";
private static string[] _standoutReagents = new[] { Blood, Slime, SpiderBlood };
public static float PuddleVolume = 1000;
// Using local deletion queue instead of the standard queue so that we can easily "undelete" if a puddle
@@ -272,14 +283,14 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
// Make blood stand out more
// Kinda EH
// Could potentially do alpha per-solution but future problem.
var standoutReagents = new string[] { "Blood", "Slime", "SpiderBlood" };
color = solution.GetColorWithout(_prototypeManager, standoutReagents);
color = solution.GetColorWithout(_prototypeManager, _standoutReagents);
color = color.WithAlpha(0.7f);
foreach (var standout in standoutReagents)
foreach (var standout in _standoutReagents)
{
if (!solution.TryGetReagent(standout, out var quantity))
var quantity = solution.GetTotalPrototypeQuantity(standout);
if (quantity <= FixedPoint2.Zero)
continue;
var interpolateValue = quantity.Float() / solution.Volume.Float();
@@ -298,13 +309,13 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
var amountRequired = FixedPoint2.New(component.OverflowVolume.Float() * LowThreshold);
var slipperyAmount = FixedPoint2.Zero;
foreach (var reagent in solution.Contents)
foreach (var (reagent, quantity) in solution.Contents)
{
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.ReagentId);
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
if (reagentProto.Slippery)
{
slipperyAmount += reagent.Quantity;
slipperyAmount += quantity;
if (slipperyAmount > amountRequired)
{
@@ -331,9 +342,9 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
private void UpdateSlow(EntityUid uid, Solution solution)
{
var maxViscosity = 0f;
foreach (var reagent in solution.Contents)
foreach (var (reagent, _) in solution.Contents)
{
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.ReagentId);
var reagentProto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
maxViscosity = Math.Max(maxViscosity, reagentProto.Viscosity);
}
if (maxViscosity > 0)
@@ -362,7 +373,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
{
args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating"));
}
else if (solution?.ContainsReagent(EvaporationReagent) == true)
else if (solution?.ContainsPrototype(EvaporationReagent) == true)
{
args.PushMarkup(Loc.GetString("puddle-component-examine-evaporating-partial"));
}
@@ -588,15 +599,15 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
if (tileReact)
{
// First, do all tile reactions
for (var i = 0; i < solution.Contents.Count; i++)
for (var i = solution.Contents.Count - 1; i >= 0; i--)
{
var (reagentId, quantity) = solution.Contents[i];
var proto = _prototypeManager.Index<ReagentPrototype>(reagentId);
var (reagent, quantity) = solution.Contents[i];
var proto = _prototypeManager.Index<ReagentPrototype>(reagent.Prototype);
var removed = proto.ReactionTile(tileRef, quantity);
if (removed <= FixedPoint2.Zero)
continue;
solution.RemoveReagent(reagentId, removed);
solution.RemoveReagent(reagent, removed);
}
}