Skip to main content

InfoBoard

A class in Root.Township, Alta.Map.

A board that shows server-set text. The server reads the text from a file named by the board's identifier in the save's InfoBoard folder and syncs it to players.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private InfoBoardSaveData dataThe saved board data, mainly the identifier that names its text file.
private TextRenderer rendererThe TextRenderer the text is shown on. Not touched on headless servers.
private MethodSync syncMethod sync used to send the text to players.
private string valueThe current board text, or null before a file is loaded.

Events​

1 private and internal event
MemberWhat it is
private static event Action<string> RefreshStatic event raised by ForceRefresh with the identifier to reload.

Methods​

MemberWhat it is
static void ForceRefresh(string identifier)Server: tells every board with this identifier to reload its file. Called by the infoboard console command after it writes new text.
override void Initialize()Sets up the sync method sync on the BookSync message type.
override void InitializeAsServer(SpawnData spawnData)Server: loads the text file and starts listening for ForceRefresh.
override void OnConnected(Player player)Server: sends the current text to a player who joins, if any text is loaded.
4 private and internal methods
MemberWhat it is
private void CheckRefresh(string identifier)Reloads the text file if the refreshed identifier matches this board's.
private async void LoadFromFile()Server: reads InfoBoard/<identifier> from the save folder if it exists, stores the text and sends it to the chunk's players.
private void OnDestroy()Stops listening for ForceRefresh.
private void Sync(IPlayer player, Stream stream)Writes the text on the server; on clients reads it and shows it on renderer.