LokStorageAccessorVersion

Inherits:

The LokStorageAccessorVersion resource describes how data is saved and loaded from a LokStorageAccessor in a specific version.

Description

The purpose of this class is to provide different behaviors of how data is dealt with accross different versions of the game that require changes in the save files organization. In order to achieve that, this class should be extended so that different implementations of the _retrieve_data and _consume_data methods can be created for different versions of a LokStorageAccessor.

Version: 1.0.0 Author: github.com/nadjiel <github.com/nadjiel>_

Property Index

Type

Name

Default value

String

number

"1.0.0"

Method Index

Property Descriptions

String number = "1.0.0"

The number property specifies what version of LokStorageAccessor this LokStorageAccessorVersion corresponds to. Initially this is set to "1.0.0", which is the default version. If you don’t intend to version your save data, you can always just leave this as default.

Method Descriptions

LokStorageAccessorVersion create(String _number = "1.0.0")

The create method is a utility to create a new LokStorageAccessorVersion with its properties already set to the desired values.

String version)

The get_version_parts method returns an Array with the substrings separated by "." that compose the number of this LokStorageAccessorVersion.

String get_minor_version(LokStorageAccessorVersion version)

The get_minor_version method returns a String with the minor version in the number of this LokStorageAccessorVersion.

String get_patch_version(LokStorageAccessorVersion version)

The get_patch_version method returns a String with the patch version in the number of this LokStorageAccessorVersion.

String get_major_version(LokStorageAccessorVersion version)

The get_major_version method returns a String with the major version in the number of this LokStorageAccessorVersion.

int compare_versions(LokStorageAccessorVersion version1, LokStorageAccessorVersion version2)

The compare_versions method returns an int representing if two LokStorageAccessorVersion <LokStorageAccessorVersion>`s are less than (`-1``), equal (0) or greater than (1) one another.

int compare_minor_versions(LokStorageAccessorVersion version1, LokStorageAccessorVersion version2)

The compare_minor_versions method returns an int representing if the minor versions of two LokStorageAccessorVersion <LokStorageAccessorVersion>`s are less than (`-1``), equal (0) or greater than (1) one another.

int compare_patch_versions(LokStorageAccessorVersion version1, LokStorageAccessorVersion version2)

The compare_patch_versions method returns an int representing if the patch versions of two LokStorageAccessorVersion <LokStorageAccessorVersion>`s are less than (`-1``), equal (0) or greater than (1) one another.

int compare_major_versions(LokStorageAccessorVersion version1, LokStorageAccessorVersion version2)

The compare_major_versions method returns an int representing if the major versions of two LokStorageAccessorVersion <LokStorageAccessorVersion>`s are less than (`-1``), equal (0) or greater than (1) one another.

Dictionary _retrieve_data(Dictionary _dependencies)

The _retrieve_data method should be overriden by concrete implementations of LokStorageAccessorVersion should store. This method receives a dependencies Dictionary that brings all information from the LokStorageAccessor.dependency_paths, so that this LokStorageAccessorVersion can access it. Any NodePath’s values are converted to nodes before being passed to this method so that they can be easily referenced by this LokStorageAccessorVersion. When finished processing, this method should return a Dictionary with the data that should be stored in a save file. If you’re using the LokJSONAccessStrategy or the LokEncryptedAccessStrategy (the built-in strategies of the LockerPlugin), the returned Dictionary should only store basic data types like String <String>`s, ``floats` and bools, so you need to make sure to transform your data accordingly. For parsing from complex data types like Vector2 method.

void _consume_data(Dictionary _data, Dictionary _dependencies)

The _consume_data method should be overriden by concrete implementations of LokStorageAccessorVersion <LokStorageAccessorVersion>`s in order to define what happens to the ``data` it receives when the game is loaded. This method receives a dependencies Dictionary that brings all information from the LokStorageAccessor.dependency_paths, so that this LokStorageAccessorVersion can access it. Any NodePath’s values are converted to nodes before being passed to this method so that they can be easily referenced by this LokStorageAccessorVersion. If you’re using the LokJSONAccessStrategy or the LokEncryptedAccessStrategy (the built-in strategies of the LockerPlugin), the data Dictionary will only be capable of storing basic data types like String <String>`s, ``floats` and bools, so you need to make sure to transform your data accordingly. For parsing from String to complex data types like Vector2 method.