Add "fill levels" to spear in-hand/wielded/equipped sprites (#28865)
* Add fill level sprite support for equipped items * Add fill sprites for held/equipped spears
@@ -2,6 +2,8 @@ using Content.Client.Items.Systems;
|
|||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Components;
|
using Content.Shared.Chemistry.Components;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
|
using Content.Shared.Clothing;
|
||||||
|
using Content.Shared.Clothing.Components;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Rounding;
|
using Content.Shared.Rounding;
|
||||||
@@ -20,6 +22,7 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<SolutionContainerVisualsComponent, MapInitEvent>(OnMapInit);
|
SubscribeLocalEvent<SolutionContainerVisualsComponent, MapInitEvent>(OnMapInit);
|
||||||
SubscribeLocalEvent<SolutionContainerVisualsComponent, GetInhandVisualsEvent>(OnGetHeldVisuals);
|
SubscribeLocalEvent<SolutionContainerVisualsComponent, GetInhandVisualsEvent>(OnGetHeldVisuals);
|
||||||
|
SubscribeLocalEvent<SolutionContainerVisualsComponent, GetEquipmentVisualsEvent>(OnGetClothingVisuals);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, SolutionContainerVisualsComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, SolutionContainerVisualsComponent component, MapInitEvent args)
|
||||||
@@ -174,4 +177,41 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
|
|||||||
args.Layers.Add((key, layer));
|
args.Layers.Add((key, layer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGetClothingVisuals(Entity<SolutionContainerVisualsComponent> ent, ref GetEquipmentVisualsEvent args)
|
||||||
|
{
|
||||||
|
if (ent.Comp.EquippedFillBaseName == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<AppearanceComponent>(ent, out var appearance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<ClothingComponent>(ent, out var clothing))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!AppearanceSystem.TryGetData<float>(ent, SolutionContainerVisuals.FillFraction, out var fraction, appearance))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var closestFillSprite = ContentHelpers.RoundToLevels(fraction, 1, ent.Comp.EquippedMaxFillLevels + 1);
|
||||||
|
|
||||||
|
if (closestFillSprite > 0)
|
||||||
|
{
|
||||||
|
var layer = new PrototypeLayerData();
|
||||||
|
|
||||||
|
var equippedPrefix = clothing.EquippedPrefix == null ? $"equipped-{args.Slot}" : $" {clothing.EquippedPrefix}-equipped-{args.Slot}";
|
||||||
|
var key = equippedPrefix + ent.Comp.EquippedFillBaseName + closestFillSprite;
|
||||||
|
|
||||||
|
// Make sure the sprite state is valid so we don't show a big red error message
|
||||||
|
// This saves us from having to make fill level sprites for every possible slot the item could be in (including pockets).
|
||||||
|
if (!TryComp<SpriteComponent>(ent, out var sprite) || sprite.BaseRSI == null || !sprite.BaseRSI.TryGetState(key, out _))
|
||||||
|
return;
|
||||||
|
|
||||||
|
layer.State = key;
|
||||||
|
|
||||||
|
if (ent.Comp.ChangeColor && AppearanceSystem.TryGetData<Color>(ent, SolutionContainerVisuals.Color, out var color, appearance))
|
||||||
|
layer.Color = color;
|
||||||
|
|
||||||
|
args.Layers.Add((key, layer));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,5 +53,17 @@ namespace Content.Shared.Chemistry.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField]
|
[DataField]
|
||||||
public int InHandsMaxFillLevels = 0;
|
public int InHandsMaxFillLevels = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional equipped visuals to show someone is wearing a something with a filled container.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public string? EquippedFillBaseName = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A separate max fill levels for equipped items (to reduce number of sprites needed)
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public int EquippedMaxFillLevels = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,11 @@
|
|||||||
- type: SolutionContainerVisuals
|
- type: SolutionContainerVisuals
|
||||||
maxFillLevels: 1
|
maxFillLevels: 1
|
||||||
fillBaseName: spear
|
fillBaseName: spear
|
||||||
|
inHandsFillBaseName: -fill-
|
||||||
|
inHandsMaxFillLevels: 1
|
||||||
|
equippedFillBaseName: -fill-
|
||||||
|
equippedMaxFillLevels: 1
|
||||||
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: reinforced spear
|
name: reinforced spear
|
||||||
|
|||||||
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 198 B |
@@ -17,25 +17,49 @@
|
|||||||
"name": "inhand-left",
|
"name": "inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-left",
|
"name": "wielded-inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-right",
|
"name": "wielded-inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-back-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-SUITSTORAGE",
|
"name": "equipped-SUITSTORAGE",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-suitstorage-fill-1",
|
||||||
|
"directions": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 198 B |
@@ -17,25 +17,49 @@
|
|||||||
"name": "inhand-left",
|
"name": "inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-left",
|
"name": "wielded-inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-right",
|
"name": "wielded-inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-back-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-SUITSTORAGE",
|
"name": "equipped-SUITSTORAGE",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-suitstorage-fill-1",
|
||||||
|
"directions": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 198 B |
@@ -17,25 +17,49 @@
|
|||||||
"name": "inhand-left",
|
"name": "inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-left",
|
"name": "wielded-inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-right",
|
"name": "wielded-inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-back-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-SUITSTORAGE",
|
"name": "equipped-SUITSTORAGE",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-suitstorage-fill-1",
|
||||||
|
"directions": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 198 B |
@@ -17,25 +17,49 @@
|
|||||||
"name": "inhand-left",
|
"name": "inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-left",
|
"name": "wielded-inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-right",
|
"name": "wielded-inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-back-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-SUITSTORAGE",
|
"name": "equipped-SUITSTORAGE",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-suitstorage-fill-1",
|
||||||
|
"directions": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 207 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 213 B |
|
After Width: | Height: | Size: 201 B |
|
After Width: | Height: | Size: 198 B |
@@ -17,25 +17,49 @@
|
|||||||
"name": "inhand-left",
|
"name": "inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "inhand-right",
|
"name": "inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-left",
|
"name": "wielded-inhand-left",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-left-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "wielded-inhand-right",
|
"name": "wielded-inhand-right",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "wielded-inhand-right-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-BACKPACK",
|
"name": "equipped-BACKPACK",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-back-fill-1",
|
||||||
|
"directions": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "equipped-SUITSTORAGE",
|
"name": "equipped-SUITSTORAGE",
|
||||||
"directions": 4
|
"directions": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "equipped-suitstorage-fill-1",
|
||||||
|
"directions": 4
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 202 B |
|
After Width: | Height: | Size: 207 B |