blinding networking (#12937)
This commit is contained in:
@@ -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
|
||||
/// </description>
|
||||
public bool GraceFrame = false;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BlindableComponentState : ComponentState
|
||||
{
|
||||
public readonly int Sources;
|
||||
|
||||
public BlindableComponentState(int sources)
|
||||
{
|
||||
Sources = sources;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ namespace Content.Shared.Eye.Blinding
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BlindableComponent, ComponentGetState>(OnGetBlindableState);
|
||||
SubscribeLocalEvent<BlindableComponent, ComponentHandleState>(OnHandleBlindableState);
|
||||
|
||||
SubscribeLocalEvent<BlindfoldComponent, GotEquippedEvent>(OnEquipped);
|
||||
SubscribeLocalEvent<BlindfoldComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
|
||||
@@ -28,6 +32,19 @@ namespace Content.Shared.Eye.Blinding
|
||||
SubscribeLocalEvent<BlindableComponent, RejuvenateEvent>(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<ClothingComponent>(uid, out var clothing) || clothing.Slots == SlotFlags.PREVENTEQUIP) // we live in a society
|
||||
|
||||
Reference in New Issue
Block a user