Platformer Pro  2.3.2
A platform game kit for Unity.
PlatformerPro.PersistableObjectManager Class Reference

Static class for managing persistable objects. More...

Inheritance diagram for PlatformerPro.PersistableObjectManager:
PlatformerPro.PlatformerProMonoBehaviour

Public Member Functions

PersistableObjectData GetState (string guid, bool defaultStateIsDisabled)
 Gets the state for the object with the given guid. This is not a copy! Creates new state if the guid is not found. More...
 
void SetState (string guid, bool state, string extraInfo)
 Sets the state for the object with the given guid. More...
 
void SetState (string guid, bool state, string extraInfo, string spawnObjectName, Vector3 spawnObjectPosition)
 
void Save ()
 Updates persistable object state. More...
 
void ResetAll ()
 Reset persistable object state. More...
 
void ResetCurrentlevel ()
 Reset persistable object state. More...
 
virtual void HandleGameOver (object sender, DamageInfoEventArgs e)
 Handles the game ending. More...
 
- Public Member Functions inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual void Validate (PlatformerProMonoBehaviour myTarget)
 Override this method if you want to provide custom validation. The actual code should be surrounded by the if UNITY_EDITOR / endif directive. More...
 

Static Public Member Functions

static PersistableObjectManager CreateNewPersistableObjectManager (bool saveOnChange, bool useBinaryFormat)
 Creates a new time manager. More...
 

Static Public Attributes

const string UniqueDataIdentifier = "PersistableObjectManagerData"
 The player preference identifier. More...
 

Protected Member Functions

void Init ()
 Init this instance. More...
 
virtual void SaveXml ()
 Updates persistable object state using XML format. More...
 
virtual void SaveBinary ()
 Updates persistable object state using binary format. More...
 
void Load ()
 Load the saved data from prefs. More...
 
virtual void LoadXml ()
 Load the saved data from prefs in XMl format. More...
 
virtual void LoadBinary ()
 Load the saved data from prefs in XMl format. More...
 
virtual void SpawnObjects (IEnumerable< PersistableObjectData > objectsToSpawn)
 Spawns loaded objects. More...
 
void DoPendingSave (object sender, PersistenceEventArgs e)
 Trigger the saves in response to save event. More...
 
List< PersistableObjectDataGetSaveData ()
 Convert dictionary into savable list. More...
 

Protected Attributes

bool useBinaryFormat
 If true save files in a binary format. False use XML. More...
 
bool saveOnChange
 Should we save data on change. More...
 
Dictionary< string, PersistableObjectDataobjectData
 The persistence data. More...
 
bool readyToSave
 Used to ensure that the will exit scene save happens at end of frame after all other objects have set their state. More...
 

Static Protected Attributes

static List< string > allPrefsIdentifiers = new List<string> ()
 Stores all pref kyes so we can reset data. More...
 
static BinaryFormatter binaryFormatter
 A formatter used for binary serialisation. More...
 

Properties

bool UseBinary [get]
 Should we use binary format? More...
 
BinaryFormatter BinaryFormatter [get]
 Get a binary formatter for use in saving. More...
 
virtual string PlayerPrefsIdentifier [get]
 The player preference identifier. More...
 
- Properties inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual string Header [get]
 Gets the header string used to describe the component. More...
 
virtual string DocLink [get]
 Gets a link to documentation site. More...
 
virtual string VideoLink [get]
 Gets a link to a youtube video. More...
 
virtual string Deprecated [get]
 If non-null this component is deprecated. The string shows a message indicating how it should be replaced. More...
 

Detailed Description

Static class for managing persistable objects.

Member Function Documentation

◆ CreateNewPersistableObjectManager()

static PersistableObjectManager PlatformerPro.PersistableObjectManager.CreateNewPersistableObjectManager ( bool  saveOnChange,
bool  useBinaryFormat 
)
static

Creates a new time manager.

◆ DoPendingSave()

void PlatformerPro.PersistableObjectManager.DoPendingSave ( object  sender,
PersistenceEventArgs  e 
)
protected

Trigger the saves in response to save event.

◆ GetSaveData()

List<PersistableObjectData> PlatformerPro.PersistableObjectManager.GetSaveData ( )
protected

