Arma Reforger Script API
Loading...
Searching...
No Matches
PersistenceSystem Interface Reference
Inheritance diagram for PersistenceSystem:
GameSystem SCR_PersistenceSystem

Public Member Functions

proto external bool TriggerSave (ESaveGameType saveType)
 Triger a global save which will also flush changes to the database at the end.
 
proto external bool Save (notnull Managed entityOrState, ESaveGameType saveType=ESaveGameType.MANUAL)
 Save the current state of the instance.
 
proto external void RequestSpawn (notnull PersistenceSpawnRequest spawnRequest, PersistenceResultCallback callback=null)
 Send of an async spawn request to fetch and instantiate the save-data. Any already available istances will instantly complete the callback with OK.
 
proto external void RequestLoad (notnull PersistenceLoadRequest loadRequest, PersistenceResultCallback callback=null)
 Send of an async spawn request to fetch and apply the save-data to existing instances.
 
proto external IEntity GetTrackedParent (IEntity entity)
 Returns wether the entity is part of a tracked parent or if it would be it's own root record.
 
proto external EPersistenceSystemState GetState ()
 Get the current state of the system.
 
proto external bool IsPrefabDataForced ()
 Returns configuration choice to be used by serializers.
 
proto external bool IsTracked (notnull Managed entityOrState)
 Is the instance configured to be persisted or will it be skipped in save-data.
 
proto external bool StartTracking (notnull Managed entityOrState)
 Make an instance known to the persistence system for further tracking and to apply save-data on load.
 
proto external bool PauseTracking (notnull Managed entityOrState)
 Pause any save-data processing for this instance.
 
proto external bool ResumeTracking (notnull Managed entityOrState)
 Undo of PauseTracking.
 
proto external bool StopTracking (notnull Managed entityOrState)
 Stop the tracking of the instance permanently. This will also release any persistent data next time a relevant save runs.
 
proto external bool ReleaseTracking (notnull Managed entityOrState)
 Will release any tracker for this instance.
 
proto external UUID GetId (Managed entityOrState)
 Get the persistence id of the instance. Null if not persistent.
 
proto external bool SetId (notnull Managed entityOrState, UUID id, bool makeAvailable=false)
 Set the persistence id of the instance.
 
proto external Managed FindById (UUID id)
 Find a tracked instance by id. Returns null if nothing under that id is found.
 
proto external PersistenceCollection FindCollection (string resourceOrDisplayName)
 Find a collection by its ResourceName from the collections configuration entry or the chosen displayName.
 
proto external PersistenceConfig GetConfig (notnull Managed entityOrState)
 Obtain a configuration instance that can be adjusted dynamically through script.
 
proto external void SetConfig (notnull Managed entityOrState, notnull PersistenceConfig config)
 Apply a configuration obtained by GetConfig and possibly changed via script.
 
proto external bool ReloadConfig (notnull Managed entityOrState)
 If the circumstances change this allows to re-evaluate the rules and select the currently appropriate config.
 
proto external ESerializeResult SerializeEntity (notnull IEntity entity, notnull BaseSerializationSaveContext context, SerializerDefaultSpawnData defaultData=null)
 Serialize an entity instance into the provided save context.
 
proto external IEntity DeserializeLoadEntity (notnull IEntity entity, notnull BaseSerializationLoadContext context, bool allowRecreate=true)
 Apply serialized data to an existing entity instance (only FINALIZE handlers are allowed for loaded entities) Returns loaded entity, or recreated one, or null in case of failure.
 
proto external IEntity DeserializeSpawnEntity (notnull EntitySpawnParams params, notnull BaseSerializationLoadContext context)
 Spawn a new entity from serialization data.
 
proto external ref PersistenceDeferredDeserializeTask AddDeferredDeserializeTask ()
 The deserialization completed callback is invoked after all tasks are completed.
 
proto external void ResolveDeferredDeserializeTaskAfterTime (notnull PersistenceDeferredDeserializeTask deferredDeserializeTask, float timeSeconds)
 Give ownership of a deferred task back to the system which will complete it after the given time in seconds has passed.
 
proto external void WhenAvailable (UUID uuid, notnull PersistenceWhenAvailableTask task, float maxWaitSeconds=0.0, PersistenceDeferredDeserializeTask deferredDeserializeTask=null)
 Await the presence of an instance tracked by the system under the given UUID.
 
proto external bool WasDataLoaded ()
 Info if the system inited with loading data or not on new playthrough.
 
proto external Managed GetPersistentState (TypeName stateType)
 
proto external void ClearSessionData (PersistenceStatusCallback callback=null)
 Deletes all data for session storage if any is currently used.
 
- Public Member Functions inherited from GameSystem
bool ShouldBePaused ()
 Is this system should be paused while the simulation is paused?
 
bool ShouldBeEnabledInEditMode ()
 Is this system should be enabled inside the editor.
 

