Skip to main content

PlayerPostboxStorage

A class in Root.Township, the global namespace.

Server: one player's postbox contents, saved items waiting to be taken out. Get it through PostboxManager.

Constructors​

MemberWhat it is
PlayerPostboxStorage()Creates a PlayerPostboxStorage with default values.

Fields​

3 private and internal fields
MemberWhat it is
private bool isNewTrue when the postbox file didn't exist at load, so InitializeIfNew adds the starting content once.
private ChunkSaveFormat.Version latestThe save version that Push(NetworkEntity) adds to: the last stored version if it's current, otherwise a new one.
private static Logger loggerNLog logger for this class.

Events​

MemberWhat it is
event PlayerPostboxStorageEventHandler ItemAddedRaised after an item is pushed, with the new count.
event PlayerPostboxStorageEventHandler ItemRemovedRaised after an item is popped, with the new count.

Methods​

MemberWhat it is
int GetCount()How many items are in the postbox.
void InitializeIfNew(PlayerPostboxStorage.InitialContent[] initialContent)Fills a brand new postbox with starting items, each with its own chance. Does nothing for an existing one.
override async Task LoadAsync(int playerIdentifier, IAltaFile file, IPlayer player = null)Loads the file and remembers whether it was new.
NetworkEntity Pop()Spawns the oldest item as a server entity and removes it from the postbox. Returns null if empty or if spawning failed.
void Push(SerializedSavedDynamicObject content)Adds an item, from a saved object or a live entity. A live entity is saved without position and destroyed unless told not to.
void Push(NetworkEntity entity, bool isDestroying = true)Adds an item, from a saved object or a live entity. A live entity is saved without position and destroyed unless told not to.
1 private and internal method
MemberWhat it is
private async Task<PlayerPostboxStorageFileFormat> ReadAsync()Reads the postbox file. Nothing in this class calls it.

Used in​

Members of other types that take, return or hold a PlayerPostboxStorage: