Skip to main content

PlayerSave

A class in Root.Township, Alta.Utilities.

A player's save file: position data plus binary blobs for their body, state stack, player entity, progression and cosmetics. Server: Player.Save gives the loaded one. The blobs are saving-system bits; treat them as opaque.

Constructors​

MemberWhat it is
PlayerSave()Creates a PlayerSave from identifier.
PlayerSave(int identifier)Creates a PlayerSave from identifier.

Fields​

13 private and internal fields
MemberWhat it is
private uint[] customizationBacking field for CosmeticData, the player's serialized cosmetics.
private int customizationBytesBacking field for CosmeticBytes. Reading a save with 4 bytes or fewer drops the cosmetics.
private Vector3 lastSafePositionBacking field for LastSafePosition, saved after the other data in the newest format.
private static Logger loggerNLog logger for save and load errors.
private uint[] playerBacking field for PlayerData, the serialized player entity data.
private int playerBytesBacking field for PlayerBytes.
private uint[] prefabBacking field for PrefabData, the serialized player prefab and what it carries.
private int prefabBytesBacking field for PrefabBytes.
private uint[] progressionBacking field for ProgressionData, the serialized skill and progression data.
private int progressionBytesBacking field for ProgressionBytes.
private BasicSaveDataWrapper<PlayerSaveFileData> saveDataWrapper holding Data, the player save file data such as position.
private uint[] stateBacking field for StateData, the serialized player state.
private int stateBytesBacking field for StateBytes.

Properties​

MemberWhat it is
int CosmeticBytes { get; set; }Used length of CosmeticData in bytes.
uint[] CosmeticData { get; set; }The player's look. Setting it returns the old array to the pool.
PlayerSaveFileData Data { get; }position (where they were) and home (their respawn point, if set).
Vector3 LastSafePosition { get; set; }The last safe spot their client reported.
int PlayerBytes { get; set; }Used length of PlayerData in bytes.
uint[] PlayerData { get; set; }The Player entity's own savable parts. Setting it returns the old array to the pool.
int PlayerIdentifier { get; set; }The user id.
int PrefabBytes { get; set; }Used length of PrefabData in bytes.
ChunkVersioning PrefabChunkVersioning { get; set; }Save format versions the prefab data was written with.
uint[] PrefabData { get; set; }The body: what's in their hands, belt and back, and everything inside. Setting it returns the old array to the pool.
int ProgressionBytes { get; set; }Used length of ProgressionData in bytes.
uint[] ProgressionData { get; set; }Skills and progression. Setting it returns the old array to the pool.
int StateBytes { get; set; }Used length of StateData in bytes.
uint[] StateData { get; set; }The player state stack. Setting it returns the old array to the pool.

Methods​

MemberWhat it is
override IAltaFileFormat Clone()Deep copy with its own arrays, used when writing the file in the background.
override void Dispose()Returns all arrays to the pool. Warns if any were missing.
override void ReadFrom(FileInfo info, Stream stream)Reads the file, handling the current and three older formats. Older formats may drop cosmetics or state.
override void WriteTo(Stream stream, CancellationToken token)Writes the file in the current format.
1 private and internal method
MemberWhat it is
private bool ReleaseArray(ref uint[] array)Returns a data array to the pool and nulls it. Returns true if it was already null, which Dispose logs as a warning.

Used in​

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