Skip to main content

CommandSync

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​

MemberWhat it is
CommandSync()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
static CommandSync InstanceThe current command sync, set in Initialize.
5 private and internal fields
MemberWhat it is
private Action<string, string> commandSyncCallbackCallback waiting for the server's command result.
private string commandToSyncCommand text being sent.
private static readonly Logger loggerNLog logger for this class.
private MethodSync syncCommandSync that sends a command to the server.
private MethodSyncStruct<CommandSync.CommandSyncInfo> syncCommandConfirmationSync that carries a command result back. Nothing in this build sends it.

Methods​

MemberWhat 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
MemberWhat 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.