Fix blindfold round cleanup bug (#9821)
* Blindness public api * fix blinding round cleanup bug
This commit is contained in:
@@ -3,6 +3,14 @@ using Content.Shared.Eye.Blinding;
|
|||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Content.Shared.Administration.Events;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Network;
|
||||||
|
|
||||||
namespace Content.Client.Eye.Blinding;
|
namespace Content.Client.Eye.Blinding;
|
||||||
|
|
||||||
@@ -25,6 +33,8 @@ public sealed class BlindingSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<BlindableComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
SubscribeLocalEvent<BlindableComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
||||||
SubscribeLocalEvent<BlindableComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
SubscribeLocalEvent<BlindableComponent, PlayerDetachedEvent>(OnPlayerDetached);
|
||||||
|
|
||||||
|
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
|
||||||
|
|
||||||
_overlay = new();
|
_overlay = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,4 +62,9 @@ public sealed class BlindingSystem : EntitySystem
|
|||||||
_overlayMan.RemoveOverlay(_overlay);
|
_overlayMan.RemoveOverlay(_overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
|
||||||
|
{
|
||||||
|
_lightManager.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace Content.Shared.Eye.Blinding
|
namespace Content.Shared.Eye.Blinding
|
||||||
{
|
{
|
||||||
@@ -24,7 +25,7 @@ namespace Content.Shared.Eye.Blinding
|
|||||||
component.IsActive = true;
|
component.IsActive = true;
|
||||||
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
|
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
|
||||||
return;
|
return;
|
||||||
blindComp.Sources++;
|
AdjustBlindSources(args.Equipee, true, blindComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args)
|
private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args)
|
||||||
@@ -34,7 +35,22 @@ namespace Content.Shared.Eye.Blinding
|
|||||||
component.IsActive = false;
|
component.IsActive = false;
|
||||||
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
|
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
|
||||||
return;
|
return;
|
||||||
blindComp.Sources--;
|
AdjustBlindSources(args.Equipee, false, blindComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PublicAPI]
|
||||||
|
public void AdjustBlindSources(EntityUid uid, bool Add, BlindableComponent? blindable = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref blindable, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Add)
|
||||||
|
{
|
||||||
|
blindable.Sources++;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
blindable.Sources--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user