fish-station/Content.Shared/Chemistry/Components/SolutionRegenerationComponent.cs
2025-08-13 16:00:32 +03:00

54 lines
1.8 KiB
C#

using Content.Shared._Sunrise.SolutionRegenerationSwitcher;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Chemistry.Components;
/// <summary>
/// Passively increases a solution's quantity of a reagent.
/// </summary>
[RegisterComponent, AutoGenerateComponentPause, AutoGenerateComponentState, NetworkedComponent]
[Access(typeof(SolutionRegenerationSystem), typeof(SharedSolutionRegenerationSwitcherSystem))] // Sunrise-Edit
public sealed partial class SolutionRegenerationComponent : Component
{
/// <summary>
/// The name of the solution to add to.
/// </summary>
[DataField("solution", required: true)]
public string SolutionName = string.Empty;
/// <summary>
/// The solution to add reagents to.
/// </summary>
[ViewVariables]
public Entity<SolutionComponent>? SolutionRef = null;
/// <summary>
/// The reagent(s) to be regenerated in the solution.
/// </summary>
[DataField(required: true)]
public Solution Generated = default!;
/// <summary>
/// How long it takes to regenerate once.
/// </summary>
[DataField]
public TimeSpan Duration = TimeSpan.FromSeconds(1);
/// <summary>
/// The time when the next regeneration will occur.
/// </summary>
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
[AutoPausedField, AutoNetworkedField]
public TimeSpan NextRegenTime = TimeSpan.FromSeconds(0);
// Sunrise-start
public void ChangeGenerated(ReagentQuantity reagent)
{
Generated.RemoveAllSolution();
Generated.AddReagent(reagent);
}
// Sunrise-end
}