Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Botany Rework Part 1: Mutations #31163

Merged
merged 22 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cd776d0
Use EntityEffects for new mutation system. Now works for Bioluminesce…
PraxisMapper Aug 17, 2024
64fb085
Sentient shouldn't apply to the botany tray.
PraxisMapper Aug 17, 2024
112155e
Add speciesChange and Unviable mutations
PraxisMapper Aug 18, 2024
268abb7
Add tolerance mutation effects
PraxisMapper Aug 18, 2024
d84b3c6
add stat mutation effects
PraxisMapper Aug 18, 2024
c776867
Add the last 4 boolean mutations.
PraxisMapper Aug 18, 2024
f64fa49
move chemical mutation to effect.
PraxisMapper Aug 18, 2024
ed775bf
move gas and harvest mutations to effects. All existing effects moved.
PraxisMapper Aug 18, 2024
1f2d028
Merge branch 'master' into mutationRework
drakewill-CRL Aug 18, 2024
e46252e
cleanup IDE warning and messages in files I touched.
PraxisMapper Aug 18, 2024
ae9c27f
Fix 'concrete type' error
PraxisMapper Aug 19, 2024
76afb02
Merge branch 'space-wizards:master' into mutationRework
drakewill-CRL Aug 19, 2024
085e925
Do not apply the same persistent mutation twice.
PraxisMapper Aug 25, 2024
90b15b4
correct odds for mutations.
PraxisMapper Aug 29, 2024
2c0797b
Merge branch 'master' into mutationRework
drakewill-CRL Sep 9, 2024
73c36c9
Review change requests.
PraxisMapper Sep 9, 2024
eb44612
BEGONE LINEBREAKS
PraxisMapper Sep 10, 2024
6f13f04
Log an error the best we can if the stat to modify wasn't found
PraxisMapper Sep 10, 2024
02364fc
PlantChangeStat now supports bools, includes MutateInt/Float.
PraxisMapper Sep 14, 2024
75029e7
Missed 1 entry in yml
PraxisMapper Sep 14, 2024
4cda18e
Unviable is a stat change, don't add it to the mutations list
PraxisMapper Sep 14, 2024
24835b9
Add quick explainer for LINQ line
PraxisMapper Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions Content.Server/Botany/Components/PlantHolderComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,90 +6,90 @@ namespace Content.Server.Botany.Components;
[RegisterComponent]
public sealed partial class PlantHolderComponent : Component
{
[DataField("nextUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan NextUpdate = TimeSpan.Zero;
[ViewVariables(VVAccess.ReadWrite), DataField("updateDelay")]
[DataField]
public TimeSpan UpdateDelay = TimeSpan.FromSeconds(3);

[DataField("lastProduce")]
[DataField]
public int LastProduce;

[ViewVariables(VVAccess.ReadWrite), DataField("missingGas")]
[DataField]
public int MissingGas;

[DataField("cycleDelay")]
[DataField]
public TimeSpan CycleDelay = TimeSpan.FromSeconds(15f);

[DataField("lastCycle", customTypeSerializer: typeof(TimeOffsetSerializer))]
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
public TimeSpan LastCycle = TimeSpan.Zero;

[ViewVariables(VVAccess.ReadWrite), DataField("updateSpriteAfterUpdate")]
[DataField]
public bool UpdateSpriteAfterUpdate;

[ViewVariables(VVAccess.ReadWrite), DataField("drawWarnings")]
[DataField]
public bool DrawWarnings = false;

[ViewVariables(VVAccess.ReadWrite), DataField("waterLevel")]
[DataField]
public float WaterLevel = 100f;

[ViewVariables(VVAccess.ReadWrite), DataField("nutritionLevel")]
[DataField]
public float NutritionLevel = 100f;

[ViewVariables(VVAccess.ReadWrite), DataField("pestLevel")]
[DataField]
public float PestLevel;

[ViewVariables(VVAccess.ReadWrite), DataField("weedLevel")]
[DataField]
public float WeedLevel;

[ViewVariables(VVAccess.ReadWrite), DataField("toxins")]
[DataField]
public float Toxins;

[ViewVariables(VVAccess.ReadWrite), DataField("age")]
[DataField]
public int Age;

[ViewVariables(VVAccess.ReadWrite), DataField("skipAging")]
[DataField]
public int SkipAging;

[ViewVariables(VVAccess.ReadWrite), DataField("dead")]
[DataField]
public bool Dead;

[ViewVariables(VVAccess.ReadWrite), DataField("harvest")]
[DataField]
public bool Harvest;

[ViewVariables(VVAccess.ReadWrite), DataField("sampled")]
[DataField]
public bool Sampled;

[ViewVariables(VVAccess.ReadWrite), DataField("yieldMod")]
[DataField]
public int YieldMod = 1;

[ViewVariables(VVAccess.ReadWrite), DataField("mutationMod")]
[DataField]
public float MutationMod = 1f;

[ViewVariables(VVAccess.ReadWrite), DataField("mutationLevel")]
[DataField]
public float MutationLevel;

[ViewVariables(VVAccess.ReadWrite), DataField("health")]
[DataField]
public float Health;

[ViewVariables(VVAccess.ReadWrite), DataField("weedCoefficient")]
[DataField]
public float WeedCoefficient = 1f;

[ViewVariables(VVAccess.ReadWrite), DataField("seed")]
[DataField]
public SeedData? Seed;

[ViewVariables(VVAccess.ReadWrite), DataField("improperHeat")]
[DataField]
public bool ImproperHeat;

[ViewVariables(VVAccess.ReadWrite), DataField("improperPressure")]
[DataField]
public bool ImproperPressure;

[ViewVariables(VVAccess.ReadWrite), DataField("improperLight")]
[DataField]
public bool ImproperLight;

[ViewVariables(VVAccess.ReadWrite), DataField("forceUpdate")]
[DataField]
public bool ForceUpdate;

[ViewVariables(VVAccess.ReadWrite), DataField("solution")]
[DataField]
public string SoilSolutionName = "soil";

[DataField]
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Botany/Components/ProduceComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public sealed partial class ProduceComponent : SharedProduceComponent
/// <summary>
/// Seed data used to create a <see cref="SeedComponent"/> when this produce has its seeds extracted.
/// </summary>
[DataField("seed")]
[DataField]
public SeedData? Seed;

/// <summary>
/// Seed data used to create a <see cref="SeedComponent"/> when this produce has its seeds extracted.
/// </summary>
[DataField("seedId", customTypeSerializer: typeof(PrototypeIdSerializer<SeedPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<SeedPrototype>))]
public string? SeedId;
}
102 changes: 43 additions & 59 deletions Content.Server/Botany/SeedPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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;
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down Expand Up @@ -295,17 +284,14 @@ public SeedData Clone()

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,
Expand Down Expand Up @@ -356,18 +342,16 @@ public SeedData SpeciesChange(SeedData other)
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.
Expand Down
10 changes: 10 additions & 0 deletions Content.Server/Botany/Systems/BotanySystem.Produce.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.Botany.Components;
using Content.Shared.EntityEffects;
using Content.Shared.FixedPoint;

namespace Content.Server.Botany.Systems;
Expand All @@ -10,6 +11,15 @@ public void ProduceGrown(EntityUid uid, ProduceComponent produce)
if (!TryGetSeed(produce, out var seed))
return;

foreach (var mutation in seed.Mutations)
{
if (mutation.AppliesToProduce)
{
var args = new EntityEffectBaseArgs(uid, EntityManager);
mutation.Effect.Effect(args);
}
}

if (!_solutionContainerSystem.EnsureSolution(uid,
produce.SolutionName,
out var solutionContainer,
Expand Down
Loading
Loading