[ByRefEvent]
public record struct GetEyeOffsetEvent(Vector2 Offset);
+/// <summary>
+/// Raised before the <see cref="GetEyeOffsetEvent"/> and <see cref="GetEyeOffsetRelayedEvent"/>, to check if any of the subscribed
+/// systems want to cancel offset changes.
+/// </summary>
+[ByRefEvent]
+public record struct GetEyeOffsetAttemptEvent(bool Cancelled);
+
/// <summary>
/// Raised on any equipped and in-hand items that may modify the eye offset.
/// Pockets and suitstorage are excluded.
[ByRefEvent]
public record struct GetEyePvsScaleEvent(float Scale);
+/// <summary>
+/// Raised before the <see cref="GetEyePvsScaleEvent"/> and <see cref="GetEyePvsScaleRelayedEvent"/>, to check if any on the subscribed
+/// systems want to cancel PVS changes.
+/// </summary>
+[ByRefEvent]
+public record struct GetEyePvsScaleAttemptEvent(bool Cancelled);
+
/// <summary>
/// Raised on any equipped and in-hand items that may modify the eye offset.
/// Pockets and suitstorage are excluded.
+using Content.Shared.Camera;
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Inventory;
using Content.Shared.Rejuvenate;
base.Initialize();
SubscribeLocalEvent<BlindableComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<BlindableComponent, EyeDamageChangedEvent>(OnDamageChanged);
+ SubscribeLocalEvent<BlindableComponent, GetEyePvsScaleAttemptEvent>(OnGetEyePvsScaleAttemptEvent);
+ SubscribeLocalEvent<BlindableComponent, GetEyeOffsetAttemptEvent>(OnGetEyeOffsetAttemptEvent);
}
private void OnRejuvenate(Entity<BlindableComponent> ent, ref RejuvenateEvent args)
_eyelids.UpdateEyesClosable((ent.Owner, ent.Comp));
}
+ private void OnGetEyePvsScaleAttemptEvent(Entity<BlindableComponent> ent, ref GetEyePvsScaleAttemptEvent args)
+ {
+ if (ent.Comp.IsBlind)
+ args.Cancelled = true;
+ }
+
+ private void OnGetEyeOffsetAttemptEvent(Entity<BlindableComponent> ent, ref GetEyeOffsetAttemptEvent args)
+ {
+ if (ent.Comp.IsBlind)
+ args.Cancelled = true;
+ }
+
[PublicAPI]
public void UpdateIsBlind(Entity<BlindableComponent?> blindable)
{
public void UpdateEyeOffset(Entity<EyeComponent> 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);
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);