Static Public Member Functions

static static proto PersistenceSystem GetInstance ()
 

Protected Member Functions

void OnStateChanged (EPersistenceSystemState oldState, EPersistenceSystemState newState)
 
void OnBeforeSave (ESaveGameType saveType)
 Called before save data is being read (and comitted).
 
void OnAfterSave (ESaveGameType saveType, bool success)
 After the save was created and comitted to database.
 
void OnAfterLoad (bool success)
 Called after initial world load completed. Success = false indicates fatal deserialization which is likely to negatively impact gameplay.
 
void HandleDelete (IEntity entity)
 Handle deletion of an entity to do some pre or post processing Reasons for deletion include:
 

Member Function Documentation

◆ AddDeferredDeserializeTask()

proto external ref PersistenceDeferredDeserializeTask PersistenceSystem.AddDeferredDeserializeTask ( )

The deserialization completed callback is invoked after all tasks are completed.

Adding a task gives the ability to wait for a call queue, frame or other delayed event until the instance is considered done and can be used by the callback handler. If the original request does not provide any callback to invoke these tasks will be ignored. The tasks is automatically added for the current load instance. Calling the method outside of a current load phase will have no effect.

◆ ClearSessionData()

proto external void PersistenceSystem.ClearSessionData ( PersistenceStatusCallback callback = null)

Deletes all data for session storage if any is currently used.

To be invoked on e.g. GamemodeEnd or debug purposes.

◆ DeserializeLoadEntity()

proto external IEntity PersistenceSystem.DeserializeLoadEntity ( notnull IEntity entity,
notnull BaseSerializationLoadContext context,
bool allowRecreate = true )

Apply serialized data to an existing entity instance (only FINALIZE handlers are allowed for loaded entities) Returns loaded entity, or recreated one, or null in case of failure.

◆ DeserializeSpawnEntity()

proto external IEntity PersistenceSystem.DeserializeSpawnEntity ( notnull EntitySpawnParams params,
notnull BaseSerializationLoadContext context )

Spawn a new entity from serialization data.

◆ FindById()

proto external Managed PersistenceSystem.FindById ( UUID id)

Find a tracked instance by id. Returns null if nothing under that id is found.

◆ FindCollection()

proto external PersistenceCollection PersistenceSystem.FindCollection ( string resourceOrDisplayName)

Find a collection by its ResourceName from the collections configuration entry or the chosen displayName.

◆ GetConfig()

proto external PersistenceConfig PersistenceSystem.GetConfig ( notnull Managed entityOrState)

Obtain a configuration instance that can be adjusted dynamically through script.

By default it is populated with the values from the system configuration. You can not get/create an instance for something that has no configuration at all.

◆ GetId()

proto external UUID PersistenceSystem.GetId ( Managed entityOrState)

Get the persistence id of the instance. Null if not persistent.

◆ GetInstance()

static static proto PersistenceSystem PersistenceSystem.GetInstance ( )
static

◆ GetPersistentState()

proto external Managed PersistenceSystem.GetPersistentState ( TypeName stateType)

◆ GetState()

proto external EPersistenceSystemState PersistenceSystem.GetState ( )

Get the current state of the system.

◆ GetTrackedParent()

proto external IEntity PersistenceSystem.GetTrackedParent ( IEntity entity)

Returns wether the entity is part of a tracked parent or if it would be it's own root record.

◆ HandleDelete()

void PersistenceSystem.HandleDelete ( IEntity entity)
protected

Handle deletion of an entity to do some pre or post processing Reasons for deletion include:

  • Removed in previous session and the change is being applied on load
  • Deserialize failure that was configured not to be tolerated

Implemented in SCR_PersistenceSystem.

◆ IsPrefabDataForced()

proto external bool PersistenceSystem.IsPrefabDataForced ( )

Returns configuration choice to be used by serializers.

◆ IsTracked()

proto external bool PersistenceSystem.IsTracked ( notnull Managed entityOrState)

Is the instance configured to be persisted or will it be skipped in save-data.

◆ OnAfterLoad()

void PersistenceSystem.OnAfterLoad ( bool success)
protected

Called after initial world load completed. Success = false indicates fatal deserialization which is likely to negatively impact gameplay.

Implemented in SCR_PersistenceSystem.

◆ OnAfterSave()

void PersistenceSystem.OnAfterSave ( ESaveGameType saveType,
bool success )
protected

After the save was created and comitted to database.

Parameters
saveTypeType of save that was done
successTrue or false if save data was successfully comitted to database

Implemented in SCR_PersistenceSystem.

◆ OnBeforeSave()

void PersistenceSystem.OnBeforeSave ( ESaveGameType saveType)
protected

Called before save data is being read (and comitted).

Implemented in SCR_PersistenceSystem.

◆ OnStateChanged()

