Clean up solution regen and drain comps (#29777)

* clean up solution regen and drain comps

* Tape applied.

* Update Content.Server/Chemistry/Components/SolutionRegenerationComponent.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

* remain entity

* That has to be a rogue test fail.

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
This commit is contained in:
IProduceWidgets
2024-09-18 22:17:13 -04:00
committed by GitHub
parent b129629405
commit 550c423181
3 changed files with 20 additions and 20 deletions

View File

@@ -14,31 +14,31 @@ public sealed partial class SolutionRegenerationComponent : Component
/// <summary> /// <summary>
/// The name of the solution to add to. /// The name of the solution to add to.
/// </summary> /// </summary>
[DataField("solution", required: true), ViewVariables(VVAccess.ReadWrite)] [DataField("solution", required: true)]
public string SolutionName = string.Empty; public string SolutionName = string.Empty;
/// <summary> /// <summary>
/// The solution to add reagents to. /// The solution to add reagents to.
/// </summary> /// </summary>
[DataField("solutionRef")] [DataField]
public Entity<SolutionComponent>? Solution = null; public Entity<SolutionComponent>? SolutionRef = null;
/// <summary> /// <summary>
/// The reagent(s) to be regenerated in the solution. /// The reagent(s) to be regenerated in the solution.
/// </summary> /// </summary>
[DataField("generated", required: true), ViewVariables(VVAccess.ReadWrite)] [DataField(required: true)]
public Solution Generated = default!; public Solution Generated = default!;
/// <summary> /// <summary>
/// How long it takes to regenerate once. /// How long it takes to regenerate once.
/// </summary> /// </summary>
[DataField("duration"), ViewVariables(VVAccess.ReadWrite)] [DataField]
public TimeSpan Duration = TimeSpan.FromSeconds(1); public TimeSpan Duration = TimeSpan.FromSeconds(1);
/// <summary> /// <summary>
/// The time when the next regeneration will occur. /// The time when the next regeneration will occur.
/// </summary> /// </summary>
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] [DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField] [AutoPausedField]
public TimeSpan NextRegenTime = TimeSpan.FromSeconds(0); public TimeSpan NextRegenTime = TimeSpan.FromSeconds(0);
} }

View File

@@ -24,7 +24,7 @@ public sealed class SolutionRegenerationSystem : EntitySystem
// timer ignores if its full, it's just a fixed cycle // timer ignores if its full, it's just a fixed cycle
regen.NextRegenTime = _timing.CurTime + regen.Duration; regen.NextRegenTime = _timing.CurTime + regen.Duration;
if (_solutionContainer.ResolveSolution((uid, manager), regen.SolutionName, ref regen.Solution, out var solution)) if (_solutionContainer.ResolveSolution((uid, manager), regen.SolutionName, ref regen.SolutionRef, out var solution))
{ {
var amount = FixedPoint2.Min(solution.AvailableVolume, regen.Generated.Volume); var amount = FixedPoint2.Min(solution.AvailableVolume, regen.Generated.Volume);
if (amount <= FixedPoint2.Zero) if (amount <= FixedPoint2.Zero)
@@ -41,7 +41,7 @@ public sealed class SolutionRegenerationSystem : EntitySystem
generated = regen.Generated.Clone().SplitSolution(amount); generated = regen.Generated.Clone().SplitSolution(amount);
} }
_solutionContainer.TryAddSolution(regen.Solution.Value, generated); _solutionContainer.TryAddSolution(regen.SolutionRef.Value, generated);
} }
} }
} }

View File

@@ -23,14 +23,14 @@ public sealed partial class DrainComponent : Component
[DataField] [DataField]
public Entity<SolutionComponent>? Solution = null; public Entity<SolutionComponent>? Solution = null;
[DataField("accumulator")] [DataField]
public float Accumulator = 0f; public float Accumulator = 0f;
/// <summary> /// <summary>
/// Does this drain automatically absorb surrouding puddles? Or is it a drain designed to empty /// Does this drain automatically absorb surrouding puddles? Or is it a drain designed to empty
/// solutions in it manually? /// solutions in it manually?
/// </summary> /// </summary>
[DataField("autoDrain"), ViewVariables(VVAccess.ReadOnly)] [DataField]
public bool AutoDrain = true; public bool AutoDrain = true;
/// <summary> /// <summary>
@@ -38,47 +38,47 @@ public sealed partial class DrainComponent : Component
/// Divided by puddles, so if there are 5 puddles this will take 1/5 from each puddle. /// Divided by puddles, so if there are 5 puddles this will take 1/5 from each puddle.
/// This will stay fixed to 1 second no matter what DrainFrequency is. /// This will stay fixed to 1 second no matter what DrainFrequency is.
/// </summary> /// </summary>
[DataField("unitsPerSecond")] [DataField]
public float UnitsPerSecond = 6f; public float UnitsPerSecond = 6f;
/// <summary> /// <summary>
/// How many units are ejected from the buffer per second. /// How many units are ejected from the buffer per second.
/// </summary> /// </summary>
[DataField("unitsDestroyedPerSecond")] [DataField]
public float UnitsDestroyedPerSecond = 3f; public float UnitsDestroyedPerSecond = 3f;
/// <summary> /// <summary>
/// How many (unobstructed) tiles away the drain will /// How many (unobstructed) tiles away the drain will
/// drain puddles from. /// drain puddles from.
/// </summary> /// </summary>
[DataField("range"), ViewVariables(VVAccess.ReadWrite)] [DataField]
public float Range = 2f; public float Range = 2f;
/// <summary> /// <summary>
/// How often in seconds the drain checks for puddles around it. /// How often in seconds the drain checks for puddles around it.
/// If the EntityQuery seems a bit unperformant this can be increased. /// If the EntityQuery seems a bit unperformant this can be increased.
/// </summary> /// </summary>
[DataField("drainFrequency")] [DataField]
public float DrainFrequency = 1f; public float DrainFrequency = 1f;
/// <summary> /// <summary>
/// How much time it takes to unclog it with a plunger /// How much time it takes to unclog it with a plunger
/// </summary> /// </summary>
[DataField("unclogDuration"), ViewVariables(VVAccess.ReadWrite)] [DataField]
public float UnclogDuration = 1f; public float UnclogDuration = 1f;
/// <summary> /// <summary>
/// What's the probability of uncloging on each try /// What's the probability of uncloging on each try
/// </summary> /// </summary>
[DataField("unclogProbability"), ViewVariables(VVAccess.ReadWrite)] [DataField]
public float UnclogProbability = 0.75f; public float UnclogProbability = 0.75f;
[DataField("manualDrainSound"), ViewVariables(VVAccess.ReadOnly)] [DataField]
public SoundSpecifier ManualDrainSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg"); public SoundSpecifier ManualDrainSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
[DataField("plungerSound"), ViewVariables(VVAccess.ReadOnly)] [DataField]
public SoundSpecifier PlungerSound = new SoundPathSpecifier("/Audio/Items/Janitor/plunger.ogg"); public SoundSpecifier PlungerSound = new SoundPathSpecifier("/Audio/Items/Janitor/plunger.ogg");
[DataField("unclogSound"), ViewVariables(VVAccess.ReadOnly)] [DataField]
public SoundSpecifier UnclogSound = new SoundPathSpecifier("/Audio/Effects/Fluids/glug.ogg"); public SoundSpecifier UnclogSound = new SoundPathSpecifier("/Audio/Effects/Fluids/glug.ogg");
} }