mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
29 lines
880 B
C#
29 lines
880 B
C#
using Content.Server.Botany.Components;
|
|
|
|
namespace Content.Server.Botany.Systems;
|
|
|
|
/// <summary>
|
|
/// Applies a death chance and damage to unviable plants each growth tick, updating visuals when necessary.
|
|
/// </summary>
|
|
public sealed class UnviableGrowthSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<UnviableGrowthComponent, OnPlantGrowEvent>(OnPlantGrow);
|
|
}
|
|
|
|
private void OnPlantGrow(Entity<UnviableGrowthComponent> ent, ref OnPlantGrowEvent args)
|
|
{
|
|
var (uid, component) = ent;
|
|
|
|
if (!TryComp(uid, out PlantHolderComponent? holder)
|
|
|| !BotanySystem.TryGetPlantTraits(holder.Seed, out var traits)
|
|
|| traits.Viable)
|
|
return;
|
|
|
|
holder.Health -= component.UnviableDamage;
|
|
if (holder.DrawWarnings)
|
|
holder.UpdateSpriteAfterUpdate = true;
|
|
}
|
|
}
|