diff --git a/Content.Client/Botany/PotencyVisualsComponent.cs b/Content.Client/Botany/PotencyVisualsComponent.cs new file mode 100644 index 0000000000..19f4f2abb9 --- /dev/null +++ b/Content.Client/Botany/PotencyVisualsComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Client.Botany; + +[RegisterComponent] +public sealed class PotencyVisualsComponent : Component +{ + [DataField("minimumScale")] + public float MinimumScale = 0.5f; + + [DataField("maximumScale")] + public float MaximumScale = 1.5f; +} diff --git a/Content.Client/Botany/PotencyVisualsSystem.cs b/Content.Client/Botany/PotencyVisualsSystem.cs new file mode 100644 index 0000000000..187a2d3005 --- /dev/null +++ b/Content.Client/Botany/PotencyVisualsSystem.cs @@ -0,0 +1,21 @@ +using Content.Shared.Botany; +using Robust.Client.GameObjects; + +namespace Content.Client.Botany; + +public sealed class PotencyVisualsSystem : VisualizerSystem +{ + protected override void OnAppearanceChange(EntityUid uid, PotencyVisualsComponent component, ref AppearanceChangeEvent args) + { + base.OnAppearanceChange(uid, component, ref args); + + if (!TryComp(uid, out var sprite)) + return; + + if (args.Component.TryGetData(ProduceVisuals.Potency, out float potency)) + { + var scale = MathHelper.Lerp(component.MinimumScale, component.MaximumScale, potency / 100); + sprite.Scale = new Vector2(scale, scale); + } + } +} diff --git a/Content.Server/Botany/Systems/BotanySystem.Seed.cs b/Content.Server/Botany/Systems/BotanySystem.Seed.cs index b4564c1c0a..21d55bb661 100644 --- a/Content.Server/Botany/Systems/BotanySystem.Seed.cs +++ b/Content.Server/Botany/Systems/BotanySystem.Seed.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Content.Server.Botany.Components; using Content.Server.Kitchen.Components; +using Content.Shared.Botany; using Content.Shared.Examine; using Content.Shared.Random.Helpers; using Content.Shared.Tag; @@ -124,6 +125,11 @@ public sealed partial class BotanySystem produce.SeedName = proto.ID; ProduceGrown(entity, produce); + if (TryComp(entity, out var appearance)) + { + appearance.SetData(ProduceVisuals.Potency, proto.Potency); + } + if (proto.Mysterious) { var metaData = MetaData(entity); diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index 16c1ebbcbd..e70b305c39 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -17,7 +17,8 @@ namespace Content.Server.Entry "ClientEntitySpawner", "CharacterInfo", "ItemCabinetVisuals", - "HandheldGPS" + "HandheldGPS", + "PotencyVisuals" }; } } diff --git a/Content.Shared/Botany/ProduceVisuals.cs b/Content.Shared/Botany/ProduceVisuals.cs new file mode 100644 index 0000000000..c55ab8114e --- /dev/null +++ b/Content.Shared/Botany/ProduceVisuals.cs @@ -0,0 +1,9 @@ +using Robust.Shared.Serialization; + +namespace Content.Shared.Botany; + +[Serializable, NetSerializable] +public enum ProduceVisuals : byte +{ + Potency +} diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml index fe67fd8232..e7cf0dd543 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml @@ -10,6 +10,8 @@ netsync: false state: produce - type: Produce + - type: PotencyVisuals + - type: Appearance - type: Extractable grindableSolutionName: food @@ -25,6 +27,8 @@ netsync: false state: produce - type: Produce + - type: PotencyVisuals + - type: Appearance - type: Extractable grindableSolutionName: food