CatStation/Content.Shared/EntityEffects/Effects/Botany/PlantAttributes/PlantAdjustMutationLevelEntityEffectSystem.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

34 lines
1.2 KiB
C#

using Content.Shared.Botany.Components;
using Content.Shared.Botany.Systems;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.Botany.PlantAttributes;
/// <summary>
/// Entity effect that adjusts the mutation level of a plant.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
public sealed partial class PlantAdjustMutationLevelEntityEffectSystem : EntityEffectSystem<PlantComponent, PlantAdjustMutationLevel>
{
[Dependency] private PlantHolderSystem _plantHolder = default!;
protected override void Effect(Entity<PlantComponent> entity, ref EntityEffectEvent<PlantAdjustMutationLevel> args)
{
if (_plantHolder.IsDead(entity.Owner))
return;
_plantHolder.AdjustsMutationLevel(entity.Owner, args.Effect.MutationTable, args.Effect.Amount);
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class PlantAdjustMutationLevel : BasePlantAdjustAttribute<PlantAdjustMutationLevel>
{
/// <summary>
/// The mutation table whose level is adjusted.
/// </summary>
[DataField(required: true)]
public ProtoId<RandomPlantMutationListPrototype> MutationTable;
public override string GuidebookAttributeName { get; set; } = "plant-attribute-mutation-level";
}