mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-03 10:37:05 +02:00
* Toolshed Rejig * shorten hint string * Try fix conflicts. Ill make with work later * bodge * Fix ProtoIdTypeParser assert * comment * AllEntities * Remove more linq from WhereCommand * better help strings * Add ContainsCommand * loc strings * Add contains command description * Add $self variable * Errors for writing to readonly variables * A
37 lines
1008 B
C#
37 lines
1008 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Robust.Shared.Toolshed.Commands.Entities;
|
|
|
|
[ToolshedCommand]
|
|
internal sealed class EntitiesCommand : ToolshedCommand
|
|
{
|
|
[CommandImplementation]
|
|
public IEnumerable<EntityUid> Entities()
|
|
{
|
|
return new AllEntityEnumerator(EntityManager);
|
|
}
|
|
|
|
public sealed class AllEntityEnumerator(IEntityManager entMan) : IEnumerable<EntityUid>
|
|
{
|
|
public IEntityManager EntMan { get; } = entMan;
|
|
|
|
// We create an array as chained commands might modify it.
|
|
public EntityUid[]? _arr;
|
|
|
|
public IEnumerator<EntityUid> GetEnumerator()
|
|
{
|
|
_arr ??= EntMan.GetEntities().ToArray();
|
|
return ((IEnumerable<EntityUid>)_arr).GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
_arr ??= EntMan.GetEntities().ToArray();
|
|
return _arr.GetEnumerator();
|
|
}
|
|
}
|
|
}
|