Toolshed refactor (#33598)
* Content changes for engine toolshed PR * add contains command * more permissive commands
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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(',');
|
||||
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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!);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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 _);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public sealed class VisualizeCommand : ToolshedCommand
|
||||
|
||||
[CommandImplementation]
|
||||
public void VisualizeEntities(
|
||||
[CommandInvocationContext] IInvocationContext ctx,
|
||||
IInvocationContext ctx,
|
||||
[PipedArgument] IEnumerable<EntityUid> input
|
||||
)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user