Skip to main content

GlobalCommunalStorageValues

A class in Root.Township, Alta.Inventory.

Server: keeps communal storage contents across server wipes, saved in the Global Communal Storage file. Static methods use a single instance set in Awake.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private List<StorageData> availableDataStored quantities shared by item and physical material.
private GlobalCommunalStorageValuesData dataThe loaded save data, or null if there was no file.
private IAltaFile fileThe save file.
private static GlobalCommunalStorageValues instanceThe single instance the static methods use.
private static Logger loggerLogger for this class.
private Task readingTaskThe file read in progress; the static methods wait for it first.
private Dictionary<CommunalStorageUniqueIdentifier, int> uniqueStoragesStored quantities for unique storages, by identifier.

Methods​

MemberWhat it is
override async void Initialize()Server: sets up the lists, hooks the wipe-finished event and reads the save file.
static async Task<int> Load(CommunalStorageUniqueIdentifier identifier)Takes and returns the stored quantity for an identifier or item, removing it and saving the file. Returns 0 if none.
static async Task<int> Load(Pickup docked)Takes and returns the stored quantity for an identifier or item, removing it and saving the file. Returns 0 if none.
static async void Save(CommunalStorageUniqueIdentifier identifier, int quantity)Records a quantity in memory, by unique identifier or added to the matching item and material. Written on FinishWipe.
static async void Save(Pickup docked, int quantity)Records a quantity in memory, by unique identifier or added to the matching item and material. Written on FinishWipe.
static async Task Wipe()Deletes the save file and clears everything. Used by the wipe-storage command.
5 private and internal methods
MemberWhat it is
private void Awake()Stores this as the static instance.
private void FinishWipe()After a wipe, writes everything collected during the wipe to the save file.
private async Task LoadContent()Reads the save file into the shared item list and the per-identifier quantities.
private void OnDestroy()Unhooks the wipe-finished event.
private void SaveToFile()Writes the current data to the save file.