Toolshed refactor (#33598)

* Content changes for engine toolshed PR

* add contains command

* more permissive commands
This commit is contained in:
Leon Friedrich
2024-12-21 17:45:48 +11:00
committed by GitHub
parent b011dbb61e
commit 06e2bba8ab
19 changed files with 212 additions and 270 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Content.Server.Administration.Managers;
using Robust.Shared.Toolshed;
namespace Content.IntegrationTests.Tests.Toolshed;
@@ -10,10 +11,23 @@ public sealed class AdminTest : ToolshedTest
[Test]
public async Task AllCommandsHavePermissions()
{
var toolMan = Server.ResolveDependency<ToolshedManager>();
var admin = Server.ResolveDependency<IAdminManager>();
var ignored = new HashSet<Assembly>()
{typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly};
await Server.WaitAssertion(() =>
{
Assert.That(InvokeCommand("cmd:list where { acmd:perms isnull }", out var res));
Assert.That((IEnumerable<CommandSpec>) res, Is.Empty, "All commands must have admin permissions set up.");
Assert.Multiple(() =>
{
foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
{
if (ignored.Contains(cmd.Cmd.GetType().Assembly))
continue;
Assert.That(admin.TryGetCommandFlags(cmd, out _), $"Command does not have admin permissions set up: {cmd.FullName()}");
}
});
});
}
}

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Globalization;
using Robust.Shared.IoC;
using System.Reflection;
using Robust.Shared.Localization;
using Robust.Shared.Toolshed;
@@ -14,10 +14,27 @@ public sealed class LocTest : ToolshedTest
[Test]
public async Task AllCommandsHaveDescriptions()
{
var locMan = Server.ResolveDependency<ILocalizationManager>();
var toolMan = Server.ResolveDependency<ToolshedManager>();
var locStrings = new HashSet<string>();
var ignored = new HashSet<Assembly>()
{typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly};
await Server.WaitAssertion(() =>
{
Assert.That(InvokeCommand("cmd:list where { cmd:descloc loc:tryloc isnull }", out var res));
Assert.That((IEnumerable<CommandSpec>)res!, Is.Empty, "All commands must have localized descriptions.");
Assert.Multiple(() =>
{
foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
{
if (ignored.Contains(cmd.Cmd.GetType().Assembly))
continue;
var descLoc = cmd.DescLocStr();
Assert.That(locStrings.Add(descLoc), $"Duplicate command description key: {descLoc}");
Assert.That(locMan.TryGetString(descLoc, out _), $"Failed to get command description for command {cmd.FullName()}");
}
});
});
}
}

View File

@@ -74,15 +74,15 @@ public abstract class ToolshedTest : IInvocationContext
return (T) res!;
}
protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null, bool once = false)
protected void ParseCommand(string command, Type? inputType = null, Type? expectedType = null)
{
var parser = new ParserContext(command, Toolshed);
var success = CommandRun.TryParse(false, parser, inputType, expectedType, once, out _, out _, out var error);
var success = CommandRun.TryParse(parser, inputType, expectedType, out _);
if (error is not null)
ReportError(error);
if (parser.Error is not null)
ReportError(parser.Error);
if (error is null)
if (parser.Error is null)
Assert.That(success, $"Parse failed despite no error being reported. Parsed {command}");
}
@@ -153,11 +153,28 @@ public abstract class ToolshedTest : IInvocationContext
return _errors;
}
public bool HasErrors => _errors.Count > 0;
public void ClearErrors()
{
_errors.Clear();
}
public object? ReadVar(string name)
{
return Variables.GetValueOrDefault(name);
}
public void WriteVar(string name, object? value)
{
Variables[name] = value;
}
public IEnumerable<string> GetVars()
{
return Variables.Keys;
}
public Dictionary<string, object?> Variables { get; } = new();
protected void ExpectError(Type err)

View File

