Allow zoom command to ignore zoom limits (#19419)
This commit is contained in:
@@ -4,6 +4,7 @@ using Robust.Client.Console;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.Administration.Managers
|
||||
@@ -121,5 +122,13 @@ namespace Content.Client.Administration.Managers
|
||||
? _adminData
|
||||
: null;
|
||||
}
|
||||
|
||||
public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
|
||||
{
|
||||
if (_player.LocalPlayer?.UserId == session.UserId)
|
||||
return _adminData;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public sealed class ZoomCommand : IConsoleCommand
|
||||
|
||||
if (_entManager.TryGetComponent<ContentEyeComponent>(player, out var content))
|
||||
{
|
||||
_entManager.System<ContentEyeSystem>().RequestZoom(player.Value, zoom, content);
|
||||
_entManager.System<ContentEyeSystem>().RequestZoom(player.Value, zoom, true, content);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _player = default!;
|
||||
|
||||
public void RequestZoom(EntityUid uid, Vector2 zoom, ContentEyeComponent? content = null)
|
||||
public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, ContentEyeComponent? content = null)
|
||||
{
|
||||
if (!Resolve(uid, ref content, false))
|
||||
return;
|
||||
@@ -18,6 +18,7 @@ public sealed class ContentEyeSystem : SharedContentEyeSystem
|
||||
RaisePredictiveEvent(new RequestTargetZoomEvent()
|
||||
{
|
||||
TargetZoom = zoom,
|
||||
IgnoreLimit = ignoreLimit,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace Content.Server.Administration.Managers
|
||||
private readonly AdminCommandPermissions _commandPermissions = new();
|
||||
private readonly AdminCommandPermissions _toolshedCommandPermissions = new();
|
||||
|
||||
public bool IsAdmin(IPlayerSession session, bool includeDeAdmin = false)
|
||||
public bool IsAdmin(ICommonSession session, bool includeDeAdmin = false)
|
||||
{
|
||||
return GetAdminData(session, includeDeAdmin) != null;
|
||||
}
|
||||
|
||||
public AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false)
|
||||
public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
|
||||
{
|
||||
if (_admins.TryGetValue(session, out var reg) && (reg.Data.Active || includeDeAdmin))
|
||||
if (_admins.TryGetValue((IPlayerSession)session, out var reg) && (reg.Data.Active || includeDeAdmin))
|
||||
{
|
||||
return reg.Data;
|
||||
}
|
||||
|
||||
@@ -29,36 +29,6 @@ namespace Content.Server.Administration.Managers
|
||||
/// </summary>
|
||||
IEnumerable<IPlayerSession> AllAdmins { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player is an admin.
|
||||
/// </summary>
|
||||
/// <param name="session">The player to check.</param>
|
||||
/// <param name="includeDeAdmin">
|
||||
/// Whether to return admin data for admins that are current de-adminned.
|
||||
/// </param>
|
||||
/// <returns>true if the player is an admin, false otherwise.</returns>
|
||||
bool IsAdmin(IPlayerSession session, bool includeDeAdmin = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the admin data for a player, if they are an admin.
|
||||
/// </summary>
|
||||
/// <param name="session">The player to get admin data for.</param>
|
||||
/// <param name="includeDeAdmin">
|
||||
/// Whether to return admin data for admins that are current de-adminned.
|
||||
/// </param>
|
||||
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
||||
AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false);
|
||||
|
||||
/// <summary>
|
||||
/// See if a player has an admin flag.
|
||||
/// </summary>
|
||||
/// <returns>True if the player is and admin and has the specified flags.</returns>
|
||||
bool HasAdminFlag(IPlayerSession player, AdminFlags flag)
|
||||
{
|
||||
var data = GetAdminData(player);
|
||||
return data != null && data.HasFlag(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// De-admins an admin temporarily so they are effectively a normal player.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Shared.Administration.Managers;
|
||||
|
||||
/// <summary>
|
||||
@@ -17,6 +19,18 @@ public interface ISharedAdminManager
|
||||
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
||||
AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the admin data for a player, if they are an admin.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When used by the client, this only returns accurate results for the player's own session.
|
||||
/// </remarks>
|
||||
/// <param name="includeDeAdmin">
|
||||
/// Whether to return admin data for admins that are current de-adminned.
|
||||
/// </param>
|
||||
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
||||
AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false);
|
||||
|
||||
/// <summary>
|
||||
/// See if a player has an admin flag.
|
||||
/// </summary>
|
||||
@@ -30,6 +44,19 @@ public interface ISharedAdminManager
|
||||
return data != null && data.HasFlag(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See if a player has an admin flag.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When used by the client, this only returns accurate results for the player's own session.
|
||||
/// </remarks>
|
||||
/// <returns>True if the player is and admin and has the specified flags.</returns>
|
||||
bool HasAdminFlag(ICommonSession player, AdminFlags flag)
|
||||
{
|
||||
var data = GetAdminData(player);
|
||||
return data != null && data.HasFlag(flag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player is an admin.
|
||||
/// </summary>
|
||||
@@ -44,4 +71,19 @@ public interface ISharedAdminManager
|
||||
{
|
||||
return GetAdminData(uid, includeDeAdmin) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a player is an admin.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// When used by the client, this only returns accurate results for the player's own session.
|
||||
/// </remarks>
|
||||
/// <param name="includeDeAdmin">
|
||||
/// Whether to return admin data for admins that are current de-adminned.
|
||||
/// </param>
|
||||
/// <returns>true if the player is an admin, false otherwise.</returns>
|
||||
bool IsAdmin(ICommonSession session, bool includeDeAdmin = false)
|
||||
{
|
||||
return GetAdminData(session, includeDeAdmin) != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Managers;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Input;
|
||||
@@ -82,8 +83,10 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
|
||||
private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug);
|
||||
|
||||
if (TryComp<ContentEyeComponent>(args.SenderSession.AttachedEntity, out var content))
|
||||
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, eye: content);
|
||||
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content);
|
||||
}
|
||||
|
||||
private void OnRequestFov(RequestFovEvent msg, EntitySessionEventArgs args)
|
||||
@@ -149,6 +152,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
public sealed class RequestTargetZoomEvent : EntityEventArgs
|
||||
{
|
||||
public Vector2 TargetZoom;
|
||||
public bool IgnoreLimit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user