Remove server/client clothing components. (#11981)

This commit is contained in:
Leon Friedrich
2022-10-23 11:30:37 +13:00
committed by GitHub
parent 4a3df4f85a
commit 7d276d1101
29 changed files with 110 additions and 131 deletions

View File

@@ -10,8 +10,9 @@ namespace Content.Shared.Clothing.Components;
/// This handles entities which can be equipped.
/// </summary>
[NetworkedComponent]
[RegisterComponent]
[Access(typeof(ClothingSystem), typeof(InventorySystem))]
public abstract class SharedClothingComponent : Component
public sealed class ClothingComponent : Component
{
[DataField("clothingVisuals")]
[Access(typeof(ClothingSystem), typeof(InventorySystem), Other = AccessPermissions.ReadExecute)] // TODO remove execute permissions.
@@ -46,6 +47,8 @@ public abstract class SharedClothingComponent : Component
[ViewVariables(VVAccess.ReadWrite)]
[DataField("femaleMask")]
public FemaleClothingMask FemaleMask = FemaleClothingMask.UniformFull;
public string? InSlot;
}
[Serializable, NetSerializable]

View File

@@ -1,11 +1,12 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Robust.Shared.GameStates;
namespace Content.Shared.Clothing.EntitySystems;
public sealed class ClothingSystem : EntitySystem
public abstract class ClothingSystem : EntitySystem
{
[Dependency] private readonly SharedItemSystem _itemSys = default!;
@@ -13,16 +14,28 @@ public sealed class ClothingSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<SharedClothingComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<SharedClothingComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<ClothingComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<ClothingComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<ClothingComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<ClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
}
private void OnGetState(EntityUid uid, SharedClothingComponent component, ref ComponentGetState args)
protected virtual void OnGotEquipped(EntityUid uid, ClothingComponent component, GotEquippedEvent args)
{
component.InSlot = args.Slot;
}
protected virtual void OnGotUnequipped(EntityUid uid, ClothingComponent component, GotUnequippedEvent args)
{
component.InSlot = null;
}
private void OnGetState(EntityUid uid, ClothingComponent component, ref ComponentGetState args)
{
args.State = new ClothingComponentState(component.EquippedPrefix);
}
private void OnHandleState(EntityUid uid, SharedClothingComponent component, ref ComponentHandleState args)
private void OnHandleState(EntityUid uid, ClothingComponent component, ref ComponentHandleState args)
{
if (args.Current is ClothingComponentState state)
SetEquippedPrefix(uid, state.EquippedPrefix, component);
@@ -30,7 +43,7 @@ public sealed class ClothingSystem : EntitySystem
#region Public API
public void SetEquippedPrefix(EntityUid uid, string? prefix, SharedClothingComponent? clothing = null)
public void SetEquippedPrefix(EntityUid uid, string? prefix, ClothingComponent? clothing = null)
{
if (!Resolve(uid, ref clothing, false))
return;
@@ -43,7 +56,7 @@ public sealed class ClothingSystem : EntitySystem
Dirty(clothing);
}
public void SetSlots(EntityUid uid, SlotFlags slots, SharedClothingComponent? clothing = null)
public void SetSlots(EntityUid uid, SlotFlags slots, ClothingComponent? clothing = null)
{
if (!Resolve(uid, ref clothing))
return;
@@ -55,7 +68,7 @@ public sealed class ClothingSystem : EntitySystem
/// <summary>
/// Copy all clothing specific visuals from another item.
/// </summary>
public void CopyVisuals(EntityUid uid, SharedClothingComponent otherClothing, SharedClothingComponent? clothing = null)
public void CopyVisuals(EntityUid uid, ClothingComponent otherClothing, ClothingComponent? clothing = null)
{
if (!Resolve(uid, ref clothing))
return;

View File

@@ -39,8 +39,8 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
}
// clothing sprite logic
if (TryComp(uid, out SharedClothingComponent? clothing) &&
proto.TryGetComponent("Clothing", out SharedClothingComponent? otherClothing))
if (TryComp(uid, out ClothingComponent? clothing) &&
proto.TryGetComponent("Clothing", out ClothingComponent? otherClothing))
{
_clothingSystem.CopyVisuals(uid, otherClothing, clothing);
}
@@ -62,7 +62,7 @@ public abstract class SharedChameleonClothingSystem : EntitySystem
return false;
// check if it's valid clothing
if (!proto.TryGetComponent("Clothing", out SharedClothingComponent? clothing))
if (!proto.TryGetComponent("Clothing", out ClothingComponent? clothing))
return false;
if (!clothing.Slots.HasFlag(chameleonSlot))
return false;