Files
RobustToolbox/Robust.Shared/Console/Commands/DumpEventTablesCommand.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

57 lines
1.7 KiB
C#

using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
namespace Robust.Shared.Console.Commands;
internal sealed partial class DumpEventTablesCommand : LocalizedCommands
{
[Dependency] private EntityManager _entities = default!;
[Dependency] private IComponentFactory _componentFactory = default!;
public override string Command => "dump_event_tables";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length < 1)
{
shell.WriteError(Loc.GetString("cmd-dump_event_tables-missing-arg-entity"));
return;
}
if (!NetEntity.TryParse(args[0], out var entityNet) ||
!_entities.TryGetEntity(entityNet, out var entity) ||
!_entities.EntityExists(entity))
{
shell.WriteError(Loc.GetString("cmd-dump_event_tables-error-entity"));
return;
}
var eventBus = (EntityEventBus)_entities.EventBus;
var table = eventBus._entEventTables[entity.Value];
foreach (var (evType, comps) in table.EventIndices)
{
shell.WriteLine($"{evType}:");
var idx = comps.Start;
while (idx != -1)
{
ref var entry = ref table.ComponentLists[idx];
idx = entry.Next;
var reg = _componentFactory.IdxToType(entry.Component);
shell.WriteLine($" {reg.Name}");
}
}
}
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
return CompletionResult.FromHint(Loc.GetString("cmd-dump_event_tables-arg-entity"));
return CompletionResult.Empty;
}
}