mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 09:37:03 +02:00
* [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>
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System.Linq;
|
|
using Robust.Client.State;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Reflection;
|
|
|
|
namespace Robust.Client.UserInterface
|
|
{
|
|
sealed partial class ChangeSceneCommpand : LocalizedCommands
|
|
{
|
|
[Dependency] private IReflectionManager _reflection = default!;
|
|
|
|
public override string Command => "scene";
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
var types = _reflection.GetAllChildren(typeof(State.State));
|
|
|
|
foreach (var tryType in types)
|
|
{
|
|
if (tryType.FullName!.EndsWith(args[0]))
|
|
{
|
|
var stateMan = IoCManager.Resolve<IStateManager>();
|
|
stateMan.RequestStateChange(tryType);
|
|
shell.WriteLine($"Switching to scene {tryType.FullName}");
|
|
return;
|
|
}
|
|
}
|
|
|
|
shell.WriteError($"No scene child class type ends with {args[0]}");
|
|
}
|
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
return CompletionResult.Empty;
|
|
var types = _reflection.GetAllChildren(typeof(State.State));
|
|
return CompletionResult.FromHintOptions(types.Select(x => x.Name), "[State name]");
|
|
}
|
|
}
|
|
}
|