@@ -10,11 +10,7 @@ namespace Content.Server.Access;
public sealed class AddAccessLogCommand : ToolshedCommand
{
[CommandImplementation]
public void AddAccessLog(
[CommandInvocationContext] IInvocationContext ctx,
[CommandArgument] EntityUid input,
[CommandArgument] float seconds,
[CommandArgument] ValueRef<string> accessor)
public void AddAccessLog(IInvocationContext ctx, EntityUid input, float seconds, string accessor)
{
var accessReader = EnsureComp<AccessReaderComponent>(input);
@@ -23,19 +19,14 @@ public sealed class AddAccessLogCommand : ToolshedCommand
ctx.WriteLine($"WARNING: Surpassing the limit of the log by {accessLogCount - accessReader.AccessLogLimit+1} entries!");
var accessTime = TimeSpan.FromSeconds(seconds);
var accessName = accessor.Evaluate(ctx)!;
accessReader.AccessLog.Enqueue(new AccessRecord(accessTime, accessName));
accessReader.AccessLog.Enqueue(new AccessRecord(accessTime, accessor));
ctx.WriteLine($"Successfully added access log to {input} with this information inside:\n " +
$"Time of access: {accessTime}\n " +
$"Accessed by: {accessName}");
$"Accessed by: {accessor}");
}
[CommandImplementation]
public void AddAccessLogPiped(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] float seconds,
[CommandArgument] ValueRef<string> accessor)
public void AddAccessLogPiped(IInvocationContext ctx, [PipedArgument] EntityUid input, float seconds, string accessor)
{
AddAccessLog(ctx, input, seconds, accessor);
}

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Administration.Toolshed;
public sealed class MarkedCommand : ToolshedCommand
{
[CommandImplementation]
public IEnumerable<EntityUid> Marked([CommandInvocationContext] IInvocationContext ctx)
public IEnumerable<EntityUid> Marked(IInvocationContext ctx)
{
var res = (IEnumerable<EntityUid>?)ctx.ReadVar("marked");
res ??= Array.Empty<EntityUid>();

View File

@@ -23,7 +23,7 @@ public sealed class RejuvenateCommand : ToolshedCommand
}
[CommandImplementation]
public void Rejuvenate([CommandInvocationContext] IInvocationContext ctx)
public void Rejuvenate(IInvocationContext ctx)
{
_rejuvenate ??= GetSys<RejuvenateSystem>();
if (ExecutingEntity(ctx) is not { } ent)

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Syntax;
using Robust.Shared.Toolshed.TypeParsers;
using System.Linq;
using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Toolshed;
@@ -17,48 +18,38 @@ public sealed class SolutionCommand : ToolshedCommand
private SharedSolutionContainerSystem? _solutionContainer;
[CommandImplementation("get")]
public SolutionRef? Get(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string> name
)
public SolutionRef? Get([PipedArgument] EntityUid input, string name)
{
_solutionContainer ??= GetSys<SharedSolutionContainerSystem>();
if (_solutionContainer.TryGetSolution(input, name.Evaluate(ctx)!, out var solution))
if (_solutionContainer.TryGetSolution(input, name, out var solution))
return new SolutionRef(solution.Value);
return null;
}
[CommandImplementation("get")]
public IEnumerable<SolutionRef> Get(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ValueRef<string> name
)
public IEnumerable<SolutionRef> Get([PipedArgument] IEnumerable<EntityUid> input, string name)
{
return input.Select(x => Get(ctx, x, name)).Where(x => x is not null).Cast<SolutionRef>();
return input.Select(x => Get(x, name)).Where(x => x is not null).Cast<SolutionRef>();
}
[CommandImplementation("adjreagent")]
public SolutionRef AdjReagent(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] SolutionRef input,
[CommandArgument] Prototype<ReagentPrototype> name,
[CommandArgument] ValueRef<FixedPoint2> amountRef
ProtoId<ReagentPrototype> proto,
FixedPoint2 amount
)
{
_solutionContainer ??= GetSys<SharedSolutionContainerSystem>();
var amount = amountRef.Evaluate(ctx);
if (amount > 0)
{
_solutionContainer.TryAddReagent(input.Solution, name.Value.ID, amount, out _);
_solutionContainer.TryAddReagent(input.Solution, proto, amount, out _);
}
else if (amount < 0)
{
_solutionContainer.RemoveReagent(input.Solution, name.Value.ID, -amount);
_solutionContainer.RemoveReagent(input.Solution, proto, -amount);
}
return input;
@@ -66,12 +57,11 @@ public sealed class SolutionCommand : ToolshedCommand
[CommandImplementation("adjreagent")]
public IEnumerable<SolutionRef> AdjReagent(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<SolutionRef> input,
[CommandArgument] Prototype<ReagentPrototype> name,
[CommandArgument] ValueRef<FixedPoint2> amountRef
ProtoId<ReagentPrototype> name,
FixedPoint2 amount
)
=> input.Select(x => AdjReagent(ctx, x, name, amountRef));
=> input.Select(x => AdjReagent(x, name, amount));
}
public readonly record struct SolutionRef(Entity<SolutionComponent> Solution)

View File

@@ -36,82 +36,50 @@ public sealed class TagCommand : ToolshedCommand
}
[CommandImplementation("add")]
public EntityUid Add(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
)
public EntityUid Add([PipedArgument] EntityUid input, ProtoId<TagPrototype> tag)
{
_tag ??= GetSys<TagSystem>();
_tag.AddTag(input, @ref.Evaluate(ctx)!);
_tag.AddTag(input, tag);
return input;
}
[CommandImplementation("add")]
public IEnumerable<EntityUid> Add(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
)
=> input.Select(x => Add(ctx, x, @ref));
public IEnumerable<EntityUid> Add([PipedArgument] IEnumerable<EntityUid> input, ProtoId<TagPrototype> tag)
=> input.Select(x => Add(x, tag));
[CommandImplementation("rm")]
public EntityUid Rm(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
)
public EntityUid Rm([PipedArgument] EntityUid input, ProtoId<TagPrototype> tag)
{
_tag ??= GetSys<TagSystem>();
_tag.RemoveTag(input, @ref.Evaluate(ctx)!);
_tag.RemoveTag(input, tag);
return input;
}
[CommandImplementation("rm")]
public IEnumerable<EntityUid> Rm(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ValueRef<string, Prototype<TagPrototype>> @ref
)
=> input.Select(x => Rm(ctx, x, @ref));
public IEnumerable<EntityUid> Rm([PipedArgument] IEnumerable<EntityUid> input, ProtoId<TagPrototype> tag)
=> input.Select(x => Rm(x, tag));
[CommandImplementation("addmany")]
public EntityUid AddMany(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
)
public EntityUid AddMany([PipedArgument] EntityUid input, IEnumerable<ProtoId<TagPrototype>> tags)
{
_tag ??= GetSys<TagSystem>();
_tag.AddTags(input, (IEnumerable<ProtoId<TagPrototype>>)@ref.Evaluate(ctx)!);
_tag.AddTags(input, tags);
return input;
}
[CommandImplementation("addmany")]
public IEnumerable<EntityUid> AddMany(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
)
=> input.Select(x => AddMany(ctx, x, @ref));
public IEnumerable<EntityUid> AddMany([PipedArgument] IEnumerable<EntityUid> input, IEnumerable<ProtoId<TagPrototype>> tags)
=> input.Select(x => AddMany(x, tags.ToArray()));
[CommandImplementation("rmmany")]
public EntityUid RmMany(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
)
public EntityUid RmMany([PipedArgument] EntityUid input, IEnumerable<ProtoId<TagPrototype>> tags)
{
_tag ??= GetSys<TagSystem>();
_tag.RemoveTags(input, (IEnumerable<ProtoId<TagPrototype>>)@ref.Evaluate(ctx)!);
_tag.RemoveTags(input, tags);
return input;
}
[CommandImplementation("rmmany")]
public IEnumerable<EntityUid> RmMany(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ValueRef<IEnumerable<string>, IEnumerable<string>> @ref
)
=> input.Select(x => RmMany(ctx, x, @ref));
public IEnumerable<EntityUid> RmMany([PipedArgument] IEnumerable<EntityUid> input, IEnumerable<ProtoId<TagPrototype>> tags)
=> input.Select(x => RmMany(x, tags.ToArray()));
}

