using Content.Server.Botany.Components; using Robust.Shared.Random; namespace Content.Server.Botany.Systems; /// /// Handles plant behavior and growth processing. /// public sealed class PlantSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; public override void Initialize() { SubscribeLocalEvent(OnPlantGrow); } private void OnPlantGrow(Entity ent, ref OnPlantGrowEvent args) { var (uid, component) = ent; if (!TryComp(uid, out PlantHolderComponent? holder)) return; // Check if plant is too old. if (holder.Age > component.Lifespan) { holder.Health -= _random.Next(3, 5) * BasicGrowthSystem.HydroponicsSpeedMultiplier; if (holder.DrawWarnings) holder.UpdateSpriteAfterUpdate = true; } } /// /// Adjusts the potency of a plant component. /// public void AdjustPotency(Entity ent, float delta) { var plant = ent.Comp; plant.Potency = Math.Max(plant.Potency + delta, 1); Dirty(ent); } }