Add inhand fill visuals (#24495)

* Add inhand fill visuals

* oops

* remove unused import
This commit is contained in:
themias
2024-01-28 20:38:06 -05:00
committed by GitHub
parent 5267d3c601
commit bd100344a2
65 changed files with 210 additions and 22 deletions

View File

@@ -1,6 +1,8 @@
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;
@@ -10,11 +12,13 @@ namespace Content.Client.Chemistry.Visualizers;
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)
@@ -111,6 +115,35 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
}
}
// 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));
}
}
}

View File

@@ -1,3 +1,4 @@
using Content.Shared.Hands.Components;
using Robust.Shared.Utility;
namespace Content.Shared.Chemistry.Components
@@ -40,5 +41,17 @@ 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;
}
}

View File

@@ -43,6 +43,8 @@
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: jug
inHandsMaxFillLevels: 5
inHandsFillBaseName: -fill-
- type: StaticPrice
price: 60
- type: Label

View File

@@ -27,6 +27,8 @@
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: vial-1-
inHandsMaxFillLevels: 4
inHandsFillBaseName: -fill-
- type: Drink
solution: beaker
- type: SolutionContainerManager

View File

@@ -158,6 +158,11 @@
solution: beaker
- type: StaticPrice
price: 10
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: beaker
inHandsMaxFillLevels: 3
inHandsFillBaseName: -fill-
- type: entity
name: cryoxadone beaker
@@ -200,6 +205,8 @@
- type: SolutionContainerVisuals
maxFillLevels: 6
fillBaseName: beakerlarge
inHandsMaxFillLevels: 4
inHandsFillBaseName: -fill-
- type: StaticPrice
price: 20
@@ -277,6 +284,8 @@
- type: SolutionContainerVisuals
maxFillLevels: 1
fillBaseName: dropper
inHandsMaxFillLevels: 1
inHandsFillBaseName: -fill-
- type: StaticPrice
price: 40
@@ -321,7 +330,6 @@
- type: Item
size: Tiny
sprite: Objects/Specific/Chemistry/syringe.rsi
heldPrefix: 0
- type: SolutionContainerManager
solutions:
injector:
@@ -338,6 +346,8 @@
- type: SolutionContainerVisuals
maxFillLevels: 2
fillBaseName: syringe
inHandsMaxFillLevels: 3
inHandsFillBaseName: -fill-
- type: Tag
tags:
- Syringe

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

View File

@@ -16,10 +16,34 @@
{
"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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View File

@@ -16,10 +16,42 @@
{
"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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

View File

@@ -20,9 +20,17 @@
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-left-fill-1",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "inhand-right-fill-1",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 418 B

View File

@@ -13,10 +13,50 @@
{
"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"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

View File

@@ -58,43 +58,35 @@
"name": "syringe2"
},
{
"name": "0-inhand-left",
"name": "inhand-left",
"directions": 4
},
{
"name": "0-inhand-right",
"name": "inhand-right",
"directions": 4
},
{
"name": "1-inhand-left",
"name": "inhand-left-fill-1",
"directions": 4
},
{
"name": "1-inhand-right",
"name": "inhand-right-fill-1",
"directions": 4
},
{
"name": "2-inhand-left",
"name": "inhand-left-fill-2",
"directions": 4
},
{
"name": "2-inhand-right",
"name": "inhand-right-fill-2",
"directions": 4
},
{
"name": "3-inhand-left",
"name": "inhand-left-fill-3",
"directions": 4
},
{
"name": "3-inhand-right",
"directions": 4
},
{
"name": "4-inhand-left",
"directions": 4
},
{
"name": "4-inhand-right",
"name": "inhand-right-fill-3",
"directions": 4
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

View File

@@ -13,10 +13,42 @@
{
"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"