+using Content.Client.Movement.Systems;
using Content.Shared.Actions;
using Content.Shared.Ghost;
using JetBrains.Annotations;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ILightManager _lightManager = default!;
- [Dependency] private readonly IEyeManager _eye = default!;
+ [Dependency] private readonly ContentEyeSystem _contentEye = default!;
public int AvailableGhostRoleCount { get; private set; }
if (args.Handled)
return;
- _eye.CurrentEye.DrawFov = !_eye.CurrentEye.DrawFov;
+ _contentEye.RequestToggleFov(uid);
args.Handled = true;
}
});
}
+ public void RequestToggleFov()
+ {
+ if (_player.LocalPlayer?.ControlledEntity is { } player)
+ RequestToggleFov(player);
+ }
+
+ public void RequestToggleFov(EntityUid uid, EyeComponent? eye = null)
+ {
+ if (Resolve(uid, ref eye, false))
+ RequestFov(!eye.DrawFov);
+ }
+
+ public void RequestFov(bool value)
+ {
+ RaisePredictiveEvent(new RequestFovEvent()
+ {
+ Fov = value,
+ });
+ }
+
public override void Update(float frameTime)
{
base.Update(frameTime);
using Content.Client.Administration.Managers;
+using Content.Client.Movement.Systems;
using Content.Shared.Sandbox;
using Robust.Client.Console;
using Robust.Client.Placement;
using Robust.Client.Placement.Modes;
-using Robust.Client.UserInterface;
using Robust.Shared.Map;
using Robust.Shared.Players;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
[Dependency] private readonly IMapManager _map = default!;
[Dependency] private readonly IPlacementManager _placement = default!;
- [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
+ [Dependency] private readonly ContentEyeSystem _contentEye = default!;
private bool _sandboxEnabled;
public bool SandboxAllowed { get; private set; }
public void ToggleFov()
{
- _consoleHost.ExecuteCommand("togglefov");
+ _contentEye.RequestToggleFov();
}
public void ToggleShadows()
+using Content.Shared.Administration.Managers;
+using Content.Shared.Ghost;
using Content.Shared.Input;
using Content.Shared.Movement.Components;
using Robust.Shared.Input;
/// </summary>
public abstract class SharedContentEyeSystem : EntitySystem
{
+ [Dependency] private readonly ISharedAdminManager _admin = default!;
+
private const float ZoomMod = 1.2f;
private const byte ZoomMultiple = 10;
base.Initialize();
SubscribeLocalEvent<ContentEyeComponent, ComponentStartup>(OnContentEyeStartup);
SubscribeAllEvent<RequestTargetZoomEvent>(OnContentZoomRequest);
+ SubscribeAllEvent<RequestFovEvent>(OnRequestFov);
CommandBinds.Builder
.Bind(ContentKeyFunctions.ZoomIn, new ScrollInputCmdHandler(true, this))
Dirty(content);
}
+ private void OnRequestFov(RequestFovEvent msg, EntitySessionEventArgs args)
+ {
+ if (args.SenderSession.AttachedEntity is not { } player)
+ return;
+
+ if (!HasComp<SharedGhostComponent>(player) && !_admin.IsAdmin(player))
+ return;
+
+ if (TryComp<SharedEyeComponent>(player, out var eyeComp))
+ {
+ eyeComp.DrawFov = msg.Fov;
+ Dirty(eyeComp);
+ }
+ }
+
public override void Shutdown()
{
base.Shutdown();
{
public Vector2 TargetZoom;
}
+
+ /// <summary>
+ /// Sendable from client to server to request changing fov.
+ /// </summary>
+ [Serializable, NetSerializable]
+ public sealed class RequestFovEvent : EntityEventArgs
+ {
+ public bool Fov;
+ }
}