+using Content.Client.Items.Systems;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
+using Content.Shared.Hands;
using Content.Shared.Rounding;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionContainerVisualsComponent>
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
+ [Dependency] private readonly ItemSystem _itemSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SolutionContainerVisualsComponent, MapInitEvent>(OnMapInit);
+ SubscribeLocalEvent<SolutionContainerVisualsComponent, GetInhandVisualsEvent>(OnGetHeldVisuals);
}
private void OnMapInit(EntityUid uid, SolutionContainerVisualsComponent component, MapInitEvent args)
}
}
+ // in-hand visuals
+ _itemSystem.VisualsChanged(uid);
+ }
+
+ private void OnGetHeldVisuals(EntityUid uid, SolutionContainerVisualsComponent component, GetInhandVisualsEvent args)
+ {
+ if (component.InHandsFillBaseName == null)
+ return;
+
+ if (!TryComp(uid, out AppearanceComponent? appearance))
+ return;
+
+ if (!AppearanceSystem.TryGetData<float>(uid, SolutionContainerVisuals.FillFraction, out var fraction, appearance))
+ return;
+ int closestFillSprite = ContentHelpers.RoundToLevels(fraction, 1, component.InHandsMaxFillLevels + 1);
+
+ if (closestFillSprite > 0)
+ {
+ var layer = new PrototypeLayerData();
+
+ var key = "inhand-" + args.Location.ToString().ToLowerInvariant() + component.InHandsFillBaseName + closestFillSprite;
+
+ layer.State = key;
+
+ if (component.ChangeColor && AppearanceSystem.TryGetData<Color>(uid, SolutionContainerVisuals.Color, out var color, appearance))
+ layer.Color = color;
+
+ args.Layers.Add((key, layer));
+ }
}
}
+using Content.Shared.Hands.Components;
using Robust.Shared.Utility;
namespace Content.Shared.Chemistry.Components
[DataField]
public string InitialDescription = string.Empty;
+
+ /// <summary>
+ /// Optional in-hand visuals to to show someone is holding a filled beaker/jug/etc.
+ /// </summary>
+ [DataField]
+ public string? InHandsFillBaseName = null;
+
+ /// <summary>
+ /// A separate max fill levels for in-hands (to reduce number of sprites needed)
+ /// </summary>
+ [DataField]
+ public int InHandsMaxFillLevels = 0;
}
}
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: jug
+ inHandsMaxFillLevels: 5
+ inHandsFillBaseName: -fill-
- type: StaticPrice
price: 60
- type: Label
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: vial-1-
+ inHandsMaxFillLevels: 4
+ inHandsFillBaseName: -fill-
- type: Drink
solution: beaker
- type: SolutionContainerManager
solution: beaker
- type: StaticPrice
price: 10
+ - type: SolutionContainerVisuals
+ maxFillLevels: 6
+ fillBaseName: beaker
+ inHandsMaxFillLevels: 3
+ inHandsFillBaseName: -fill-
- type: entity
name: cryoxadone beaker
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: beakerlarge
+ inHandsMaxFillLevels: 4
+ inHandsFillBaseName: -fill-
- type: StaticPrice
price: 20
- type: SolutionContainerVisuals
maxFillLevels: 1
fillBaseName: dropper
+ inHandsMaxFillLevels: 1
+ inHandsFillBaseName: -fill-
- type: StaticPrice
price: 40
- type: Item
size: Tiny
sprite: Objects/Specific/Chemistry/syringe.rsi
- heldPrefix: 0
- type: SolutionContainerManager
solutions:
injector:
- type: SolutionContainerVisuals
maxFillLevels: 2
fillBaseName: syringe
+ inHandsMaxFillLevels: 3
+ inHandsFillBaseName: -fill-
- type: Tag
tags:
- Syringe
{
"name": "inhand-left",
"directions": 4
+ },
+ {
+ "name": "inhand-left-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-3",
+ "directions": 4
},
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "inhand-right-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-3",
+ "directions": 4
},
{
"name": "beaker1"
{
"name": "inhand-left",
"directions": 4
+ },
+ {
+ "name": "inhand-left-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-4",
+ "directions": 4
},
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "inhand-right-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-4",
+ "directions": 4
},
{
"name": "beakerlarge1"
"name": "inhand-left",
"directions": 4
},
+ {
+ "name": "inhand-left-fill-1",
+ "directions": 4
+ },
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "inhand-right-fill-1",
+ "directions": 4
}
]
}
{
"name": "inhand-left",
"directions": 4
+ },
+ {
+ "name": "inhand-left-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-4",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-5",
+ "directions": 4
},
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "inhand-right-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-4",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-5",
+ "directions": 4
},
{
"name": "jug1"
"name": "syringe2"
},
{
- "name": "0-inhand-left",
- "directions": 4
- },
- {
- "name": "0-inhand-right",
- "directions": 4
- },
- {
- "name": "1-inhand-left",
- "directions": 4
+ "name": "inhand-left",
+ "directions": 4
},
{
- "name": "1-inhand-right",
- "directions": 4
+ "name": "inhand-right",
+ "directions": 4
},
{
- "name": "2-inhand-left",
+ "name": "inhand-left-fill-1",
"directions": 4
},
{
- "name": "2-inhand-right",
+ "name": "inhand-right-fill-1",
"directions": 4
},
{
- "name": "3-inhand-left",
+ "name": "inhand-left-fill-2",
"directions": 4
},
{
- "name": "3-inhand-right",
+ "name": "inhand-right-fill-2",
"directions": 4
},
{
- "name": "4-inhand-left",
+ "name": "inhand-left-fill-3",
"directions": 4
},
{
- "name": "4-inhand-right",
+ "name": "inhand-right-fill-3",
"directions": 4
}
]
{
"name": "inhand-left",
"directions": 4
+ },
+ {
+ "name": "inhand-left-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-left-fill-4",
+ "directions": 4
},
{
"name": "inhand-right",
"directions": 4
+ },
+ {
+ "name": "inhand-right-fill-1",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-2",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-3",
+ "directions": 4
+ },
+ {
+ "name": "inhand-right-fill-4",
+ "directions": 4
},
{
"name": "vial-1"