A class in Root.Township, ATT.Character.QuickAccessMenu.
Routes console commands from in-game menus to the server. Singleton Instance on a networked entity; the server runs commands directly.
Constructors
| Member | What it is |
|---|
CommandSync() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|
static CommandSync Instance | The current command sync, set in Initialize. |
5 private and internal fields
| Member | What it is |
|---|
private Action<string, string> commandSyncCallback | Callback waiting for the server's command result. |
private string commandToSync | Command text being sent. |
private static readonly Logger logger | NLog logger for this class. |
private MethodSync syncCommand | Sync that sends a command to the server. |
private MethodSyncStruct<CommandSync.CommandSyncInfo> syncCommandConfirmation | Sync that carries a command result back. Nothing in this build sends it. |
Methods
| Member | What it is |
|---|
override void Initialize() | Sets Instance and creates the command and confirmation syncs. |
void RouteCommand(string command, Action<string, string> callback = null) | Fills in {localplayer}, then runs the command on a dedicated server or sends it to the server from a client. |
3 private and internal methods
| Member | What it is |
|---|
private static string SetupPlayerForCommand(string command, IPlayer player) | Replaces {localplayer} in the command with the player's user ID. |
private async void SyncCommand(IPlayer player, Stream stream) | Reads or writes the command text. In this build nothing runs a received command here. |
private void SyncCommandConfirmation(IPlayer player, Stream stream, CommandSync.CommandSyncInfo commandResult) | Reads or writes a command's name and result; on receive, calls and clears the pending callback. |