Info
- Named commands that any caller can run from a text line: server console, launch arguments
- Module
Polis.Core.Commands, runtime
- A command is a factory from
CommandArgs to an IAction, so the work itself is a normal action
Adding commands
CommandRegistry.Register(new Command("spawn", CommandSources.Local, "spawn <prefab> [count=1]", "Spawn a prefab",
args =>
{
var prefab = args.Require<string>(0, "prefab");
var count = args.Get("count", 1);
return new DelegateAction(() => Spawn(prefab, count));
}));
Command(name, sources, usage, description, factory). Register in your service's load, CommandRegistry.Unregister(name) in OnDestroy
CommandSources - which callers may run it: Console, LaunchArgument, DeepLink, Local (console + launch argument)
CommandArgs - tokens split on spaces, quotes keep spaces together. name=value tokens are named, the rest positional
Require<T>(index, name), Get<T>(index, fallback), Get<T>(name, fallback). Strings, enums (any case) and numbers
DelegateAction wraps a method or async function, any other IAction works too
- Throw
ArgumentException in the factory for bad input, the caller gets the message plus the usage
- Run from code:
await CommandRegistry.RunAsync("setup Lab", CommandSources.Console) returns a CommandResult (Success, Message)
- Registry commands show up in the server console
help, see Console
Commands
network <offline|host> - start the network and wait for the connection (MasterNetworkManager)
setup <id> - switch the scene setup by its ID (e.g. Lab) or full address (SceneSetup/Lab), the network must be running (SceneSetupManager). A setup that isn't on the device or available is reported, the player stays
quitAfter <seconds> - quit the app after a delay
crashTest <error|exception|native> - logs a test error or exception for the crash reports, or crashes the app, to check what the reports get (CrashReportingManager). Only in development builds, while crash reports run
- All of them are
Local: console and launch arguments
Launch commands