Botany Rework Part 1: Mutations (#31163)
Instead of each mutation being a flag that gets checked at some unique point in BotanySystem somewhere, they're now EntityEffects that get applied when the mutation occurs and when produce is harvested. One new list was added to SeedData so that multiple other fields could be removed. All the non-stat-change mutations that have been rolled are added to the Mutations list, and get applied to the plant when the mutation occurs or when a seed with the mutation is planted. Produce get mutations applied at harvest if they apply to the produce, and carry all of the plant's mutations over as a seed. This gets rid of the one-off checks for things like Slippery, Bioluminescent, Sentient, etc. The base odds of a mutation applying should be equal to the odds of the original mutation check. It pretended to have 1 bit flip (on averge) per mutation power, and odds of each mutation was the odds of one of its bit being flipped (1 /275 * bits). The 'thermometer code' applied for numbers will be replaced with simple random rolls, as both average out to the middle value. The new checks are much easier to understand and don't obfuscate the actual changes of something happening behind 3 layers of math. The biggest player-facing change is that Potency will be able to get over 65 significantly more often than it did in the previous system, but it will be just as common to get low values as high ones. Mutation definitions have been moved to a .yml file. These include the odds per tick per mutagen strength of that mutation applying that tick, the effect applied, if it applies to the plant and/or its produce. This makes mutations simpler to add and edit. This PR is limited specifically to the mutation logic. Improving other aspects of the system will be done in other PRs per the design document. Mutations was chosen first because its got the largest amount of one-off checks scattered all over that could be consolidated. Once this is merged, mutations could be contributed to the codebase with minimal extra work for later botany refactor PRs.
This commit is contained in:
@@ -2,6 +2,7 @@ using Content.Server.Botany.Components;
|
||||
using Content.Server.Botany.Systems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.Random;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
@@ -132,78 +133,67 @@ public partial class SeedData
|
||||
[DataField("productPrototypes", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
|
||||
public List<string> ProductPrototypes = new();
|
||||
|
||||
[DataField("chemicals")] public Dictionary<string, SeedChemQuantity> Chemicals = new();
|
||||
[DataField] public Dictionary<string, SeedChemQuantity> Chemicals = new();
|
||||
|
||||
[DataField("consumeGasses")] public Dictionary<Gas, float> ConsumeGasses = new();
|
||||
[DataField] public Dictionary<Gas, float> ConsumeGasses = new();
|
||||
|
||||
[DataField("exudeGasses")] public Dictionary<Gas, float> ExudeGasses = new();
|
||||
[DataField] public Dictionary<Gas, float> ExudeGasses = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tolerances
|
||||
|
||||
[DataField("nutrientConsumption")] public float NutrientConsumption = 0.75f;
|
||||
[DataField] public float NutrientConsumption = 0.75f;
|
||||
|
||||
[DataField("waterConsumption")] public float WaterConsumption = 0.5f;
|
||||
[DataField("idealHeat")] public float IdealHeat = 293f;
|
||||
[DataField("heatTolerance")] public float HeatTolerance = 10f;
|
||||
[DataField("idealLight")] public float IdealLight = 7f;
|
||||
[DataField("lightTolerance")] public float LightTolerance = 3f;
|
||||
[DataField("toxinsTolerance")] public float ToxinsTolerance = 4f;
|
||||
[DataField] public float WaterConsumption = 0.5f;
|
||||
[DataField] public float IdealHeat = 293f;
|
||||
[DataField] public float HeatTolerance = 10f;
|
||||
[DataField] public float IdealLight = 7f;
|
||||
[DataField] public float LightTolerance = 3f;
|
||||
[DataField] public float ToxinsTolerance = 4f;
|
||||
|
||||
[DataField("lowPressureTolerance")] public float LowPressureTolerance = 81f;
|
||||
[DataField] public float LowPressureTolerance = 81f;
|
||||
|
||||
[DataField("highPressureTolerance")] public float HighPressureTolerance = 121f;
|
||||
[DataField] public float HighPressureTolerance = 121f;
|
||||
|
||||
[DataField("pestTolerance")] public float PestTolerance = 5f;
|
||||
[DataField] public float PestTolerance = 5f;
|
||||
|
||||
[DataField("weedTolerance")] public float WeedTolerance = 5f;
|
||||
[DataField] public float WeedTolerance = 5f;
|
||||
|
||||
[DataField("weedHighLevelThreshold")] public float WeedHighLevelThreshold = 10f;
|
||||
[DataField] public float WeedHighLevelThreshold = 10f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region General traits
|
||||
|
||||
[DataField("endurance")] public float Endurance = 100f;
|
||||
[DataField] public float Endurance = 100f;
|
||||
|
||||
[DataField("yield")] public int Yield;
|
||||
[DataField("lifespan")] public float Lifespan;
|
||||
[DataField("maturation")] public float Maturation;
|
||||
[DataField("production")] public float Production;
|
||||
[DataField("growthStages")] public int GrowthStages = 6;
|
||||
[DataField] public int Yield;
|
||||
[DataField] public float Lifespan;
|
||||
[DataField] public float Maturation;
|
||||
[DataField] public float Production;
|
||||
[DataField] public int GrowthStages = 6;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("harvestRepeat")] public HarvestType HarvestRepeat = HarvestType.NoRepeat;
|
||||
[DataField] public HarvestType HarvestRepeat = HarvestType.NoRepeat;
|
||||
|
||||
[DataField("potency")] public float Potency = 1f;
|
||||
[DataField] public float Potency = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// If true, cannot be harvested for seeds. Balances hybrids and
|
||||
/// mutations.
|
||||
/// </summary>
|
||||
[DataField("seedless")] public bool Seedless = false;
|
||||
[DataField] public bool Seedless = false;
|
||||
|
||||
/// <summary>
|
||||
/// If false, rapidly decrease health while growing. Used to kill off
|
||||
/// plants with "bad" mutations.
|
||||
/// </summary>
|
||||
[DataField("viable")] public bool Viable = true;
|
||||
|
||||
/// <summary>
|
||||
/// If true, fruit slips players.
|
||||
/// </summary>
|
||||
[DataField("slip")] public bool Slip = false;
|
||||
|
||||
/// <summary>
|
||||
/// If true, fruits are sentient.
|
||||
/// </summary>
|
||||
[DataField("sentient")] public bool Sentient = false;
|
||||
[DataField] public bool Viable = true;
|
||||
|
||||
/// <summary>
|
||||
/// If true, a sharp tool is required to harvest this plant.
|
||||
/// </summary>
|
||||
[DataField("ligneous")] public bool Ligneous;
|
||||
[DataField] public bool Ligneous;
|
||||
|
||||
// No, I'm not removing these.
|
||||
// if you re-add these, make sure that they get cloned.
|
||||
@@ -222,36 +212,35 @@ public partial class SeedData
|
||||
|
||||
#region Cosmetics
|
||||
|
||||
[DataField("plantRsi", required: true)]
|
||||
[DataField(required: true)]
|
||||
public ResPath PlantRsi { get; set; } = default!;
|
||||
|
||||
[DataField("plantIconState")] public string PlantIconState { get; set; } = "produce";
|
||||
[DataField] public string PlantIconState { get; set; } = "produce";
|
||||
|
||||
/// <summary>
|
||||
/// Screams random sound, could be strict sound SoundPathSpecifier or collection SoundCollectionSpecifier
|
||||
/// base class is SoundSpecifier
|
||||
/// Screams random sound from collection SoundCollectionSpecifier
|
||||
/// </summary>
|
||||
[DataField("screamSound")]
|
||||
[DataField]
|
||||
public SoundSpecifier ScreamSound = new SoundCollectionSpecifier("PlantScreams", AudioParams.Default.WithVolume(-10));
|
||||
|
||||
[DataField("screaming")] public bool CanScream;
|
||||
|
||||
[DataField("bioluminescent")] public bool Bioluminescent;
|
||||
[DataField("bioluminescentColor")] public Color BioluminescentColor { get; set; } = Color.White;
|
||||
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] public string KudzuPrototype = "WeakKudzu";
|
||||
|
||||
public float BioluminescentRadius = 2f;
|
||||
|
||||
[DataField("kudzuPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] public string KudzuPrototype = "WeakKudzu";
|
||||
|
||||
[DataField("turnIntoKudzu")] public bool TurnIntoKudzu;
|
||||
[DataField("splatPrototype")] public string? SplatPrototype { get; set; }
|
||||
[DataField] public bool TurnIntoKudzu;
|
||||
[DataField] public string? SplatPrototype { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The mutation effects that have been applied to this plant.
|
||||
/// </summary>
|
||||
[DataField] public List<RandomPlantMutation> Mutations { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The seed prototypes this seed may mutate into when prompted to.
|
||||
/// </summary>
|
||||
[DataField("mutationPrototypes", customTypeSerializer: typeof(PrototypeIdListSerializer<SeedPrototype>))]
|
||||
[DataField(customTypeSerializer: typeof(PrototypeIdListSerializer<SeedPrototype>))]
|
||||
public List<string> MutationPrototypes = new();
|
||||
|
||||
public SeedData Clone()
|
||||
@@ -295,17 +284,14 @@ public partial class SeedData
|
||||
|
||||
Seedless = Seedless,
|
||||
Viable = Viable,
|
||||
Slip = Slip,
|
||||
Sentient = Sentient,
|
||||
Ligneous = Ligneous,
|
||||
|
||||
PlantRsi = PlantRsi,
|
||||
PlantIconState = PlantIconState,
|
||||
Bioluminescent = Bioluminescent,
|
||||
CanScream = CanScream,
|
||||
TurnIntoKudzu = TurnIntoKudzu,
|
||||
BioluminescentColor = BioluminescentColor,
|
||||
SplatPrototype = SplatPrototype,
|
||||
Mutations = Mutations,
|
||||
|
||||
// Newly cloned seed is unique. No need to unnecessarily clone if repeatedly modified.
|
||||
Unique = true,
|
||||
@@ -356,18 +342,16 @@ public partial class SeedData
|
||||
HarvestRepeat = HarvestRepeat,
|
||||
Potency = Potency,
|
||||
|
||||
Mutations = Mutations,
|
||||
|
||||
Seedless = Seedless,
|
||||
Viable = Viable,
|
||||
Slip = Slip,
|
||||
Sentient = Sentient,
|
||||
Ligneous = Ligneous,
|
||||
|
||||
PlantRsi = other.PlantRsi,
|
||||
PlantIconState = other.PlantIconState,
|
||||
Bioluminescent = Bioluminescent,
|
||||
CanScream = CanScream,
|
||||
TurnIntoKudzu = TurnIntoKudzu,
|
||||
BioluminescentColor = BioluminescentColor,
|
||||
SplatPrototype = other.SplatPrototype,
|
||||
|
||||
// Newly cloned seed is unique. No need to unnecessarily clone if repeatedly modified.
|
||||
|
||||
Reference in New Issue
Block a user