diff --git a/Content.Server/Chemistry/ReagentEffects/ChemHealEyeDamage.cs b/Content.Server/Chemistry/ReagentEffects/ChemHealEyeDamage.cs
index 622d6c41d3..24cb696874 100644
--- a/Content.Server/Chemistry/ReagentEffects/ChemHealEyeDamage.cs
+++ b/Content.Server/Chemistry/ReagentEffects/ChemHealEyeDamage.cs
@@ -11,13 +11,14 @@ namespace Content.Server.Chemistry.ReagentEffects
public sealed class ChemHealEyeDamage : ReagentEffect
{
///
- /// Add or remove eye damage?
- [DataField("add")]
- public bool Add = false;
+ /// How much eye damage to remove.
+ ///
+ [DataField("amount")]
+ public int Amount = -1;
public override void Effect(ReagentEffectArgs args)
{
- EntitySystem.Get().AdjustEyeDamage(args.SolutionEntity, Add);
+ args.EntityManager.EntitySysManager.GetEntitySystem().AdjustEyeDamage(args.SolutionEntity, Amount);
}
}
}
diff --git a/Content.Server/Eye/Blinding/EyeProtection/EyeProtectionSystem.cs b/Content.Server/Eye/Blinding/EyeProtection/EyeProtectionSystem.cs
index f64aa0d945..80e1de68a8 100644
--- a/Content.Server/Eye/Blinding/EyeProtection/EyeProtectionSystem.cs
+++ b/Content.Server/Eye/Blinding/EyeProtection/EyeProtectionSystem.cs
@@ -27,13 +27,13 @@ namespace Content.Server.Eye.Blinding.EyeProtection
if (!component.Toggled)
return;
- if (!TryComp(args.User, out var status) || !TryComp(args.User, out var blindable))
+ if (!HasComp(args.User) || !TryComp(args.User, out var blindable))
return;
if (blindable.Sources > 0)
return;
- float statusTime = (float) component.StatusEffectTime.TotalSeconds - blindable.BlindResistance;
+ var statusTime = (float) component.StatusEffectTime.TotalSeconds - blindable.BlindResistance;
if (statusTime <= 0)
return;
@@ -41,7 +41,7 @@ namespace Content.Server.Eye.Blinding.EyeProtection
var statusTimeSpan = TimeSpan.FromSeconds(statusTime * (blindable.EyeDamage + 1));
// Add permanent eye damage if they had zero protection, also scale their temporary blindness by how much they already accumulated.
if (_statusEffectsSystem.TryAddStatusEffect(args.User, SharedBlindingSystem.BlindingStatusEffect, statusTimeSpan, false, "TemporaryBlindness") && blindable.BlindResistance <= 0)
- _blindingSystem.AdjustEyeDamage(args.User, true, blindable);
+ _blindingSystem.AdjustEyeDamage(args.User, 1, blindable);
}
private void OnWelderToggled(EntityUid uid, RequiresEyeProtectionComponent component, WelderToggledEvent args)
{
diff --git a/Content.Shared/Bed/Sleep/SharedSleepingSystem.cs b/Content.Shared/Bed/Sleep/SharedSleepingSystem.cs
index 7d7414a98d..855aafff9c 100644
--- a/Content.Shared/Bed/Sleep/SharedSleepingSystem.cs
+++ b/Content.Shared/Bed/Sleep/SharedSleepingSystem.cs
@@ -19,15 +19,15 @@ namespace Content.Server.Bed.Sleep
private void OnInit(EntityUid uid, SleepingComponent component, ComponentInit args)
{
var ev = new SleepStateChangedEvent(true);
- RaiseLocalEvent(uid, ev, false);
- _blindingSystem.AdjustBlindSources(uid, true);
+ RaiseLocalEvent(uid, ev);
+ _blindingSystem.AdjustBlindSources(uid, 1);
}
private void OnShutdown(EntityUid uid, SleepingComponent component, ComponentShutdown args)
{
var ev = new SleepStateChangedEvent(false);
- RaiseLocalEvent(uid, ev, false);
- _blindingSystem.AdjustBlindSources(uid, false);
+ RaiseLocalEvent(uid, ev);
+ _blindingSystem.AdjustBlindSources(uid, -1);
}
private void OnSpeakAttempt(EntityUid uid, SleepingComponent component, SpeakAttemptEvent args)
diff --git a/Content.Shared/Eye/Blinding/BlindableComponent.cs b/Content.Shared/Eye/Blinding/BlindableComponent.cs
index d17a1ca37c..a78270b8ad 100644
--- a/Content.Shared/Eye/Blinding/BlindableComponent.cs
+++ b/Content.Shared/Eye/Blinding/BlindableComponent.cs
@@ -26,7 +26,7 @@ namespace Content.Shared.Eye.Blinding
///
/// Whether eye damage has accumulated enough to blind them.
- ///
+ ///
[ViewVariables]
public bool EyeTooDamaged = false;
diff --git a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs
index 49ca19159b..41fff76fbc 100644
--- a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs
+++ b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs
@@ -1,6 +1,7 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory.Events;
using Content.Shared.Inventory;
+using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using JetBrains.Annotations;
@@ -23,6 +24,8 @@ namespace Content.Shared.Eye.Blinding
SubscribeLocalEvent(OnInit);
SubscribeLocalEvent(OnShutdown);
+
+ SubscribeLocalEvent(OnRejuvenate);
}
private void OnEquipped(EntityUid uid, BlindfoldComponent component, GotEquippedEvent args)
@@ -36,7 +39,7 @@ namespace Content.Shared.Eye.Blinding
component.IsActive = true;
if (!TryComp(args.Equipee, out var blindComp))
return;
- AdjustBlindSources(args.Equipee, true, blindComp);
+ AdjustBlindSources(args.Equipee, 1, blindComp);
}
private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args)
@@ -46,7 +49,7 @@ namespace Content.Shared.Eye.Blinding
component.IsActive = false;
if (!TryComp(args.Equipee, out var blindComp))
return;
- AdjustBlindSources(args.Equipee, false, blindComp);
+ AdjustBlindSources(args.Equipee, -1, blindComp);
}
private void OnGlassesEquipped(EntityUid uid, VisionCorrectionComponent component, GotEquippedEvent args)
@@ -81,52 +84,45 @@ namespace Content.Shared.Eye.Blinding
private void OnInit(EntityUid uid, TemporaryBlindnessComponent component, ComponentInit args)
{
- AdjustBlindSources(uid, true);
+ AdjustBlindSources(uid, 1);
}
private void OnShutdown(EntityUid uid, TemporaryBlindnessComponent component, ComponentShutdown args)
{
- AdjustBlindSources(uid, false);
+ AdjustBlindSources(uid, -1);
+ }
+
+ private void OnRejuvenate(EntityUid uid, BlindableComponent component, RejuvenateEvent args)
+ {
+ AdjustEyeDamage(uid, -component.EyeDamage, component);
}
[PublicAPI]
- public void AdjustBlindSources(EntityUid uid, bool Add, BlindableComponent? blindable = null)
+ public void AdjustBlindSources(EntityUid uid, int amount, BlindableComponent? blindable = null)
{
if (!Resolve(uid, ref blindable, false))
return;
- if (Add)
- {
- blindable.Sources++;
- } else
- {
- blindable.Sources--;
- }
-
+ blindable.Sources += amount;
blindable.Sources = Math.Max(blindable.Sources, 0);
Dirty(blindable);
}
- public void AdjustEyeDamage(EntityUid uid, bool add, BlindableComponent? blindable = null)
+ public void AdjustEyeDamage(EntityUid uid, int amount, BlindableComponent? blindable = null)
{
if (!Resolve(uid, ref blindable, false))
return;
- if (add)
- {
- blindable.EyeDamage++;
- } else
- {
- blindable.EyeDamage--;
- }
+ blindable.EyeDamage += amount;
if (blindable.EyeDamage > 0)
{
var blurry = EnsureComp(uid);
blurry.Magnitude = (9 - blindable.EyeDamage);
blurry.Dirty();
- } else
+ }
+ else
{
RemComp(uid);
}
@@ -134,12 +130,12 @@ namespace Content.Shared.Eye.Blinding
if (!blindable.EyeTooDamaged && blindable.EyeDamage >= 8)
{
blindable.EyeTooDamaged = true;
- AdjustBlindSources(uid, true, blindable);
+ AdjustBlindSources(uid, 1, blindable);
}
if (blindable.EyeTooDamaged && blindable.EyeDamage < 8)
{
blindable.EyeTooDamaged = false;
- AdjustBlindSources(uid, false, blindable);
+ AdjustBlindSources(uid, -1, blindable);
}
blindable.EyeDamage = Math.Clamp(blindable.EyeDamage, 0, 8);
diff --git a/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs b/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs
index 448433be39..49b82a0966 100644
--- a/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs
+++ b/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs
@@ -31,11 +31,11 @@ public sealed class PermanentBlindnessSystem : EntitySystem
private void OnShutdown(EntityUid uid, PermanentBlindnessComponent component, ComponentShutdown args)
{
- _blinding.AdjustBlindSources(uid, false);
+ _blinding.AdjustBlindSources(uid, -1);
}
private void OnStartup(EntityUid uid, PermanentBlindnessComponent component, ComponentStartup args)
{
- _blinding.AdjustBlindSources(uid, true);
+ _blinding.AdjustBlindSources(uid, 1);
}
}