From e68cb5a912f949118c02298ad2d57ea1562d5d36 Mon Sep 17 00:00:00 2001 From: PraxisMapper Date: Thu, 19 Sep 2024 19:32:03 -0400 Subject: [PATCH] Update chemical effects --- .../PlantMetabolism/PlantAdjustAttribute.cs | 9 +++----- .../PlantMetabolism/PlantAdjustHealth.cs | 15 ++++++++----- .../PlantAdjustMutationLevel.cs | 5 +++-- .../PlantMetabolism/PlantAdjustMutationMod.cs | 5 +++-- .../PlantMetabolism/PlantAdjustNutrition.cs | 8 +++---- .../PlantMetabolism/PlantAdjustPests.cs | 8 +++---- .../PlantMetabolism/PlantAdjustPotency.cs | 16 +++++--------- .../PlantMetabolism/PlantAdjustToxins.cs | 6 ++--- .../PlantMetabolism/PlantAdjustWater.cs | 8 +++---- .../PlantMetabolism/PlantAdjustWeeds.cs | 8 +++++-- .../PlantMetabolism/PlantAffectGrowth.cs | 8 +++---- .../PlantMetabolism/PlantCryoxadone.cs | 20 +++++++++-------- .../PlantMetabolism/PlantDestroySeeds.cs | 20 +++++------------ .../PlantMetabolism/PlantDiethylamine.cs | 16 ++++---------- .../PlantMetabolism/PlantPhalanximine.cs | 7 +++--- .../PlantMetabolism/PlantRestoreSeeds.cs | 22 ++++++------------- .../Effects/PlantMetabolism/RobustHarvest.cs | 22 +++++++------------ 17 files changed, 86 insertions(+), 117 deletions(-) diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustAttribute.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustAttribute.cs index 5133fe502ffc8f..71f22de78fb106 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustAttribute.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustAttribute.cs @@ -1,7 +1,6 @@ using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using Robust.Shared.Prototypes; -using Robust.Shared.Random; using System.Diagnostics.CodeAnalysis; namespace Content.Server.EntityEffects.Effects.PlantMetabolism; @@ -32,14 +31,12 @@ public abstract partial class PlantAdjustAttribute : EntityEffect /// The entity manager /// Whether to check if it has an alive plant or not /// - public bool CanMetabolize(EntityUid plantHolder, [NotNullWhen(true)] out PlantHolderComponent? plantHolderComponent, + public bool CanMetabolize(EntityUid plant, [NotNullWhen(true)] out PlantComponent? plantComponent, IEntityManager entityManager, bool mustHaveAlivePlant = true) { - plantHolderComponent = null; - - if (!entityManager.TryGetComponent(plantHolder, out plantHolderComponent) - || mustHaveAlivePlant && (plantHolderComponent.Seed == null || plantHolderComponent.Dead)) + if (!entityManager.TryGetComponent(plant, out plantComponent) + || (mustHaveAlivePlant && plantComponent.Dead)) return false; return true; diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustHealth.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustHealth.cs index 774f6ec48c6735..dbfa8330e1c1af 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustHealth.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustHealth.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; @@ -6,16 +7,18 @@ namespace Content.Server.EntityEffects.Effects.PlantMetabolism; public sealed partial class PlantAdjustHealth : PlantAdjustAttribute { public override string GuidebookAttributeName { get; set; } = "plant-attribute-health"; - + public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!CanMetabolize(args.TargetEntity, out PlantComponent? plantComp, args.EntityManager)) return; - var plantHolder = args.EntityManager.System(); - - plantHolderComp.Health += Amount; - plantHolder.CheckHealth(args.TargetEntity, plantHolderComp); + plantComp.Health += Amount; + if (plantComp.Health <= 0) + { + var plant = args.EntityManager.System(); + plant.Die(args.TargetEntity); + } } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationLevel.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationLevel.cs index bf41a21bcb0d64..ca21359db7c7f5 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationLevel.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationLevel.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; namespace Content.Server.EntityEffects.Effects.PlantMetabolism; @@ -8,9 +9,9 @@ public sealed partial class PlantAdjustMutationLevel : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!CanMetabolize(args.TargetEntity, out PlantComponent? plantComp, args.EntityManager)) return; - plantHolderComp.MutationLevel += Amount * plantHolderComp.MutationMod; + plantComp.MutationLevel += Amount * plantComp.MutationMod; } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationMod.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationMod.cs index 6ed793e61431f6..8e69f3507c7480 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationMod.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustMutationMod.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -10,10 +11,10 @@ public sealed partial class PlantAdjustMutationMod : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!CanMetabolize(args.TargetEntity, out PlantComponent? plantComp, args.EntityManager)) return; - plantHolderComp.MutationMod += Amount; + plantComp.MutationMod = Math.Clamp(plantComp.MutationMod + Amount, 1f, 3f); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustNutrition.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustNutrition.cs index b9389afacdf032..afedc6ab4c9885 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustNutrition.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustNutrition.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,11 +12,8 @@ public sealed partial class PlantAdjustNutrition : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false)) - return; - + var plantComp = args.EntityManager.GetComponent(args.TargetEntity); var plantHolder = args.EntityManager.System(); - - plantHolder.AdjustNutrient(args.TargetEntity, Amount, plantHolderComp); + plantHolder.AdjustNutrient(plantComp.PlantHolderUid, Amount); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPests.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPests.cs index 219529bfc4cf9b..0d4c0fd240240b 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPests.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPests.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,10 +12,9 @@ public sealed partial class PlantAdjustPests : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) - return; - - plantHolderComp.PestLevel += Amount; + var plantComp = args.EntityManager.GetComponent(args.TargetEntity); + var plantHolderComp = args.EntityManager.GetComponent(plantComp.PlantHolderUid); + plantHolderComp.PestLevel = Math.Clamp(plantHolderComp.PestLevel + Amount, 0, 10); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPotency.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPotency.cs index 5776463ce718a1..4c4d2331641128 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPotency.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustPotency.cs @@ -1,4 +1,4 @@ -using Content.Server.Botany.Systems; +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; namespace Content.Server.EntityEffects.Effects.PlantMetabolism; @@ -13,16 +13,12 @@ public sealed partial class PlantAdjustPotency : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) + { return; + } - if (plantHolderComp.Seed == null) - return; - - var plantHolder = args.EntityManager.System(); - - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); - - plantHolderComp.Seed.Potency = Math.Max(plantHolderComp.Seed.Potency + Amount, 1); + plantComp.Seed.Potency = Math.Max(plantComp.Seed.Potency + Amount, 1); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustToxins.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustToxins.cs index ab1baa42850c5e..6f5ba474d0c292 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustToxins.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustToxins.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,9 +12,8 @@ public sealed partial class PlantAdjustToxins : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) - return; - + var plantComp = args.EntityManager.GetComponent(args.TargetEntity); + var plantHolderComp = args.EntityManager.GetComponent(plantComp.PlantHolderUid); plantHolderComp.Toxins += Amount; } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWater.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWater.cs index 41774977d54301..d066437ff6159d 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWater.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWater.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,12 +12,9 @@ public sealed partial class PlantAdjustWater : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false)) - return; - + var plantComp = args.EntityManager.GetComponent(args.TargetEntity); var plantHolder = args.EntityManager.System(); - - plantHolder.AdjustWater(args.TargetEntity, Amount, plantHolderComp); + plantHolder.AdjustWater(plantComp.PlantHolderUid, Amount); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWeeds.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWeeds.cs index 421e31998db0d9..39113fabe6b4c8 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWeeds.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAdjustWeeds.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,9 +12,12 @@ public sealed partial class PlantAdjustWeeds : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp)) return; - plantHolderComp.WeedLevel += Amount; + if (!args.EntityManager.TryGetComponent(plantComp.PlantHolderUid, out PlantHolderComponent? plantHolderComp)) + return; + + plantHolderComp.WeedLevel = Math.Clamp(plantHolderComp.WeedLevel + Amount, 0f, 10f); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAffectGrowth.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAffectGrowth.cs index 397eace399af4f..17c00aa963422c 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAffectGrowth.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantAffectGrowth.cs @@ -1,3 +1,4 @@ +using Content.Server.Botany.Components; using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; @@ -11,12 +12,11 @@ public sealed partial class PlantAffectGrowth : PlantAdjustAttribute public override void Effect(EntityEffectBaseArgs args) { - if (!CanMetabolize(args.TargetEntity, out var plantHolderComp, args.EntityManager)) + if (!CanMetabolize(args.TargetEntity, out PlantComponent? plantComp, args.EntityManager)) return; - var plantHolder = args.EntityManager.System(); - - plantHolder.AffectGrowth(args.TargetEntity, (int) Amount, plantHolderComp); + var plant = args.EntityManager.System(); + plant.AffectGrowth(args.TargetEntity, (int)Amount, plantComp); } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantCryoxadone.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantCryoxadone.cs index 7fe4b7a1707b16..0d9963085614d9 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantCryoxadone.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantCryoxadone.cs @@ -1,4 +1,5 @@ using Content.Server.Botany.Components; +using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; using Robust.Shared.Prototypes; @@ -12,20 +13,21 @@ public sealed partial class PlantCryoxadone : EntityEffect { public override void Effect(EntityEffectBaseArgs args) { - if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null || plantHolderComp.Dead) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; var deviation = 0; - var seed = plantHolderComp.Seed; + var seed = plantComp.Seed; var random = IoCManager.Resolve(); - if (plantHolderComp.Age > seed.Maturation) - deviation = (int) Math.Max(seed.Maturation - 1, plantHolderComp.Age - random.Next(7, 10)); + if (plantComp.Age > seed.Maturation) + deviation = (int)Math.Max(seed.Maturation - 1, plantComp.Age - random.Next(7, 10)); else - deviation = (int) (seed.Maturation / seed.GrowthStages); - plantHolderComp.Age -= deviation; - plantHolderComp.SkipAging++; - plantHolderComp.ForceUpdate = true; + deviation = (int)(seed.Maturation / seed.GrowthStages); + plantComp.Age -= deviation; + plantComp.SkipAging++; + var plantSys = args.EntityManager.System(); + plantSys.Update(args.TargetEntity, plantComp); } protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-cryoxadone", ("chance", Probability)); diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDestroySeeds.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDestroySeeds.cs index 2929bb6ee9e161..590d74e7a39a18 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDestroySeeds.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDestroySeeds.cs @@ -1,5 +1,4 @@ -using Content.Server.Botany.Components; -using Content.Server.Botany.Systems; +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using Content.Shared.Popups; using Robust.Shared.Prototypes; @@ -14,26 +13,19 @@ public sealed partial class PlantDestroySeeds : EntityEffect { public override void Effect(EntityEffectBaseArgs args) { - if ( - !args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null - || plantHolderComp.Dead - || plantHolderComp.Seed.Immutable - ) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; - var plantHolder = args.EntityManager.System(); - var popupSystem = args.EntityManager.System(); - - if (plantHolderComp.Seed.Seedless == false) + if (plantComp.Seed != null && plantComp.Seed.Seedless == false) { - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); + var popupSystem = args.EntityManager.System(); popupSystem.PopupEntity( Loc.GetString("botany-plant-seedsdestroyed"), args.TargetEntity, PopupType.SmallCaution ); - plantHolderComp.Seed.Seedless = true; + plantComp.Seed.Seedless = true; } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDiethylamine.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDiethylamine.cs index 36b6a8334235ae..413dd241bed204 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDiethylamine.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantDiethylamine.cs @@ -1,5 +1,4 @@ using Content.Server.Botany.Components; -using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; using Robust.Shared.Prototypes; @@ -13,29 +12,22 @@ public sealed partial class PlantDiethylamine : EntityEffect { public override void Effect(EntityEffectBaseArgs args) { - if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null || plantHolderComp.Dead || - plantHolderComp.Seed.Immutable) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; - - var plantHolder = args.EntityManager.System(); - var random = IoCManager.Resolve(); if (random.Prob(0.1f)) { - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); - plantHolderComp.Seed.Lifespan++; + plantComp.Seed.Lifespan++; } if (random.Prob(0.1f)) { - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); - plantHolderComp.Seed.Endurance++; + plantComp.Seed.Endurance++; } } - protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-diethylamine", ("chance", Probability)); } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantPhalanximine.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantPhalanximine.cs index 96d98bfbf2ec66..2ae33be88021d6 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantPhalanximine.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantPhalanximine.cs @@ -11,12 +11,11 @@ public sealed partial class PlantPhalanximine : EntityEffect { public override void Effect(EntityEffectBaseArgs args) { - if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null || plantHolderComp.Dead || - plantHolderComp.Seed.Immutable) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; - plantHolderComp.Seed.Viable = true; + plantComp.Seed.Viable = true; } protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-phalanximine", ("chance", Probability)); diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantRestoreSeeds.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantRestoreSeeds.cs index 11af8d511fe7a5..a952ac60794408 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantRestoreSeeds.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/PlantRestoreSeeds.cs @@ -1,5 +1,4 @@ -using Content.Server.Botany.Components; -using Content.Server.Botany.Systems; +using Content.Server.Botany.Components; using Content.Shared.EntityEffects; using Content.Shared.Popups; using Robust.Shared.Prototypes; @@ -7,29 +6,22 @@ namespace Content.Server.EntityEffects.Effects.PlantMetabolism; /// -/// Handles restoral of seeds on a plant. +/// Handles restoration of seeds on a plant. /// public sealed partial class PlantRestoreSeeds : EntityEffect { public override void Effect(EntityEffectBaseArgs args) { - if ( - !args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null - || plantHolderComp.Dead - || plantHolderComp.Seed.Immutable - ) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; - var plantHolder = args.EntityManager.System(); - var popupSystem = args.EntityManager.System(); - - if (plantHolderComp.Seed.Seedless) + if (plantComp.Seed.Seedless) { - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); + var popupSystem = args.EntityManager.System(); popupSystem.PopupEntity(Loc.GetString("botany-plant-seedsrestored"), args.TargetEntity); - plantHolderComp.Seed.Seedless = false; + plantComp.Seed.Seedless = false; } } diff --git a/Content.Server/EntityEffects/Effects/PlantMetabolism/RobustHarvest.cs b/Content.Server/EntityEffects/Effects/PlantMetabolism/RobustHarvest.cs index 695cb96675c5f3..c2f873dcc076bb 100644 --- a/Content.Server/EntityEffects/Effects/PlantMetabolism/RobustHarvest.cs +++ b/Content.Server/EntityEffects/Effects/PlantMetabolism/RobustHarvest.cs @@ -1,5 +1,4 @@ using Content.Server.Botany.Components; -using Content.Server.Botany.Systems; using Content.Shared.EntityEffects; using JetBrains.Annotations; using Robust.Shared.Prototypes; @@ -22,30 +21,25 @@ public sealed partial class RobustHarvest : EntityEffect public override void Effect(EntityEffectBaseArgs args) { - if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantHolderComponent? plantHolderComp) - || plantHolderComp.Seed == null || plantHolderComp.Dead || - plantHolderComp.Seed.Immutable) + if (!args.EntityManager.TryGetComponent(args.TargetEntity, out PlantComponent? plantComp) + || plantComp.Dead || plantComp.Seed == null || plantComp.Seed.Immutable) return; - - var plantHolder = args.EntityManager.System(); var random = IoCManager.Resolve(); - if (plantHolderComp.Seed.Potency < PotencyLimit) + if (plantComp.Seed.Potency < PotencyLimit) { - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); - plantHolderComp.Seed.Potency = Math.Min(plantHolderComp.Seed.Potency + PotencyIncrease, PotencyLimit); + plantComp.Seed.Potency = Math.Min(plantComp.Seed.Potency + PotencyIncrease, PotencyLimit); - if (plantHolderComp.Seed.Potency > PotencySeedlessThreshold) + if (plantComp.Seed.Potency > PotencySeedlessThreshold) { - plantHolderComp.Seed.Seedless = true; + plantComp.Seed.Seedless = true; } } - else if (plantHolderComp.Seed.Yield > 1 && random.Prob(0.1f)) + else if (plantComp.Seed.Yield > 1 && random.Prob(0.1f)) { // Too much of a good thing reduces yield - plantHolder.EnsureUniqueSeed(args.TargetEntity, plantHolderComp); - plantHolderComp.Seed.Yield--; + plantComp.Seed.Yield--; } }