From cdd526ee0a292ee0f0e6f49a94de47029226d551 Mon Sep 17 00:00:00 2001 From: Whatstone <166147148+whatston3@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:05:57 +0000 Subject: [PATCH] Fix killer tomato visual bug after mutation, cleanup Plant*System IComponentFactory instances. (#46201) * MutationSystem: take GrowthStages from new plant * get the rest of the IComponentFactory instances might as well * todo bem --- .../PlantChangeStatEntityEffectSystem.cs | 3 +-- .../Botany/Systems/BotanySystem.Seed.cs | 5 ++--- .../Botany/Systems/MutationSystem.cs | 18 ++++++++++++++++++ .../PlantChangeTraitsEntityEffectSystem.cs | 3 +-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Content.Server/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeStatEntityEffectSystem.cs b/Content.Server/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeStatEntityEffectSystem.cs index 92071552f6..b503cf8669 100644 --- a/Content.Server/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeStatEntityEffectSystem.cs +++ b/Content.Server/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeStatEntityEffectSystem.cs @@ -12,7 +12,6 @@ namespace Content.Server.EntityEffects.Effects.Botany.PlantAttributes; /// public sealed partial class PlantChangeStatEntityEffectSystem : EntityEffectSystem { - [Dependency] private IComponentFactory _componentFactory = default!; [Dependency] private IRobustRandom _random = default!; [Dependency] private PlantHolderSystem _plantHolder = default!; [Dependency] private SharedEntityEffectsSystem _entityEffects = default!; @@ -25,7 +24,7 @@ public sealed partial class PlantChangeStatEntityEffectSystem : EntityEffectSyst var targetDataField = args.Effect.TargetDataField; var targetComponent = args.Effect.TargetComponent; - if (!_componentFactory.TryGetRegistration(targetComponent, out var registration)) + if (!Factory.TryGetRegistration(targetComponent, out var registration)) { Log.Error($"{nameof(PlantChangeStat)} Error: Component '{targetComponent}' is not a valid component name."); return; diff --git a/Content.Shared/Botany/Systems/BotanySystem.Seed.cs b/Content.Shared/Botany/Systems/BotanySystem.Seed.cs index 93efbbfb09..f776891a48 100644 --- a/Content.Shared/Botany/Systems/BotanySystem.Seed.cs +++ b/Content.Shared/Botany/Systems/BotanySystem.Seed.cs @@ -15,7 +15,6 @@ namespace Content.Shared.Botany.Systems; public sealed partial class BotanySystem : EntitySystem { - [Dependency] private IComponentFactory _componentFactory = default!; [Dependency] private IGameTiming _timing = default!; [Dependency] private MetaDataSystem _metaData = default!; [Dependency] private PlantSystem _plant = default!; @@ -87,7 +86,7 @@ public sealed partial class BotanySystem : EntitySystem if (!ProtoMan.TryIndex(plantProtoId.Value, out var proto)) return false; - return proto.TryComp(out plant, _componentFactory); + return proto.TryComp(out plant, Factory); } /// @@ -193,7 +192,7 @@ public sealed partial class BotanySystem : EntitySystem return false; if (!ProtoMan.Resolve(ent.Comp2.PacketPrototype, out var seedProto) - || !seedProto.TryComp(out var seedComp, _componentFactory)) + || !seedProto.TryComp(out var seedComp, Factory)) { return false; } diff --git a/Content.Shared/Botany/Systems/MutationSystem.cs b/Content.Shared/Botany/Systems/MutationSystem.cs index 00135c5163..7dbc723506 100644 --- a/Content.Shared/Botany/Systems/MutationSystem.cs +++ b/Content.Shared/Botany/Systems/MutationSystem.cs @@ -86,6 +86,7 @@ public sealed partial class PlantMutationSystem : EntitySystem _botany.DeletePlantSnapshot(snapshot); ChemicalsSpeciesChange(newPlantUid, newPlantProto); + PlantSpeciesChange(newPlantUid, newPlantProto); if (_plant.TryGetTray(oldPlant.Owner, out var trayEnt)) _plantTray.PlantingPlantInTray(trayEnt.AsNullable(), newPlantUid); @@ -121,6 +122,23 @@ public sealed partial class PlantMutationSystem : EntitySystem Dirty(plantUid, oldPlantChemicals); } + /// + /// Copies information from the PlantComponent on a prototype over to a given plant. + /// + /// + /// must stay true for the given plant. + /// TODO: better support excluding fields depending on clone context. + /// + private void PlantSpeciesChange(EntityUid plantUid, EntProtoId plantProto) + { + if (!_botany.TryGetPlantComponent(null, plantProto, out var newSpecies) + || !_plantQuery.TryComp(plantUid, out var plant)) + return; + + plant.GrowthStages = newSpecies.GrowthStages; + DirtyField(plantUid, plant, nameof(PlantComponent.GrowthStages)); + } + /// /// Combines mutations from the pollen and target plants. /// diff --git a/Content.Shared/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeTraitsEntityEffectSystem.cs b/Content.Shared/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeTraitsEntityEffectSystem.cs index 129c16bde5..d4ec07bdf8 100644 --- a/Content.Shared/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeTraitsEntityEffectSystem.cs +++ b/Content.Shared/EntityEffects/Effects/Botany/PlantAttributes/PlantChangeTraitsEntityEffectSystem.cs @@ -13,14 +13,13 @@ namespace Content.Shared.EntityEffects.Effects.Botany.PlantAttributes; public sealed partial class PlantChangeTraitsEntityEffectSystem : EntityEffectSystem { [Dependency] private PlantHolderSystem _plantHolder = default!; - [Dependency] private IComponentFactory _componentFactory = default!; protected override void Effect(Entity entity, ref EntityEffectEvent args) { if (_plantHolder.IsDead(entity.Owner)) return; - var traitType = _componentFactory.GetComponent(args.Effect.Trait); + var traitType = Factory.GetComponent(args.Effect.Trait); if (traitType is not PlantTraitsComponent) { Log.Error(