using Content.Client.Botany.Components; using Content.Shared.Botany; using Robust.Client.GameObjects; namespace Content.Client.Botany; public sealed class PlantHolderVisualizerSystem : VisualizerSystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnComponentInit); } private void OnComponentInit(EntityUid uid, PlantHolderVisualsComponent component, ComponentInit args) { if (!TryComp(uid, out var sprite)) return; sprite.LayerMapReserveBlank(PlantHolderLayers.Plant); sprite.LayerSetVisible(PlantHolderLayers.Plant, false); } protected override void OnAppearanceChange(EntityUid uid, PlantHolderVisualsComponent component, ref AppearanceChangeEvent args) { if (args.Sprite == null) return; if (AppearanceSystem.TryGetData(uid, PlantHolderVisuals.PlantRsi, out var rsi, args.Component) && AppearanceSystem.TryGetData(uid, PlantHolderVisuals.PlantState, out var state, args.Component)) { var valid = !string.IsNullOrWhiteSpace(state); args.Sprite.LayerSetVisible(PlantHolderLayers.Plant, valid); if (valid) { args.Sprite.LayerSetRSI(PlantHolderLayers.Plant, rsi); args.Sprite.LayerSetState(PlantHolderLayers.Plant, state); } } } } public enum PlantHolderLayers : byte { Plant, HealthLight, WaterLight, NutritionLight, AlertLight, HarvestLight, }