PerPlayerContent<TSaveFormat>
A class in Root.Township, the global namespace.
Server: a save file that belongs to one player (by user ID), loaded whether or not they're online. Tracks the player while they're in the server. Base of PlayerPostboxStorage.
- Listed in Global namespace: P
- Inherits or implements
IPerPlayerContent<TSaveFormat> - Derived types
ClimbingTowerTeleporterSave,PlayerGoldBankAccount,PlayerPostboxStorage
Constructors
| Member | What it is |
|---|---|
PerPlayerContent() | Creates a PerPlayerContent with default values. |
Properties
| Member | What it is |
|---|---|
TSaveFormat Content { get; private set; } | The loaded file contents. |
IAltaFile File { get; private set; } | The save file the content is read from and written to. |
bool IsSavingPaused { get; private set; } | True between PauseSaving and ResumeSaving. |
int PlayerIdentifier { get; private set; } | The user ID of the player this content belongs to. |
IPlayer TargetPlayer { get; private set; } | The player while they're in the server, otherwise null. |
Methods
| Member | What it is |
|---|---|
virtual async Task LoadAsync(int playerIdentifier, IAltaFile file, IPlayer currentPlayer = null) | Reads the file, finds the player if they're online, and starts watching for them to join. |
void PauseSaving() | Stops SaveIfNoPlayer from writing, for batches of changes. |
void ResumeSaving(bool isUnloading) | Ends a pause and saves straight away, optionally unloading the file. |
void Save(bool isUnloading) | Writes the file if the server has save files, and optionally queues it to unload. |
void SaveIfNoPlayer() | Saves now if the player is offline and saving isn't paused. |
2 private and internal methods
| Member | What it is |
|---|---|
private void LosePlayer(NetworkEntity entity, bool isUnload) | Clears TargetPlayer when the player's entity is destroyed. |
private void PlayerJoined(IPlayer newPlayer) | Sets TargetPlayer when the player with this content's ID joins, and watches for them leaving. |