mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using Content.Shared.Botany.Components;
|
|
using Content.Shared.Botany.Events;
|
|
using Content.Shared.Botany.Systems;
|
|
using Content.Shared.Botany.Traits.Components;
|
|
|
|
namespace Content.Shared.Botany.Traits.Systems;
|
|
|
|
/// <inheritdoc cref="PlantTraitKudzuComponent"/>
|
|
public sealed partial class PlantTraitKudzuSystem : EntitySystem
|
|
{
|
|
[Dependency] private PlantHolderSystem _plantHolder = default!;
|
|
[Dependency] private PlantTraySystem _plantTray = default!;
|
|
[Dependency] private SharedTransformSystem _transform = default!;
|
|
|
|
[Dependency] private EntityQuery<PlantTrayComponent> _trayQuery;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnPlantGrow(Entity<PlantTraitKudzuComponent> ent, ref PlantGrowEvent args)
|
|
{
|
|
var trayUid = args.Tray;
|
|
if (!_trayQuery.TryComp(trayUid, out var trayComp))
|
|
return;
|
|
|
|
if (trayComp is { WaterLevel: > 10, NutritionLevel: > 5 })
|
|
_plantTray.AdjustWeed(trayUid, ent.Comp.WeedGrowthAmount);
|
|
|
|
// Handle kudzu transformation.
|
|
if (trayComp.WeedLevel >= ent.Comp.WeedLevelThreshold)
|
|
{
|
|
PredictedSpawn(ent.Comp.KudzuPrototype, _transform.GetMapCoordinates(ent.Owner));
|
|
RemComp<PlantTraitKudzuComponent>(ent.Owner);
|
|
_plantHolder.KillPlant(ent.Owner);
|
|
}
|
|
}
|
|
}
|