[feat? i dunno] SetGlobalZoomCommand

This commit is contained in:
rhailrake
2023-04-27 06:04:21 +06:00
committed by Remuchi
parent aca6843c0a
commit cd6483a665

View File

@@ -0,0 +1,38 @@
using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Client.Commands;
[AdminCommand(AdminFlags.Debug)]
public sealed class SetGlobalZoomCommand : IConsoleCommand
{
public string Command => "setglobalzoom";
public string Description => "Sets the global zoom for all characters.";
public string Help => "setglobalzoom <float>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if(args.Length != 1)
{
shell.WriteLine("Invalid number of arguments.");
return;
}
if (!float.TryParse(args[0], out var zoom))
{
shell.WriteLine("Invalid zoom value.");
return;
}
var entityManager = IoCManager.Resolve<EntityManager>();
var eyes = entityManager.GetAllComponents(typeof(SharedEyeComponent), true).Cast<SharedEyeComponent>().ToList();
foreach (var eye in eyes)
{
eye.Zoom = new Vector2(zoom, zoom);
entityManager.Dirty(eye);
}
}
}