diff --git a/Content.Shared/Clothing/Components/ClothingComponent.cs b/Content.Shared/Clothing/Components/ClothingComponent.cs
index 260af210e0..ff1d422189 100644
--- a/Content.Shared/Clothing/Components/ClothingComponent.cs
+++ b/Content.Shared/Clothing/Components/ClothingComponent.cs
@@ -11,12 +11,11 @@ namespace Content.Shared.Clothing.Components;
///
/// This handles entities which can be equipped.
///
-[NetworkedComponent]
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(ClothingSystem), typeof(InventorySystem))]
public sealed partial class ClothingComponent : Component
{
- [DataField("clothingVisuals")]
+ [DataField]
public Dictionary> ClothingVisuals = new();
///
@@ -25,8 +24,7 @@ public sealed partial class ClothingComponent : Component
[DataField]
public string? MappedLayer;
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("quickEquip")]
+ [DataField]
public bool QuickEquip = true;
///
@@ -36,22 +34,18 @@ public sealed partial class ClothingComponent : Component
///
/// Note that this may be a combination of different slot flags, not a singular bit.
///
- [ViewVariables(VVAccess.ReadWrite)]
[DataField(required: true)]
[Access(typeof(ClothingSystem), typeof(InventorySystem), Other = AccessPermissions.ReadExecute)]
public SlotFlags Slots = SlotFlags.NONE;
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("equipSound")]
+ [DataField]
public SoundSpecifier? EquipSound;
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("unequipSound")]
+ [DataField]
public SoundSpecifier? UnequipSound;
[Access(typeof(ClothingSystem))]
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("equippedPrefix")]
+ [DataField, AutoNetworkedField]
public string? EquippedPrefix;
///
@@ -59,11 +53,9 @@ public sealed partial class ClothingComponent : Component
/// useful when prototyping INNERCLOTHING items into OUTERCLOTHING items without duplicating/modifying RSIs etc.
///
[Access(typeof(ClothingSystem))]
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("equippedState")]
+ [DataField, AutoNetworkedField]
public string? EquippedState;
- [ViewVariables(VVAccess.ReadWrite)]
[DataField("sprite")]
public string? RsiPath;
@@ -72,7 +64,7 @@ public sealed partial class ClothingComponent : Component
/// Note that this being non-null does not mean the clothing is considered "worn" or "equipped" unless the slot
/// satisfies the flags.
///
- [DataField]
+ [DataField, AutoNetworkedField]
public string? InSlot;
// TODO CLOTHING
// Maybe keep this null unless its in a valid slot?
@@ -82,16 +74,16 @@ public sealed partial class ClothingComponent : Component
///
/// Slot flags of the slot the clothing is currently in. See also .
///
- [DataField]
+ [DataField, AutoNetworkedField]
public SlotFlags? InSlotFlag;
// TODO CLOTHING
// Maybe keep this null unless its in a valid slot?
// And when doing this, combine InSlot and InSlotFlag, as it'd be a breaking change for downstreams anyway
- [DataField, ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public TimeSpan EquipDelay = TimeSpan.Zero;
- [DataField, ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public TimeSpan UnequipDelay = TimeSpan.Zero;
///
@@ -102,17 +94,6 @@ public sealed partial class ClothingComponent : Component
public TimeSpan StripDelay = TimeSpan.Zero;
}
-[Serializable, NetSerializable]
-public sealed class ClothingComponentState : ComponentState
-{
- public string? EquippedPrefix;
-
- public ClothingComponentState(string? equippedPrefix)
- {
- EquippedPrefix = equippedPrefix;
- }
-}
-
public enum ClothingMask : byte
{
NoMask = 0,
diff --git a/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs
index 10417045ff..6ebaa94e2e 100644
--- a/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs
+++ b/Content.Shared/Clothing/EntitySystems/ClothingSystem.cs
@@ -21,8 +21,7 @@ public abstract class ClothingSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent(OnUseInHand);
- SubscribeLocalEvent(OnGetState);
- SubscribeLocalEvent(OnHandleState);
+ SubscribeLocalEvent(AfterAutoHandleState);
SubscribeLocalEvent(OnGotEquipped);
SubscribeLocalEvent(OnGotUnequipped);
@@ -84,6 +83,7 @@ public abstract class ClothingSystem : EntitySystem
{
component.InSlot = args.Slot;
component.InSlotFlag = args.SlotFlags;
+ Dirty(uid, component);
if ((component.Slots & args.SlotFlags) == SlotFlags.NONE)
return;
@@ -108,19 +108,12 @@ public abstract class ClothingSystem : EntitySystem
component.InSlot = null;
component.InSlotFlag = null;
+ Dirty(uid, component);
}
- private void OnGetState(EntityUid uid, ClothingComponent component, ref ComponentGetState args)
+ private void AfterAutoHandleState(Entity ent, ref AfterAutoHandleStateEvent args)
{
- args.State = new ClothingComponentState(component.EquippedPrefix);
- }
-
- private void OnHandleState(EntityUid uid, ClothingComponent component, ref ComponentHandleState args)
- {
- if (args.Current is not ClothingComponentState state)
- return;
-
- SetEquippedPrefix(uid, state.EquippedPrefix, component);
+ _itemSys.VisualsChanged(ent.Owner);
}
private void OnEquipDoAfter(Entity ent, ref ClothingEquipDoAfterEvent args)
diff --git a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs
index 4f89b111bd..30e00faf0a 100644
--- a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs
+++ b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs
@@ -75,13 +75,13 @@ public sealed class MaskSystem : EntitySystem
private void ToggleMaskComponents(EntityUid uid, MaskComponent mask, EntityUid wearer, string? equippedPrefix = null, bool isEquip = false)
{
Dirty(uid, mask);
- if (mask.ToggleActionEntity is {} action)
+ if (mask.ToggleActionEntity is { } action)
_actionSystem.SetToggled(action, mask.IsToggled);
- var maskEv = new ItemMaskToggledEvent((wearer, mask), wearer);
+ var maskEv = new ItemMaskToggledEvent((uid, mask), wearer);
RaiseLocalEvent(uid, ref maskEv);
- var wearerEv = new WearerMaskToggledEvent((wearer, mask));
+ var wearerEv = new WearerMaskToggledEvent((uid, mask));
RaiseLocalEvent(wearer, ref wearerEv);
}