Potency sprite scaling (#7100)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
11
Content.Client/Botany/PotencyVisualsComponent.cs
Normal file
11
Content.Client/Botany/PotencyVisualsComponent.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
21
Content.Client/Botany/PotencyVisualsSystem.cs
Normal file
21
Content.Client/Botany/PotencyVisualsSystem.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Content.Shared.Botany;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.Botany;
|
||||||
|
|
||||||
|
public sealed class PotencyVisualsSystem : VisualizerSystem<PotencyVisualsComponent>
|
||||||
|
{
|
||||||
|
protected override void OnAppearanceChange(EntityUid uid, PotencyVisualsComponent component, ref AppearanceChangeEvent args)
|
||||||
|
{
|
||||||
|
base.OnAppearanceChange(uid, component, ref args);
|
||||||
|
|
||||||
|
if (!TryComp<SpriteComponent>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Botany.Components;
|
using Content.Server.Botany.Components;
|
||||||
using Content.Server.Kitchen.Components;
|
using Content.Server.Kitchen.Components;
|
||||||
|
using Content.Shared.Botany;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Random.Helpers;
|
using Content.Shared.Random.Helpers;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
@@ -124,6 +125,11 @@ public sealed partial class BotanySystem
|
|||||||
produce.SeedName = proto.ID;
|
produce.SeedName = proto.ID;
|
||||||
ProduceGrown(entity, produce);
|
ProduceGrown(entity, produce);
|
||||||
|
|
||||||
|
if (TryComp<AppearanceComponent>(entity, out var appearance))
|
||||||
|
{
|
||||||
|
appearance.SetData(ProduceVisuals.Potency, proto.Potency);
|
||||||
|
}
|
||||||
|
|
||||||
if (proto.Mysterious)
|
if (proto.Mysterious)
|
||||||
{
|
{
|
||||||
var metaData = MetaData(entity);
|
var metaData = MetaData(entity);
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ namespace Content.Server.Entry
|
|||||||
"ClientEntitySpawner",
|
"ClientEntitySpawner",
|
||||||
"CharacterInfo",
|
"CharacterInfo",
|
||||||
"ItemCabinetVisuals",
|
"ItemCabinetVisuals",
|
||||||
"HandheldGPS"
|
"HandheldGPS",
|
||||||
|
"PotencyVisuals"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
Content.Shared/Botany/ProduceVisuals.cs
Normal file
9
Content.Shared/Botany/ProduceVisuals.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.Botany;
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum ProduceVisuals : byte
|
||||||
|
{
|
||||||
|
Potency
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
state: produce
|
state: produce
|
||||||
- type: Produce
|
- type: Produce
|
||||||
|
- type: PotencyVisuals
|
||||||
|
- type: Appearance
|
||||||
- type: Extractable
|
- type: Extractable
|
||||||
grindableSolutionName: food
|
grindableSolutionName: food
|
||||||
|
|
||||||
@@ -25,6 +27,8 @@
|
|||||||
netsync: false
|
netsync: false
|
||||||
state: produce
|
state: produce
|
||||||
- type: Produce
|
- type: Produce
|
||||||
|
- type: PotencyVisuals
|
||||||
|
- type: Appearance
|
||||||
- type: Extractable
|
- type: Extractable
|
||||||
grindableSolutionName: food
|
grindableSolutionName: food
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user