diff --git a/Content.Shared/Camera/GetEyeOffsetEvent.cs b/Content.Shared/Camera/GetEyeOffsetEvent.cs index 0e3c00110a..fc118315ec 100644 --- a/Content.Shared/Camera/GetEyeOffsetEvent.cs +++ b/Content.Shared/Camera/GetEyeOffsetEvent.cs @@ -19,6 +19,13 @@ namespace Content.Shared.Camera; [ByRefEvent] public record struct GetEyeOffsetEvent(Vector2 Offset); +/// +/// Raised before the and , to check if any of the subscribed +/// systems want to cancel offset changes. +/// +[ByRefEvent] +public record struct GetEyeOffsetAttemptEvent(bool Cancelled); + /// /// Raised on any equipped and in-hand items that may modify the eye offset. /// Pockets and suitstorage are excluded. diff --git a/Content.Shared/Camera/GetEyePvsScaleEvent.cs b/Content.Shared/Camera/GetEyePvsScaleEvent.cs index 482b755db8..4e8c48ade1 100644 --- a/Content.Shared/Camera/GetEyePvsScaleEvent.cs +++ b/Content.Shared/Camera/GetEyePvsScaleEvent.cs @@ -20,6 +20,13 @@ namespace Content.Shared.Camera; [ByRefEvent] public record struct GetEyePvsScaleEvent(float Scale); +/// +/// Raised before the and , to check if any on the subscribed +/// systems want to cancel PVS changes. +/// +[ByRefEvent] +public record struct GetEyePvsScaleAttemptEvent(bool Cancelled); + /// /// Raised on any equipped and in-hand items that may modify the eye offset. /// Pockets and suitstorage are excluded. diff --git a/Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs b/Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs index 24eed3adcf..ae81226a4b 100644 --- a/Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs +++ b/Content.Shared/Eye/Blinding/Systems/BlindableSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.Camera; using Content.Shared.Eye.Blinding.Components; using Content.Shared.Inventory; using Content.Shared.Rejuvenate; @@ -15,6 +16,8 @@ public sealed class BlindableSystem : EntitySystem base.Initialize(); SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnDamageChanged); + SubscribeLocalEvent(OnGetEyePvsScaleAttemptEvent); + SubscribeLocalEvent(OnGetEyeOffsetAttemptEvent); } private void OnRejuvenate(Entity ent, ref RejuvenateEvent args) @@ -28,6 +31,18 @@ public sealed class BlindableSystem : EntitySystem _eyelids.UpdateEyesClosable((ent.Owner, ent.Comp)); } + private void OnGetEyePvsScaleAttemptEvent(Entity ent, ref GetEyePvsScaleAttemptEvent args) + { + if (ent.Comp.IsBlind) + args.Cancelled = true; + } + + private void OnGetEyeOffsetAttemptEvent(Entity ent, ref GetEyeOffsetAttemptEvent args) + { + if (ent.Comp.IsBlind) + args.Cancelled = true; + } + [PublicAPI] public void UpdateIsBlind(Entity blindable) { diff --git a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs index 71bc65a79e..8063948eea 100644 --- a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs +++ b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs @@ -142,6 +142,15 @@ public abstract class SharedContentEyeSystem : EntitySystem public void UpdateEyeOffset(Entity eye) { + var evAttempt = new GetEyeOffsetAttemptEvent(); + RaiseLocalEvent(eye, ref evAttempt); + + if (evAttempt.Cancelled) + { + _eye.SetOffset(eye, Vector2.Zero, eye); + return; + } + var ev = new GetEyeOffsetEvent(); RaiseLocalEvent(eye, ref ev); @@ -156,6 +165,15 @@ public abstract class SharedContentEyeSystem : EntitySystem if (!Resolve(uid, ref contentEye) || !Resolve(uid, ref eye)) return; + var evAttempt = new GetEyePvsScaleAttemptEvent(); + RaiseLocalEvent(uid, ref evAttempt); + + if (evAttempt.Cancelled) + { + _eye.SetPvsScale((uid, eye), 1); + return; + } + var ev = new GetEyePvsScaleEvent(); RaiseLocalEvent(uid, ref ev);