Convert dictionary into savable list.

Returns
The save data.

◆ GetState()

PersistableObjectData PlatformerPro.PersistableObjectManager.GetState ( string  guid,
bool  defaultStateIsDisabled 
)

Gets the state for the object with the given guid. This is not a copy! Creates new state if the guid is not found.

Parameters
guidGUID.
defaultStateIsDisabledIf true the object starts disabled.

◆ HandleGameOver()

virtual void PlatformerPro.PersistableObjectManager.HandleGameOver ( object  sender,
DamageInfoEventArgs  e 
)
virtual

Handles the game ending.

Parameters
senderSender.
eEvent data.

◆ Init()

void PlatformerPro.PersistableObjectManager.Init ( )
protected

Init this instance.

◆ Load()

void PlatformerPro.PersistableObjectManager.Load ( )
protected

Load the saved data from prefs.

◆ LoadBinary()

virtual void PlatformerPro.PersistableObjectManager.LoadBinary ( )
protectedvirtual

Load the saved data from prefs in XMl format.

◆ LoadXml()

virtual void PlatformerPro.PersistableObjectManager.LoadXml ( )
protectedvirtual

Load the saved data from prefs in XMl format.

◆ ResetAll()

void PlatformerPro.PersistableObjectManager.ResetAll ( )

Reset persistable object state.

◆ ResetCurrentlevel()

void PlatformerPro.PersistableObjectManager.ResetCurrentlevel ( )

Reset persistable object state.

◆ Save()

void PlatformerPro.PersistableObjectManager.Save ( )

Updates persistable object state.

◆ SaveBinary()

virtual void PlatformerPro.PersistableObjectManager.SaveBinary ( )
protectedvirtual

Updates persistable object state using binary format.

◆ SaveXml()

virtual void PlatformerPro.PersistableObjectManager.SaveXml ( )
protectedvirtual

Updates persistable object state using XML format.

◆ SetState() [1/2]

void PlatformerPro.PersistableObjectManager.SetState ( string  guid,
bool  state,
string  extraInfo 
)

Sets the state for the object with the given guid.

Parameters
guidGUID.
stateState to set.
extraInfoExtra info.

◆ SetState() [2/2]

void PlatformerPro.PersistableObjectManager.SetState ( string  guid,
bool  state,
string  extraInfo,
string  spawnObjectName,
Vector3  spawnObjectPosition 
)

◆ SpawnObjects()

virtual void PlatformerPro.PersistableObjectManager.SpawnObjects ( IEnumerable< PersistableObjectData objectsToSpawn)
protectedvirtual

Spawns loaded objects.

Member Data Documentation

◆ allPrefsIdentifiers

List<string> PlatformerPro.PersistableObjectManager.allPrefsIdentifiers = new List<string> ()
staticprotected

Stores all pref kyes so we can reset data.

◆ binaryFormatter

BinaryFormatter PlatformerPro.PersistableObjectManager.binaryFormatter
staticprotected

A formatter used for binary serialisation.

◆ objectData

Dictionary<string, PersistableObjectData> PlatformerPro.PersistableObjectManager.objectData
protected

The persistence data.

◆ readyToSave

bool PlatformerPro.PersistableObjectManager.readyToSave
protected

Used to ensure that the will exit scene save happens at end of frame after all other objects have set their state.

◆ saveOnChange

bool PlatformerPro.PersistableObjectManager.saveOnChange
protected

Should we save data on change.

◆ UniqueDataIdentifier

const string PlatformerPro.PersistableObjectManager.UniqueDataIdentifier = "PersistableObjectManagerData"
static

The player preference identifier.

◆ useBinaryFormat

bool PlatformerPro.PersistableObjectManager.useBinaryFormat
protected

If true save files in a binary format. False use XML.

Property Documentation

◆ BinaryFormatter

BinaryFormatter PlatformerPro.PersistableObjectManager.BinaryFormatter
get

Get a binary formatter for use in saving.

◆ PlayerPrefsIdentifier

virtual string PlatformerPro.PersistableObjectManager.PlayerPrefsIdentifier
get

The player preference identifier.

◆ UseBinary

bool PlatformerPro.PersistableObjectManager.UseBinary
get

Should we use binary format?


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