CatStation/Content.Shared/Botany/Components/PlantHolderComponent.cs
ahandleman bc33f740cf
Allow for multiple mutation and chem tables (#45769)
* Initial decoupling of main mutation table from mutation level - levels are now stored on a per-table basis.

* Changes to allow for multiple chem tables

* Update to use specified chemicals for random mutations

* swapped some tryindex to index because they should be validated by the yaml

* Fixes for Pok

* oops refactoring miss

* Make a copy before iterating mutation levels so it doesn't break if mutations mutate in the future.

* yamls capitalization

* review

* Update RandomPlantMutationListPrototype.cs

* refactor: whitespaces + remove excessive allocations

---------

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
Co-authored-by: Fildrance <fildrance@gmail.com>
2026-09-03 14:16:06 +00:00

115 lines
3.6 KiB
C#

using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Botany.Components;
/// <summary>
/// Runtime plant lifecycle data. This component is attached to the plant entity.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(fieldDeltas: true, raiseAfterAutoHandleState: true), AutoGenerateComponentPause]
public sealed partial class PlantHolderComponent : Component
{
/// <summary>
/// Current age of the plant in growth cycles.
/// </summary>
[DataField, AutoNetworkedField]
public int Age = 1;
/// <summary>
/// Number of growth cycles to skip due to poor conditions.
/// </summary>
[DataField, AutoNetworkedField]
public int SkipAging;
/// <summary>
/// Whether the plant is dead.
/// </summary>
[ViewVariables, AutoNetworkedField]
public bool Dead;
/// <summary>
/// Multiplier for the number of entities produced at harvest.
/// </summary>
[DataField, AutoNetworkedField]
public int YieldMod = 1;
[DataField, AutoNetworkedField]
public int MaxYieldMod = 2;
/// <summary>
/// Current mutation level buildup per mutation table.
/// Levels are consumed (reset to zero) each time the plant ages and processes its mutations.
/// </summary>
[DataField, AutoNetworkedField]
public Dictionary<ProtoId<RandomPlantMutationListPrototype>, float> MutationLevels = [];
[DataField, AutoNetworkedField]
public float MaxMutationLevel = 25f;
/// <summary>
/// Multiplier for mutation chance and severity.
/// </summary>
[DataField, AutoNetworkedField]
public float MutationMod = 1f;
[DataField, AutoNetworkedField]
public float MaxMutationMod = 3f;
/// <summary>
/// Current health of the plant (0 to seed endurance).
/// </summary>
[DataField, AutoNetworkedField]
public float Health = 100f;
/// <summary>
/// Whether the plant is currently ready for harvest.
/// </summary>
[ViewVariables, AutoNetworkedField]
public bool ReadyForHarvest = false;
/// <summary>
/// The age of the plant when last harvested.
/// </summary>
[ViewVariables, AutoNetworkedField]
public int LastHarvest = 0;
/// <summary>
/// Game time for the next plant reagent update.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField, AutoPausedField]
public TimeSpan NextUpdate = TimeSpan.Zero;
/// <summary>
/// Time between plant growth updates.
/// </summary>
[DataField, AutoNetworkedField]
public TimeSpan CycleDelay = TimeSpan.FromSeconds(15f);
/// <summary>
/// Game time when the plant last did a growth update.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField, AutoPausedField]
public TimeSpan LastCycle = TimeSpan.Zero;
/// <summary>
/// True if the plant is losing health due to too high/low temperature.
/// </summary>
[DataField, AutoNetworkedField]
[Access(Other = AccessPermissions.ReadWriteExecute)]
public bool ImproperHeat;
/// <summary>
/// True if the plant is losing health due to too high/low pressure.
/// </summary>
[DataField, AutoNetworkedField]
[Access(Other = AccessPermissions.ReadWriteExecute)]
public bool ImproperPressure;
/// <summary>
/// True if the plant is missing gases required for growth.
/// </summary>
[DataField, AutoNetworkedField]
[Access(Other = AccessPermissions.ReadWriteExecute)]
public bool MissingGas;
}