View File

@@ -14,7 +14,7 @@ public sealed class DeleteChatMessageCommand : ToolshedCommand
[Dependency] private readonly IEntitySystemManager _manager = default!;
[CommandImplementation("id")]
public void DeleteChatMessage([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] uint messageId)
public void DeleteChatMessage(IInvocationContext ctx, uint messageId)
{
if (!_manager.GetEntitySystem<ChatRepositorySystem>().Delete(messageId))
{

View File

@@ -14,7 +14,7 @@ public sealed class NukeChatMessagesCommand : ToolshedCommand
[Dependency] private readonly IEntitySystemManager _manager = default!;
[CommandImplementation("usernames")]
public void Command([CommandInvocationContext] IInvocationContext ctx, [CommandArgument] string usernamesCsv)
public void Command(IInvocationContext ctx, string usernamesCsv)
{
var usernames = usernamesCsv.Split(',');

View File

@@ -29,19 +29,10 @@ public sealed class MindCommand : ToolshedCommand
}
[CommandImplementation("control")]
public EntityUid Control(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid target,
[CommandArgument] ValueRef<ICommonSession> playerRef)
public EntityUid Control(IInvocationContext ctx, [PipedArgument] EntityUid target, ICommonSession player)
{
_mind ??= GetSys<SharedMindSystem>();
var player = playerRef.Evaluate(ctx);
if (player is null)
{
ctx.ReportError(new NotForServerConsoleError());
return target;
}
if (!_mind.TryGetMind(player, out var mindId, out var mind))
{

View File

@@ -20,7 +20,7 @@ public sealed class PolymorphCommand : ToolshedCommand
[CommandImplementation]
public EntityUid? Polymorph(
[PipedArgument] EntityUid input,
[CommandArgument] ProtoId<PolymorphPrototype> protoId
ProtoId<PolymorphPrototype> protoId
)
{
_system ??= GetSys<PolymorphSystem>();
@@ -34,7 +34,7 @@ public sealed class PolymorphCommand : ToolshedCommand
[CommandImplementation]
public IEnumerable<EntityUid> Polymorph(
[PipedArgument] IEnumerable<EntityUid> input,
[CommandArgument] ProtoId<PolymorphPrototype> protoId
ProtoId<PolymorphPrototype> protoId
)
=> input.Select(x => Polymorph(x, protoId)).Where(x => x is not null).Select(x => (EntityUid)x!);
}

View File

@@ -30,7 +30,7 @@ public sealed class JobsCommand : ToolshedCommand
=> stations.SelectMany(Jobs);
[CommandImplementation("job")]
public JobSlotRef Job([PipedArgument] EntityUid station, [CommandArgument] Prototype<JobPrototype> job)
public JobSlotRef Job([PipedArgument] EntityUid station, Prototype<JobPrototype> job)
{
_jobs ??= GetSys<StationJobsSystem>();
@@ -38,7 +38,7 @@ public sealed class JobsCommand : ToolshedCommand
}
[CommandImplementation("job")]
public IEnumerable<JobSlotRef> Job([PipedArgument] IEnumerable<EntityUid> stations, [CommandArgument] Prototype<JobPrototype> job)
public IEnumerable<JobSlotRef> Job([PipedArgument] IEnumerable<EntityUid> stations, Prototype<JobPrototype> job)
=> stations.Select(x => Job(x, job));
[CommandImplementation("isinfinite")]
@@ -50,63 +50,41 @@ public sealed class JobsCommand : ToolshedCommand
=> jobs.Select(x => IsInfinite(x, inverted));
[CommandImplementation("adjust")]
public JobSlotRef Adjust(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] JobSlotRef @ref,
[CommandArgument] ValueRef<int> by
)
public JobSlotRef Adjust([PipedArgument] JobSlotRef @ref, int by)
{
_jobs ??= GetSys<StationJobsSystem>();
_jobs.TryAdjustJobSlot(@ref.Station, @ref.Job, by.Evaluate(ctx), true, true);
_jobs.TryAdjustJobSlot(@ref.Station, @ref.Job, by, true, true);
return @ref;
}
[CommandImplementation("adjust")]
public IEnumerable<JobSlotRef> Adjust(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<JobSlotRef> @ref,
[CommandArgument] ValueRef<int> by
)
=> @ref.Select(x => Adjust(ctx, x, by));
public IEnumerable<JobSlotRef> Adjust([PipedArgument] IEnumerable<JobSlotRef> @ref, int by)
=> @ref.Select(x => Adjust(x, by));
[CommandImplementation("set")]
public JobSlotRef Set(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] JobSlotRef @ref,
[CommandArgument] ValueRef<int> by
)
public JobSlotRef Set([PipedArgument] JobSlotRef @ref, int by)
{
_jobs ??= GetSys<StationJobsSystem>();
_jobs.TrySetJobSlot(@ref.Station, @ref.Job, by.Evaluate(ctx), true);
_jobs.TrySetJobSlot(@ref.Station, @ref.Job, by, true);
return @ref;
}
[CommandImplementation("set")]
public IEnumerable<JobSlotRef> Set(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<JobSlotRef> @ref,
[CommandArgument] ValueRef<int> by
)
=> @ref.Select(x => Set(ctx, x, by));
public IEnumerable<JobSlotRef> Set([PipedArgument] IEnumerable<JobSlotRef> @ref, int by)
=> @ref.Select(x => Set(x, by));
[CommandImplementation("amount")]
public int Amount(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] JobSlotRef @ref
)
public int Amount([PipedArgument] JobSlotRef @ref)
{
_jobs ??= GetSys<StationJobsSystem>();
_jobs.TryGetJobSlot(@ref.Station, @ref.Job, out var slots);
return (int)(slots ?? 0);
return slots ?? 0;
}
[CommandImplementation("amount")]
public IEnumerable<int> Amount(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] IEnumerable<JobSlotRef> @ref
)
=> @ref.Select(x => Amount(ctx, x));
public IEnumerable<int> Amount([PipedArgument] IEnumerable<JobSlotRef> @ref)
=> @ref.Select(Amount);
}
// Used for Toolshed queries.

