diff --git a/Content.Client/Botany/Components/PlantHolderVisualsComponent.cs b/Content.Client/Botany/Components/PlantHolderVisualsComponent.cs new file mode 100644 index 0000000000..fd44c6ae2a --- /dev/null +++ b/Content.Client/Botany/Components/PlantHolderVisualsComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Client.Botany.Components; + +[RegisterComponent] +public sealed class PlantHolderVisualsComponent : Component +{ +} diff --git a/Content.Client/Botany/PotencyVisualsComponent.cs b/Content.Client/Botany/Components/PotencyVisualsComponent.cs similarity index 83% rename from Content.Client/Botany/PotencyVisualsComponent.cs rename to Content.Client/Botany/Components/PotencyVisualsComponent.cs index 19f4f2abb9..c39431884c 100644 --- a/Content.Client/Botany/PotencyVisualsComponent.cs +++ b/Content.Client/Botany/Components/PotencyVisualsComponent.cs @@ -1,4 +1,4 @@ -namespace Content.Client.Botany; +namespace Content.Client.Botany.Components; [RegisterComponent] public sealed class PotencyVisualsComponent : Component diff --git a/Content.Client/Botany/PlantHolderVisualizer.cs b/Content.Client/Botany/PlantHolderVisualizer.cs deleted file mode 100644 index 1994f64c9b..0000000000 --- a/Content.Client/Botany/PlantHolderVisualizer.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Content.Shared.Botany; -using JetBrains.Annotations; -using Robust.Client.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Utility; - -namespace Content.Client.Botany -{ - [UsedImplicitly] - public sealed class PlantHolderVisualizer : AppearanceVisualizer - { - public override void InitializeEntity(EntityUid entity) - { - base.InitializeEntity(entity); - - var sprite = IoCManager.Resolve().GetComponent(entity); - - sprite.LayerMapReserveBlank(PlantHolderLayers.Plant); - sprite.LayerMapReserveBlank(PlantHolderLayers.HealthLight); - sprite.LayerMapReserveBlank(PlantHolderLayers.WaterLight); - sprite.LayerMapReserveBlank(PlantHolderLayers.NutritionLight); - sprite.LayerMapReserveBlank(PlantHolderLayers.AlertLight); - sprite.LayerMapReserveBlank(PlantHolderLayers.HarvestLight); - - var hydroTools = new ResourcePath("Structures/Hydroponics/overlays.rsi"); - - sprite.LayerSetSprite(PlantHolderLayers.HealthLight, - new SpriteSpecifier.Rsi(hydroTools, "lowhealth3")); - sprite.LayerSetSprite(PlantHolderLayers.WaterLight, - new SpriteSpecifier.Rsi(hydroTools, "lowwater3")); - sprite.LayerSetSprite(PlantHolderLayers.NutritionLight, - new SpriteSpecifier.Rsi(hydroTools, "lownutri3")); - sprite.LayerSetSprite(PlantHolderLayers.AlertLight, - new SpriteSpecifier.Rsi(hydroTools, "alert3")); - sprite.LayerSetSprite(PlantHolderLayers.HarvestLight, - new SpriteSpecifier.Rsi(hydroTools, "harvest3")); - - // Let's make those invisible for now. - sprite.LayerSetVisible(PlantHolderLayers.Plant, false); - sprite.LayerSetVisible(PlantHolderLayers.HealthLight, false); - sprite.LayerSetVisible(PlantHolderLayers.WaterLight, false); - sprite.LayerSetVisible(PlantHolderLayers.NutritionLight, false); - sprite.LayerSetVisible(PlantHolderLayers.AlertLight, false); - sprite.LayerSetVisible(PlantHolderLayers.HarvestLight, false); - - // Pretty unshaded lights! - sprite.LayerSetShader(PlantHolderLayers.HealthLight, "unshaded"); - sprite.LayerSetShader(PlantHolderLayers.WaterLight, "unshaded"); - sprite.LayerSetShader(PlantHolderLayers.NutritionLight, "unshaded"); - sprite.LayerSetShader(PlantHolderLayers.AlertLight, "unshaded"); - sprite.LayerSetShader(PlantHolderLayers.HarvestLight, "unshaded"); - } - - public override void OnChangeData(AppearanceComponent component) - { - base.OnChangeData(component); - - var sprite = IoCManager.Resolve().GetComponent(component.Owner); - - if (component.TryGetData(PlantHolderVisuals.PlantRsi, out var rsi) - && component.TryGetData(PlantHolderVisuals.PlantState, out var state)) - { - var valid = !string.IsNullOrWhiteSpace(state); - - sprite.LayerSetVisible(PlantHolderLayers.Plant, valid); - - if(valid) - { - sprite.LayerSetRSI(PlantHolderLayers.Plant, rsi); - sprite.LayerSetState(PlantHolderLayers.Plant, state); - } - } - - if (component.TryGetData(PlantHolderVisuals.HealthLight, out var health)) - { - sprite.LayerSetVisible(PlantHolderLayers.HealthLight, health); - } - - if (component.TryGetData(PlantHolderVisuals.WaterLight, out var water)) - { - sprite.LayerSetVisible(PlantHolderLayers.WaterLight, water); - } - - if (component.TryGetData(PlantHolderVisuals.NutritionLight, out var nutrition)) - { - sprite.LayerSetVisible(PlantHolderLayers.NutritionLight, nutrition); - } - - if (component.TryGetData(PlantHolderVisuals.AlertLight, out var alert)) - { - sprite.LayerSetVisible(PlantHolderLayers.AlertLight, alert); - } - - if (component.TryGetData(PlantHolderVisuals.HarvestLight, out var harvest)) - { - sprite.LayerSetVisible(PlantHolderLayers.HarvestLight, harvest); - } - } - } - - public enum PlantHolderLayers : byte - { - Plant, - HealthLight, - WaterLight, - NutritionLight, - AlertLight, - HarvestLight, - } -} diff --git a/Content.Client/Botany/PlantHolderVisualizerSystem.cs b/Content.Client/Botany/PlantHolderVisualizerSystem.cs new file mode 100644 index 0000000000..b94ca28ddf --- /dev/null +++ b/Content.Client/Botany/PlantHolderVisualizerSystem.cs @@ -0,0 +1,54 @@ +using Content.Client.Botany.Components; +using Content.Shared.Botany; +using Robust.Client.GameObjects; +using Robust.Shared.Utility; + +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 (args.Component.TryGetData(PlantHolderVisuals.PlantRsi, out var rsi) + && args.Component.TryGetData(PlantHolderVisuals.PlantState, out var state)) + { + 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, +} diff --git a/Content.Client/Botany/PotencyVisualsSystem.cs b/Content.Client/Botany/PotencyVisualsSystem.cs index f107a4b690..f13c8de600 100644 --- a/Content.Client/Botany/PotencyVisualsSystem.cs +++ b/Content.Client/Botany/PotencyVisualsSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Botany; +using Content.Client.Botany.Components; using Robust.Client.GameObjects; namespace Content.Client.Botany; diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index 4065ffe7c8..07bcb7563c 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -1,4 +1,4 @@ - + diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index 2fe6a3918b..049f538fe2 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -38,6 +38,7 @@ namespace Content.Server.Entry "PipeColorVisuals", "FireVisuals", "CrematoriumVisuals", + "PlantHolderVisuals", }; } } diff --git a/Resources/Prototypes/Entities/Structures/hydro_tray.yml b/Resources/Prototypes/Entities/Structures/hydro_tray.yml index 756d53fa70..acc70706c8 100644 --- a/Resources/Prototypes/Entities/Structures/hydro_tray.yml +++ b/Resources/Prototypes/Entities/Structures/hydro_tray.yml @@ -18,8 +18,52 @@ - type: Anchorable - type: Pullable - type: Sprite - sprite: Structures/Hydroponics/containers.rsi - state: hydrotray3 + layers: + - sprite: Structures/Hydroponics/containers.rsi + state: hydrotray3 + - sprite: Structures/Hydroponics/overlays.rsi + state: lowhealth3 + map: [ "health_alert" ] + visible: false + - sprite: Structures/Hydroponics/overlays.rsi + state: lowwater3 + map: [ "water_alert" ] + visible: false + - sprite: Structures/Hydroponics/overlays.rsi + state: lownutri3 + map: [ "nutri_alert" ] + visible: false + - sprite: Structures/Hydroponics/overlays.rsi + state: alert3 + map: [ "undefined_alert" ] + visible: false + - sprite: Structures/Hydroponics/overlays.rsi + state: harvest3 + map: [ "harvest_alert" ] + visible: false + - type: Appearance + - type: GenericVisualizer + visuals: + enum.PlantHolderVisuals.HealthLight: + health_alert: + True: { visible: true } + False: { visible: false } + enum.PlantHolderVisuals.WaterLight: + water_alert: + True: { visible: true } + False: { visible: false } + enum.PlantHolderVisuals.NutritionLight: + nutri_alert: + True: { visible: true } + False: { visible: false } + enum.PlantHolderVisuals.AlertLight: + undefined_alert: + True: { visible: true } + False: { visible: false } + enum.PlantHolderVisuals.HarvestLight: + harvest_alert: + True: { visible: true } + False: { visible: false } - type: PlantHolder drawWarnings: true - type: Construction diff --git a/Resources/Prototypes/Entities/Structures/soil.yml b/Resources/Prototypes/Entities/Structures/soil.yml index bfa8385b27..861d623bdb 100644 --- a/Resources/Prototypes/Entities/Structures/soil.yml +++ b/Resources/Prototypes/Entities/Structures/soil.yml @@ -53,5 +53,4 @@ - !type:AddToSolutionReaction solution: soil - type: Appearance - visuals: - - type: PlantHolderVisualizer + - type: PlantHolderVisuals