Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SaveManager

Hierarchy

Implements

Index

Properties

Readonly event

event: IEventEmitter<this, ISaveManagerEvents> = new EventEmitter<this, E>(this)

lastLoadedVersion

lastLoadedVersion: IVersionInfo

Methods

clearMultiplayerSlotData

  • clearMultiplayerSlotData(): void
  • Returns void

compressSave

  • compressSave(slot: number, saveObject: ISaveObject, exporting?: boolean): void
  • Parameters

    • slot: number
    • saveObject: ISaveObject
    • Default value exporting: boolean = false

    Returns void

copySave

  • copySave(slot?: number, target?: undefined | number): Promise<any>
  • Parameters

    • Default value slot: number = game.slot!
    • Optional target: undefined | number

    Returns Promise<any>

decompressSave

  • decompressSave(slot: number, saveObject: ISaveObject, importing?: boolean): void
  • Parameters

    • slot: number
    • saveObject: ISaveObject
    • Default value importing: boolean = false

    Returns void

deleteAllData

  • Returns Promise<void>

deleteAllSlots

  • deleteAllSlots(): Promise<undefined | false | true>
  • Returns Promise<undefined | false | true>

deleteSlot

  • deleteSlot(slot?: number): Promise<undefined | false | true>
  • Parameters

    • Default value slot: number = game.slot!

    Returns Promise<undefined | false | true>

downloadGameStateAsJson

  • downloadGameStateAsJson(cleanup?: boolean): void
  • Parameters

    • Default value cleanup: boolean = true

    Returns void

exportSave

  • exportSave(slot: number): Promise<Uint8Array>
  • Parameters

    • slot: number

    Returns Promise<Uint8Array>

exportSaveAsCompressedSaveObject

  • Parameters

    • slot: number

    Returns Promise<ISaveObject>

exportSaveObject

  • exportSaveObject(saveObject: ISaveObject): Uint8Array
  • Parameters

    Returns Uint8Array

getClientStore

  • Returns the players ClientStore

    Parameters

    • Default value player: Player = localPlayer

    Returns IClientStore

getFirstFreeSlot

  • getFirstFreeSlot(): Promise<number | undefined>
  • Returns the index of the first free slot

    Returns Promise<number | undefined>

getGameStateAsJson

  • getGameStateAsJson(cleanup?: boolean, pretty?: boolean): string
  • Parameters

    • Default value cleanup: boolean = true
    • Default value pretty: boolean = false

    Returns string

getMostRecentSlot

  • getMostRecentSlot(): Promise<number>
  • Gets the most recently saved slot

    Returns Promise<number>

getSaveCount

  • Returns the number of filled slots

    Returns Promise<number>

getSerializer

  • Returns ISerializer

getSlots

  • Returns an array where the index is the slot number, and the value is whether or not the slot is filled

    Returns Promise<boolean[]>

getUsedSlots

  • getUsedSlots(): Promise<number[]>
  • Returns the indices of the used slots

    Returns Promise<number[]>

getUsedSlotsSorted

  • Gets the used slots, ordered by one of a few properties of the saveData in that slot

    Parameters

    Returns Promise<number[]>

importSave

  • importSave(slot: number, saveObject: ISaveObject | string | Uint8Array): Promise<undefined | number>
  • Imports saves from multiple formats

    1. ISaveObject - games imported while joining a multiplayer server
    2. string - From legacy exported save games to files or to steam
    3. Uint8Array - From exported save games

    Parameters

    • slot: number
    • saveObject: ISaveObject | string | Uint8Array

    Returns Promise<undefined | number>

    the number of bytes the save takes up, or undefined, if an error occurs

initialize

  • Returns Promise<void>

isEnabled

  • isEnabled(): boolean
  • Returns boolean

isSlotUsed

  • isSlotUsed(slot: number): Promise<boolean>
  • Returns whether or not the slot is used

    Parameters

    • slot: number

    Returns Promise<boolean>

load

  • load(slot: number): Promise<boolean>
  • Returns whether or not it succeeded

    Parameters

    • slot: number

    Returns Promise<boolean>

loadPartial

  • Parameters

    • slot: number

    Returns Promise<ISaveObject>

loadPartialData

  • loadPartialData(saveObject: ISaveObject, object: any, key: string, saveObjectKey?: string, skipCompression?: boolean, importing?: boolean): void
  • Parameters

    • saveObject: ISaveObject
    • object: any
    • key: string
    • Default value saveObjectKey: string = key
    • Default value skipCompression: boolean = false
    • Default value importing: boolean = false

    Returns void

save

  • Returns a tuple [bytes: number, saveObject: ISaveObject]

    Parameters

    • slot: number
    • Default value unloading: boolean = false

    Returns Promise<ISaveInfo>

savePartialData

  • savePartialData(slot: number, object: any, key: string, saveObjectKey: string): Promise<number>
  • Returns the number of bytes the save takes up

    Parameters

    • slot: number
    • object: any
    • key: string
    • saveObjectKey: string

    Returns Promise<number>

savePartialDataInside

  • savePartialDataInside(slot: number, saveObjectKey: string, key: string, value: any): Promise<number>
  • Returns the number of bytes the save takes up

    Parameters

    • slot: number
    • saveObjectKey: string
    • key: string
    • value: any

    Returns Promise<number>

Generated using TypeDoc