Fix blindfold round cleanup bug (#9821)

* Blindness public api

* fix blinding round cleanup bug
This commit is contained in:
Rane
2022-07-19 03:10:08 -04:00
committed by GitHub
parent 91adb3edb3
commit 037feb3ad0
2 changed files with 33 additions and 2 deletions

View File

@@ -3,6 +3,14 @@ using Content.Shared.Eye.Blinding;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
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;
@@ -25,6 +33,8 @@ public sealed class BlindingSystem : EntitySystem
SubscribeLocalEvent<BlindableComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<BlindableComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
_overlay = new();
}
@@ -52,4 +62,9 @@ public sealed class BlindingSystem : EntitySystem
_overlayMan.RemoveOverlay(_overlay);
}
}
private void RoundRestartCleanup(RoundRestartCleanupEvent ev)
{
_lightManager.Enabled = true;
}
}

View File

@@ -1,6 +1,7 @@
using Content.Shared.Inventory.Events;
using Content.Shared.Inventory;
using Content.Shared.Item;
using JetBrains.Annotations;
namespace Content.Shared.Eye.Blinding
{
@@ -24,7 +25,7 @@ namespace Content.Shared.Eye.Blinding
component.IsActive = true;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
return;
blindComp.Sources++;
AdjustBlindSources(args.Equipee, true, blindComp);
}
private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args)
@@ -34,7 +35,22 @@ namespace Content.Shared.Eye.Blinding
component.IsActive = false;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
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--;
}
}
}
}