void PersistenceSystem.OnStateChanged ( EPersistenceSystemState oldState,
EPersistenceSystemState newState )
protected

Implemented in SCR_PersistenceSystem.

◆ PauseTracking()

proto external bool PersistenceSystem.PauseTracking ( notnull Managed entityOrState)

Pause any save-data processing for this instance.

◆ ReleaseTracking()

proto external bool PersistenceSystem.ReleaseTracking ( notnull Managed entityOrState)

Will release any tracker for this instance.

None of the prior operations will be done. This is for memory optimization, so that if this instance will not be interacted with in any way in the near future it can be released. Useful for cleaning up trackers of players that disconnected and other situations where data should stay, but no more tracking is needed.

◆ ReloadConfig()

proto external bool PersistenceSystem.ReloadConfig ( notnull Managed entityOrState)

If the circumstances change this allows to re-evaluate the rules and select the currently appropriate config.

Note: This will reset any customization done via script on SetConfig.

◆ RequestLoad()

proto external void PersistenceSystem.RequestLoad ( notnull PersistenceLoadRequest loadRequest,
PersistenceResultCallback callback = null )

Send of an async spawn request to fetch and apply the save-data to existing instances.

◆ RequestSpawn()

proto external void PersistenceSystem.RequestSpawn ( notnull PersistenceSpawnRequest spawnRequest,
PersistenceResultCallback callback = null )

Send of an async spawn request to fetch and instantiate the save-data. Any already available istances will instantly complete the callback with OK.

◆ ResolveDeferredDeserializeTaskAfterTime()

proto external void PersistenceSystem.ResolveDeferredDeserializeTaskAfterTime ( notnull PersistenceDeferredDeserializeTask deferredDeserializeTask,
float timeSeconds )

Give ownership of a deferred task back to the system which will complete it after the given time in seconds has passed.

◆ ResumeTracking()

proto external bool PersistenceSystem.ResumeTracking ( notnull Managed entityOrState)

Undo of PauseTracking.

◆ Save()

proto external bool PersistenceSystem.Save ( notnull Managed entityOrState,
ESaveGameType saveType = ESaveGameType.MANUAL )

Save the current state of the instance.

Data is transient until the storage is flushed, but the entity can safely be deleted already after this (e.g. saving a disconnecting player).

◆ SerializeEntity()

proto external ESerializeResult PersistenceSystem.SerializeEntity ( notnull IEntity entity,
notnull BaseSerializationSaveContext context,
SerializerDefaultSpawnData defaultData = null )

Serialize an entity instance into the provided save context.

◆ SetConfig()

proto external void PersistenceSystem.SetConfig ( notnull Managed entityOrState,
notnull PersistenceConfig config )

Apply a configuration obtained by GetConfig and possibly changed via script.

◆ SetId()

proto external bool PersistenceSystem.SetId ( notnull Managed entityOrState,
UUID id,
bool makeAvailable = false )

Set the persistence id of the instance.

False if not persistent, or the id is already in use.

Parameters
entityOrStateInstance to set the id for
idId to assign onto the instance
makeAvailableResolve pending WhenAvailable calls if all relevant data is applied already.

◆ StartTracking()

proto external bool PersistenceSystem.StartTracking ( notnull Managed entityOrState)

Make an instance known to the persistence system for further tracking and to apply save-data on load.

Mostly for scripted states. IEntity should usually be registered by putting the PersistenceComponent on it!

◆ StopTracking()

proto external bool PersistenceSystem.StopTracking ( notnull Managed entityOrState)

Stop the tracking of the instance permanently. This will also release any persistent data next time a relevant save runs.

◆ TriggerSave()

proto external bool PersistenceSystem.TriggerSave ( ESaveGameType saveType)

Triger a global save which will also flush changes to the database at the end.

Returns false if the save process could not be started.

◆ WasDataLoaded()

proto external bool PersistenceSystem.WasDataLoaded ( )

Info if the system inited with loading data or not on new playthrough.

◆ WhenAvailable()

proto external void PersistenceSystem.WhenAvailable ( UUID uuid,
notnull PersistenceWhenAvailableTask task,
float maxWaitSeconds = 0.0,
PersistenceDeferredDeserializeTask deferredDeserializeTask = null )

Await the presence of an instance tracked by the system under the given UUID.

Parameters
uuidThe id to wait for. Could become known through registration of an existing id or spawn/load process of a record from the databse. NOTE: It is not guarantueed that the instance has completed all its deferred deserialization tasks already.
taskThe task you want to execute on availability. Will be instantly executed on call if the UUID is already available.
maxWaitSecondsTime after which availability check expires and the callback wil invoke with expired=true and instance=null. Wait time during async inital setup does not count.
deferredDeserializeTaskIf a deserialization completion should await this additional task, then it can be passed here. If the UUID is already available it will prematurely complete the deferred task AFTER the work was done.

The documentation for this interface was generated from the following file: