Files
RobustToolbox/Robust.Shared/Map/Commands/AmbientLightCommand.cs
T
83c2a1be11 [Dependency] source generator part 2 (#6550)
* [Dependency] source generator

No more reflection, no more codegen at runtime

Also various changes to Roslyn helpers to make this easier to write.

Requires all types with dependencies to be partial and not have readonly dependency fields. An analyzer enforces this at warning level, the previous injection strategies have remained in the code *for now* as a fallback.

No fallback is available for [field: Dependency] properties, due to a Roslyn bug.

Code Fixes exist. We love Roslyn

* Apply dependencies generator changes to all code

* Release notes

* Preprocessor got hands

* Handle nullable dependencies

These are bad but gotta deal with it.

* Apply suggestions from code review

Co-authored-by: Moony <moony@hellomouse.net>

* Fine, let's not use collection expressions

---------

Co-authored-by: Moony <moony@hellomouse.net>
2026-05-08 12:38:33 +02:00

55 lines
1.7 KiB
C#

using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
namespace Robust.Shared.Map.Commands;
/// <summary>
/// Sets the ambient light for a particular map
/// </summary>
public sealed partial class AmbientLightCommand : IConsoleCommand
{
[Dependency] private IEntitySystemManager _systems = default!;
public string Command => $"setambientlight";
public string Description => Loc.GetString("cmd-set-ambient-light-desc");
public string Help => Loc.GetString("cmd-set-ambient-light-help");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 5)
{
shell.WriteError(Loc.GetString("cmd-invalid-arg-number-error"));
return;
}
if (!int.TryParse(args[0], out var mapInt))
{
shell.WriteError(Loc.GetString("cmd-parse-failure-integer"));
return;
}
var mapId = new MapId(mapInt);
var mapSystem = _systems.GetEntitySystem<SharedMapSystem>();
if (!mapSystem.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-parse-failure-mapid", ("arg", mapId.Value)));
return;
}
if (!byte.TryParse(args[1], out var r) ||
!byte.TryParse(args[2], out var g) ||
!byte.TryParse(args[3], out var b) ||
!byte.TryParse(args[4], out var a))
{
shell.WriteError(Loc.GetString("cmd-set-ambient-light-parse"));
return;
}
var color = Color.FromSrgb(new Color(r, g, b, a));
mapSystem.SetAmbientLight(mapId, color);
}
}