View File

@@ -27,7 +27,7 @@ public sealed class StationsCommand : ToolshedCommand
}
[CommandImplementation("get")]
public EntityUid Get([CommandInvocationContext] IInvocationContext ctx)
public EntityUid Get(IInvocationContext ctx)
{
_station ??= GetSys<StationSystem>();
@@ -54,7 +54,6 @@ public sealed class StationsCommand : ToolshedCommand
public EntityUid? LargestGrid([PipedArgument] EntityUid input)
{
_station ??= GetSys<StationSystem>();
return _station.GetLargestGrid(Comp<StationDataComponent>(input));
}
@@ -80,46 +79,30 @@ public sealed class StationsCommand : ToolshedCommand
=> input.Select(Config);
[CommandImplementation("addgrid")]
public void AddGrid(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<EntityUid> grid
)
public void AddGrid([PipedArgument] EntityUid input, EntityUid grid)
{
_station ??= GetSys<StationSystem>();
_station.AddGridToStation(input, grid.Evaluate(ctx));
_station.AddGridToStation(input, grid);
}
[CommandImplementation("rmgrid")]
public void RmGrid(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<EntityUid> grid
)
public void RmGrid([PipedArgument] EntityUid input, EntityUid grid)
{
_station ??= GetSys<StationSystem>();
_station.RemoveGridFromStation(input, grid.Evaluate(ctx));
_station.RemoveGridFromStation(input, grid);
}
[CommandImplementation("rename")]
public void Rename([CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input,
[CommandArgument] ValueRef<string> name
)
public void Rename([PipedArgument] EntityUid input, string name)
{
_station ??= GetSys<StationSystem>();
_station.RenameStation(input, name.Evaluate(ctx)!);
_station.RenameStation(input, name);
}
[CommandImplementation("rerollBounties")]
public void RerollBounties([CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] EntityUid input)
public void RerollBounties([PipedArgument] EntityUid input)
{
_cargo ??= GetSys<CargoSystem>();
_cargo.RerollBountyDatabase(input);
}
}

View File

@@ -94,7 +94,7 @@ namespace Content.Server.StationEvents
/// to even exist) so I think it's fine.
/// </remarks>
[CommandImplementation("simulate")]
public IEnumerable<(string, float)> Simulate([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] int rounds, [CommandArgument] int playerCount, [CommandArgument] float roundEndMean, [CommandArgument] float roundEndStdDev)
public IEnumerable<(string, float)> Simulate(EntityPrototype eventScheduler, int rounds, int playerCount, float roundEndMean, float roundEndStdDev)
{
_stationEvent ??= GetSys<EventManagerSystem>();
_entityTable ??= GetSys<EntityTableSystem>();
@@ -146,7 +146,7 @@ namespace Content.Server.StationEvents
}
[CommandImplementation("lsprob")]
public IEnumerable<(string, float)> LsProb([CommandArgument] EntityPrototype eventScheduler)
public IEnumerable<(string, float)> LsProb(EntityPrototype eventScheduler)
{
_compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>();
@@ -166,7 +166,7 @@ namespace Content.Server.StationEvents
}
[CommandImplementation("lsprobtime")]
public IEnumerable<(string, float)> LsProbTime([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] float time)
public IEnumerable<(string, float)> LsProbTime(EntityPrototype eventScheduler, float time)
{
_compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>();
@@ -188,7 +188,7 @@ namespace Content.Server.StationEvents
}
[CommandImplementation("prob")]
public float Prob([CommandArgument] EntityPrototype eventScheduler, [CommandArgument] string eventId)
public float Prob(EntityPrototype eventScheduler, string eventId)
{
_compFac ??= IoCManager.Resolve<IComponentFactory>();
_stationEvent ??= GetSys<EventManagerSystem>();

View File

@@ -22,13 +22,9 @@ public sealed class ACmdCommand : ToolshedCommand
}
[CommandImplementation("caninvoke")]
public bool CanInvoke(
[CommandInvocationContext] IInvocationContext ctx,
[PipedArgument] CommandSpec command,
[CommandArgument] ValueRef<ICommonSession> player
)
public bool CanInvoke(IInvocationContext ctx, [PipedArgument] CommandSpec command, ICommonSession player)
{
// Deliberately discard the error.
return ((IPermissionController) _adminManager).CheckInvokable(command, player.Evaluate(ctx), out var err);
return ((IPermissionController) _adminManager).CheckInvokable(command, player, out _);
}
}

