CatStation/Content.Shared/Camera/GetEyeOffsetEvent.cs
metalgearsloth e1d5c3dd9c
Make GetEyeOffsetRelayedEvent a struct (#45090)
* Make GetEyeOffsetRelayedEvent a struct

ContentEyeSystem probably shouldn't raise a relay event every single frame but this at least makes it faster, shouldn't be a BC for anything unless a fork modified it.

* review
2026-08-06 14:42:04 +00:00

37 lines
1.4 KiB
C#

using System.Numerics;
using Content.Shared.Inventory;
using Content.Shared.Movement.Systems;
namespace Content.Shared.Camera;
/// <summary>
/// Raised directed by-ref when <see cref="SharedContentEyeSystem.UpdateEyeOffset"/> is called.
/// Should be subscribed to by any systems that want to modify an entity's eye offset,
/// so that they do not override each other.
/// </summary>
/// <param name="Offset">
/// The total offset to apply.
/// </param>
/// <remarks>
/// Note that in most cases <see cref="Offset"/> should be incremented or decremented by subscribers, not set.
/// Otherwise, any offsets applied by previous subscribing systems will be overridden.
/// </remarks>
[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.
/// </summary>
[ByRefEvent]
public record struct GetEyeOffsetRelayedEvent(Vector2 Offset = default) : IInventoryRelayEvent
{
SlotFlags IInventoryRelayEvent.TargetSlots => ~(SlotFlags.POCKET & SlotFlags.SUITSTORAGE);
}