Files
tbd-station-14/Content.Client/Movement/Systems/ContentEyeSystem.cs
Pieter-Jan Briers 68ce53ae17 Random spontaneous cleanup PR (#25131)
* Use new Subs.CVar helper

Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe.

This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown.

* Fix a bunch of warnings

* More warning fixes

* Use new DateTime serializer to get rid of ISerializationHooks in changelog code.

* Get rid of some more ISerializationHooks for enums

* And a little more

* Apply suggestions from code review

Co-authored-by: 0x6273 <0x40@keemail.me>

---------

Co-authored-by: 0x6273 <0x40@keemail.me>
2024-02-13 16:48:39 -05:00

48 lines
1.3 KiB
C#

using System.Numerics;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Client.Player;
namespace Content.Client.Movement.Systems;
public sealed class ContentEyeSystem : SharedContentEyeSystem
{
[Dependency] private readonly IPlayerManager _player = default!;
public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, ContentEyeComponent? content = null)
{
if (!Resolve(uid, ref content, false))
return;
RaisePredictiveEvent(new RequestTargetZoomEvent()
{
TargetZoom = zoom,
IgnoreLimit = ignoreLimit,
});
}
public void RequestToggleFov()
{
if (_player.LocalEntity is { } player)
RequestToggleFov(player);
}
public void RequestToggleFov(EntityUid uid, EyeComponent? eye = null)
{
if (Resolve(uid, ref eye, false))
RequestEye(!eye.DrawFov, eye.DrawLight);
}
public void RequestToggleLight(EntityUid uid, EyeComponent? eye = null)
{
if (Resolve(uid, ref eye, false))
RequestEye(eye.DrawFov, !eye.DrawLight);
}
public void RequestEye(bool drawFov, bool drawLight)
{
RaisePredictiveEvent(new RequestEyeEvent(drawFov, drawLight));
}
}