View File

@@ -15,10 +15,10 @@ public sealed class RunVerbAsCommand : ToolshedCommand
[CommandImplementation]
public IEnumerable<NetEntity> RunVerbAs(
[CommandInvocationContext] IInvocationContext ctx,
IInvocationContext ctx,
[PipedArgument] IEnumerable<NetEntity> input,
[CommandArgument] ValueRef<NetEntity> runner,
[CommandArgument] string verb
EntityUid runner,
string verb
)
{
_verb ??= GetSys<SharedVerbSystem>();
@@ -26,17 +26,14 @@ public sealed class RunVerbAsCommand : ToolshedCommand
foreach (var i in input)
{
var runnerNet = runner.Evaluate(ctx);
var runnerEid = EntityManager.GetEntity(runnerNet);
if (EntityManager.Deleted(runnerEid) && runnerEid.IsValid())
ctx.ReportError(new DeadEntity(runnerEid));
if (EntityManager.Deleted(runner) && runner.IsValid())
ctx.ReportError(new DeadEntity(runner));
if (ctx.GetErrors().Any())
yield break;
var eId = EntityManager.GetEntity(i);
var verbs = _verb.GetLocalVerbs(eId, runnerEid, Verb.VerbTypes, true);
var verbs = _verb.GetLocalVerbs(eId, runner, Verb.VerbTypes, true);
// if the "verb name" is actually a verb-type, try run any verb of that type.
var verbType = Verb.VerbTypes.FirstOrDefault(x => x.Name == verb);
@@ -45,7 +42,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand
var verbTy = verbs.FirstOrDefault(v => v.GetType() == verbType);
if (verbTy != null)
{
_verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true);
_verb.ExecuteVerb(verbTy, runner, eId, forced: true);
yield return i;
}
}
@@ -54,7 +51,7 @@ public sealed class RunVerbAsCommand : ToolshedCommand
{
if (verbTy.Text.ToLowerInvariant() == verb)
{
_verb.ExecuteVerb(verbTy, runnerEid, eId, forced: true);
_verb.ExecuteVerb(verbTy, runner, eId, forced: true);
yield return i;
}
}

