Skip to main content

PostboxManager

A class in Root.Township, the global namespace.

Server: the per-player manager that loads and saves each player's postbox contents (PlayerPostboxStorage). Reach it through PerPlayerManager<PostboxManager, PlayerPostboxStorage, PlayerPostboxStorageFileFormat>.Instance. It also collects trade vendor refunds during a wipe and posts them afterwards.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private PlayerPostboxStorage.InitialContent[] initialContentItems a player's postbox starts with the first time it's created.
private static Logger loggerNLog logger for this class.
private Dictionary<int, PostboxManager.TradeVendorData> wipeDataRefunds collected during a wipe, keyed by player identifier.

Methods​

MemberWhat it is
async void ConcludeWipe()Server: after a wipe finishes, pushes each player's collected wipe refunds (coins as a coin or pouch, plus items) into their postbox.
override async Task<PlayerPostboxStorage> GetContentAsync(IPlayer player)Server: loads a player's postbox storage and fills it with initialContent if it's new.
override void InitializeAsServer(SpawnData spawnData)Server: sets up the wipe data and hooks ConcludeWipe to ServerWipeManager.WipeOperationsFinished.
static async void PostToPlayer(int playerIdentifier, NetworkPrefab prefab)Server: saves a prefab, destroys it in the world and pushes the save into the given player's postbox, saving if they're offline.
void TradeWipe(int playerIdentifier, int coinCount, NetworkEntity dockedItem)Server: records coins and a docked item from a trade vendor to refund to a player once the wipe ends. Destroys the item.
1 private and internal method
MemberWhat it is
private void OnDestroy()Unhooks ConcludeWipe from the wipe event.