diff --git a/Content.Shared/Eye/Blinding/BlindableComponent.cs b/Content.Shared/Eye/Blinding/BlindableComponent.cs index a78270b8ad..8cb34bc4b3 100644 --- a/Content.Shared/Eye/Blinding/BlindableComponent.cs +++ b/Content.Shared/Eye/Blinding/BlindableComponent.cs @@ -1,4 +1,5 @@ using Robust.Shared.GameStates; +using Robust.Shared.Serialization; namespace Content.Shared.Eye.Blinding { @@ -41,4 +42,15 @@ namespace Content.Shared.Eye.Blinding /// public bool GraceFrame = false; } + + [Serializable, NetSerializable] + public sealed class BlindableComponentState : ComponentState + { + public readonly int Sources; + + public BlindableComponentState(int sources) + { + Sources = sources; + } + } } diff --git a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs index fbbc76967b..5d75bc9898 100644 --- a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs +++ b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs @@ -14,6 +14,10 @@ namespace Content.Shared.Eye.Blinding public override void Initialize() { base.Initialize(); + + SubscribeLocalEvent(OnGetBlindableState); + SubscribeLocalEvent(OnHandleBlindableState); + SubscribeLocalEvent(OnEquipped); SubscribeLocalEvent(OnUnequipped); @@ -28,6 +32,19 @@ namespace Content.Shared.Eye.Blinding SubscribeLocalEvent(OnRejuvenate); } + private void OnGetBlindableState(EntityUid uid, BlindableComponent component, ref ComponentGetState args) + { + args.State = new BlindableComponentState(component.Sources); + } + + private void OnHandleBlindableState(EntityUid uid, BlindableComponent component, ref ComponentHandleState args) + { + if (args.Current is not BlindableComponentState cast) + return; + + component.Sources = cast.Sources; + } + private void OnEquipped(EntityUid uid, BlindfoldComponent component, GotEquippedEvent args) { if (!TryComp(uid, out var clothing) || clothing.Slots == SlotFlags.PREVENTEQUIP) // we live in a society