View File

@@ -16,7 +16,7 @@ public sealed class VisualizeCommand : ToolshedCommand
[CommandImplementation]
public void VisualizeEntities(
[CommandInvocationContext] IInvocationContext ctx,
IInvocationContext ctx,
[PipedArgument] IEnumerable<EntityUid> input
)
{

View File

@@ -6,7 +6,6 @@
- physics
- player
- splat
- emplace
- bin
- extremes
- reduce
@@ -19,113 +18,88 @@
- iota
- rep
- to
- iterate
- Flags: DEBUG
Commands:
- comp
- delete
- do
- with
- prototyped
- named
- paused
- with
- count
- emplace
- do
- iterate
- select
- where
- prototyped
- count
- types
- ecscomp
- actor
- spawn
- replace
- mappos
- pos
- tp
- allcomps
- replace
- entitysystemupdateorder
- mind
- Flags: HOST
Commands:
- methods
- ioc
- Commands:
- fuck
- ent
- as
- buildinfo
- help
- explain
- cmd
- stopwatch
- self
- search
- isnull
- help
- isempty
- any
- unique
- cd
- ls
- loc
- vars
- '=>'
- first
- val
- '+'
- '-'
- '*'
- '/'
- 'min'
- 'max'
- '&'
- '|'
- '^'
- 'neg'
- '<'
- '>'
- '<='
- '>='
- '=='
- '!='
- f
- i
- s
- b
- '+/'
- '-/'
- '*/'
- '//'
- join
- append
- '?'
- 'or?'
- '??'
- rng
- 'sum'
- self
- sum
- take
- curtick
- curtime
- realtime
- servertime
- more
- join
- search
- first
- unique
- any
- contains
- isnull
- isempty
- cd
- ls
- stopwatch
- append
- min
- max
- average
- '+'
- '-'
- '*'
- '/'
- '%'
- '%/'
- '&~'
- '|~'
- '^~'
- '~'
- 'abs'
- 'average'
- 'bibytecount'
- 'shortestbitlength'
- 'countleadzeros'
- 'counttrailingzeros'
- 'fpi'
- 'fe'
- 'ftau'
- 'fepsilon'
- '<'
- '>'
- '<='
- '>='
- '=='
- '!='
- '+/'
- '-/'
- '*/'
- '//'
- '&'
- '|'
- '^'
- neg
- abs
- bibytecount
- shortestbitlength
- countleadzeros
- counttrailingzeros
- fpi
- fe
- ftau
- fepsilon
- dpi
- de
- dtau
@@ -181,3 +155,29 @@
- atanpi
- pick
- tee
- Flags: HOST
Commands:
- methods
- ioc
- Commands:
- ent
- f
- i
- s
- b
- as
- var
- vars
- val
- help
- explain
- cmd
- buildinfo
- loc
- curtick
- curtime
- realtime
- servertime
- more