Add conditional camera offset based on cursor - Hristov Rework, Part 1 (#31626)

This commit is contained in:
SlamBamActionman
2025-01-28 00:20:45 +01:00
committed by GitHub
parent 3e091c4dfa
commit 5c782d3028
20 changed files with 357 additions and 12 deletions

View File

@@ -0,0 +1,45 @@
using Content.Server.Movement.Components;
using Content.Server.Movement.Systems;
using Content.Shared.Camera;
using Content.Shared.Hands;
using Content.Shared.Movement.Components;
using Content.Shared.Wieldable;
using Content.Shared.Wieldable.Components;
namespace Content.Server.Wieldable;
public sealed class WieldableSystem : SharedWieldableSystem
{
[Dependency] private readonly ContentEyeSystem _eye = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CursorOffsetRequiresWieldComponent, ItemUnwieldedEvent>(OnEyeOffsetUnwielded);
SubscribeLocalEvent<CursorOffsetRequiresWieldComponent, ItemWieldedEvent>(OnEyeOffsetWielded);
SubscribeLocalEvent<CursorOffsetRequiresWieldComponent, HeldRelayedEvent<GetEyePvsScaleRelayedEvent>>(OnGetEyePvsScale);
}
private void OnEyeOffsetUnwielded(Entity<CursorOffsetRequiresWieldComponent> entity, ref ItemUnwieldedEvent args)
{
_eye.UpdatePvsScale(args.User);
}
private void OnEyeOffsetWielded(Entity<CursorOffsetRequiresWieldComponent> entity, ref ItemWieldedEvent args)
{
_eye.UpdatePvsScale(args.User);
}
private void OnGetEyePvsScale(Entity<CursorOffsetRequiresWieldComponent> entity,
ref HeldRelayedEvent<GetEyePvsScaleRelayedEvent> args)
{
if (!TryComp(entity, out EyeCursorOffsetComponent? eyeCursorOffset) || !TryComp(entity.Owner, out WieldableComponent? wieldableComp))
return;
if (!wieldableComp.Wielded)
return;
args.Args.Scale += eyeCursorOffset.PvsIncrease;
}
}