Remove inventory component references (#15249)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Client.Inventory;
|
||||
using Content.Client.Humanoid;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.Clothing.EntitySystems;
|
||||
@@ -53,12 +52,12 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
|
||||
SubscribeLocalEvent<ClothingComponent, GetEquipmentVisualsEvent>(OnGetVisuals);
|
||||
|
||||
SubscribeLocalEvent<ClientInventoryComponent, VisualsChangedEvent>(OnVisualsChanged);
|
||||
SubscribeLocalEvent<InventoryComponent, VisualsChangedEvent>(OnVisualsChanged);
|
||||
SubscribeLocalEvent<SpriteComponent, DidUnequipEvent>(OnDidUnequip);
|
||||
SubscribeLocalEvent<ClientInventoryComponent, AppearanceChangeEvent>(OnAppearanceUpdate);
|
||||
SubscribeLocalEvent<InventoryComponent, AppearanceChangeEvent>(OnAppearanceUpdate);
|
||||
}
|
||||
|
||||
private void OnAppearanceUpdate(EntityUid uid, ClientInventoryComponent component, ref AppearanceChangeEvent args)
|
||||
private void OnAppearanceUpdate(EntityUid uid, InventoryComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
// May need to update jumpsuit stencils if the sex changed. Also required to properly set the stencil on init
|
||||
// when sex is first loaded from the profile.
|
||||
@@ -85,7 +84,7 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
|
||||
private void OnGetVisuals(EntityUid uid, ClothingComponent item, GetEquipmentVisualsEvent args)
|
||||
{
|
||||
if (!TryComp(args.Equipee, out ClientInventoryComponent? inventory))
|
||||
if (!TryComp(args.Equipee, out InventoryComponent? inventory))
|
||||
return;
|
||||
|
||||
List<PrototypeLayerData>? layers = null;
|
||||
@@ -170,7 +169,7 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnVisualsChanged(EntityUid uid, ClientInventoryComponent component, VisualsChangedEvent args)
|
||||
private void OnVisualsChanged(EntityUid uid, InventoryComponent component, VisualsChangedEvent args)
|
||||
{
|
||||
if (!TryComp(args.Item, out ClothingComponent? clothing) || clothing.InSlot == null)
|
||||
return;
|
||||
@@ -180,22 +179,22 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
|
||||
private void OnDidUnequip(EntityUid uid, SpriteComponent component, DidUnequipEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out ClientInventoryComponent? inventory) || !TryComp(uid, out SpriteComponent? sprite))
|
||||
if (!TryComp(uid, out InventoryComponent? inventory) || !TryComp(uid, out InventorySlotsComponent? inventorySlots))
|
||||
return;
|
||||
|
||||
if (!inventory.VisualLayerKeys.TryGetValue(args.Slot, out var revealedLayers))
|
||||
if (!inventorySlots.VisualLayerKeys.TryGetValue(args.Slot, out var revealedLayers))
|
||||
return;
|
||||
|
||||
// Remove old layers. We could also just set them to invisible, but as items may add arbitrary layers, this
|
||||
// may eventually bloat the player with lots of invisible layers.
|
||||
foreach (var layer in revealedLayers)
|
||||
{
|
||||
sprite.RemoveLayer(layer);
|
||||
component.RemoveLayer(layer);
|
||||
}
|
||||
revealedLayers.Clear();
|
||||
}
|
||||
|
||||
public void InitClothing(EntityUid uid, ClientInventoryComponent? component = null, SpriteComponent? sprite = null)
|
||||
public void InitClothing(EntityUid uid, InventoryComponent? component = null, SpriteComponent? sprite = null)
|
||||
{
|
||||
if (!Resolve(uid, ref sprite, ref component) || !_inventorySystem.TryGetSlots(uid, out var slots, component))
|
||||
return;
|
||||
@@ -217,10 +216,14 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
}
|
||||
|
||||
private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot,
|
||||
ClientInventoryComponent? inventory = null, SpriteComponent? sprite = null, ClothingComponent? clothingComponent = null)
|
||||
InventoryComponent? inventory = null, SpriteComponent? sprite = null, ClothingComponent? clothingComponent = null,
|
||||
InventorySlotsComponent? inventorySlots = null)
|
||||
{
|
||||
if(!Resolve(equipee, ref inventory, ref sprite) || !Resolve(equipment, ref clothingComponent, false))
|
||||
if (!Resolve(equipee, ref inventory, ref sprite, ref inventorySlots) ||
|
||||
!Resolve(equipment, ref clothingComponent, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot == "jumpsuit" && sprite.LayerMapTryGet(HumanoidVisualLayers.StencilMask, out var suitLayer))
|
||||
{
|
||||
@@ -243,7 +246,7 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
|
||||
// Remove old layers. We could also just set them to invisible, but as items may add arbitrary layers, this
|
||||
// may eventually bloat the player with lots of invisible layers.
|
||||
if (inventory.VisualLayerKeys.TryGetValue(slot, out var revealedLayers))
|
||||
if (inventorySlots.VisualLayerKeys.TryGetValue(slot, out var revealedLayers))
|
||||
{
|
||||
foreach (var key in revealedLayers)
|
||||
{
|
||||
@@ -254,11 +257,11 @@ public sealed class ClientClothingSystem : ClothingSystem
|
||||
else
|
||||
{
|
||||
revealedLayers = new();
|
||||
inventory.VisualLayerKeys[slot] = revealedLayers;
|
||||
inventorySlots.VisualLayerKeys[slot] = revealedLayers;
|
||||
}
|
||||
|
||||
var ev = new GetEquipmentVisualsEvent(equipee, slot);
|
||||
RaiseLocalEvent(equipment, ev, false);
|
||||
RaiseLocalEvent(equipment, ev);
|
||||
|
||||
if (ev.Layers.Count == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user