A class in Root.Township, Alta.Inventory.
A chunk that loads one player's personal storage, saved under a name with that player's ID. Server only; one player at a time, and a player can only use one at a time.
Constructors
| Member | What it is |
|---|
PersonalChunk() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
4 private and internal fields
| Member | What it is |
|---|
private Chunk chunk | The chunk on this object. |
private static HashSet<IPlayer> currentlyUsing | Players who have a personal chunk loaded, across all instances. |
private string nameSuffix | Part of the chunk name, so different personal chunks don't share a save. Defaults to Storage. |
private NetworkPrefab prefab | Prefab spawned the first time a player's chunk is empty. |
Properties
| Member | What it is |
|---|
IPlayer CurrentPlayer { get; private set; } | The player whose storage is loaded, or null. |
Methods
| Member | What it is |
|---|
override void Initialize() | Gets the chunk and marks it not static. |
void Load(IPlayer player) | Server: renames the chunk to Personal Chunk plus suffix and the player's ID, force loads it, and spawns contents once loaded. |
void Unload(IPlayer player) | Server: unloads and saves the chunk if this player is the current one. |
2 private and internal methods
| Member | What it is |
|---|
private void RemoveCurrentPlayer() | Force unloads and saves the chunk and frees the current player. |
private void SpawnInitialDocks(Chunk chunk) | Once loaded, spawns prefab if the chunk is empty (else re-parents the first entity), then adds the player to the chunk. |