A* Pathfinding Project
3.8.5
The A* Pathfinding Project for Unity 3D
|
Handles low level serialization and deserialization of graph settings and data. More...
Handles low level serialization and deserialization of graph settings and data.
Mostly for internal use. You can use the methods in the AstarData class for higher level serialization and deserialization.
Public Member Functions | |
AstarSerializer (AstarData data) | |
AstarSerializer (AstarData data, SerializeSettings settings) | |
void | CloseDeserialize () |
byte[] | CloseSerialize () |
void | DeserializeEditorSettings (GraphEditorBase[] graphEditors) |
Deserializes graph editor settings. | |
void | DeserializeExtraInfo () |
Deserializes extra graph info. | |
NavGraph[] | DeserializeGraphs () |
Deserializes graph settings. | |
uint | GetChecksum () |
bool | OpenDeserialize (byte[] bytes) |
void | OpenSerialize () |
void | PostDeserialization () |
Calls PostDeserialization on all loaded graphs. | |
byte[] | Serialize (NavGraph graph) |
Serializes the graph settings to JSON and returns the data. | |
void | SerializeEditorSettings (GraphEditorBase[] editors) |
void | SerializeExtraInfo () |
void | SerializeGraphs (NavGraph[] _graphs) |
void | SerializeNodes () |
Deprecated method to serialize node data. | |
void | SetGraphIndexOffset (int offset) |
Static Public Member Functions | |
static byte[] | LoadFromFile (string path) |
Load the specified data from the specified path. | |
static void | SaveToFile (string path, byte[] data) |
Save the specified data at the specified path. | |
Private Member Functions | |
void | AddChecksum (byte[] bytes) |
bool | AnyDestroyedNodesInGraphs () |
GraphMeta | DeserializeBinaryMeta (ZipEntry entry) |
bool | DeserializeExtraInfo (NavGraph graph) |
NavGraph | DeserializeGraph (int zipIndex, int graphIndex) |
GraphMeta | DeserializeMeta (ZipEntry entry) |
void | DeserializeNodeLinks (GraphNode[] int2Node) |
GraphNode[] | DeserializeNodeReferenceMap () |
void | DeserializeNodeReferences (NavGraph graph, GraphNode[] int2Node) |
byte[] | SerializeMeta () |
Serialize metadata about all graphs. | |
byte[] | SerializeNodeLinks () |
Static Private Member Functions | |
static void | CloseOrDispose (BinaryWriter writer) |
static System.Version | FullyDefinedVersion (System.Version v) |
Returns a version with all fields fully defined. | |
static BinaryReader | GetBinaryReader (ZipEntry entry) |
Returns a binary reader for the data in the zip entry. | |
static int | GetMaxNodeIndexInAllGraphs (NavGraph[] graphs) |
static string | GetString (ZipEntry entry) |
Returns the data in the zip entry as a string. | |
static System.Text.StringBuilder | GetStringBuilder () |
Returns a cached StringBuilder. | |
static byte[] | SerializeGraphExtraInfo (NavGraph graph) |
Serializes info returned by NavGraph.SerializeExtraInfo. | |
static byte[] | SerializeGraphNodeReferences (NavGraph graph) |
Used to serialize references to other nodes e.g connections. | |
static byte[] | SerializeNodeIndices (NavGraph[] graphs) |
Private Attributes | |
const string | binaryExt = ".binary" |
Extension to use for binary files. | |
uint | checksum = 0xffffffff |
Checksum for the serialized data. | |
AstarData | data |
System.Text.UTF8Encoding | encoding = new System.Text.UTF8Encoding() |
Dictionary< NavGraph, int > | graphIndexInZip |
Index used for the graph in the file. | |
int | graphIndexOffset |
NavGraph[] | graphs |
Graphs that are being serialized or deserialized. | |
const string | jsonExt = ".json" |
Extension to use for json files. | |
GraphMeta | meta |
Graph metadata. | |
SerializeSettings | settings |
Settings for serialization. | |
ZipFile | zip |
Zip which the data is loaded from. | |
MemoryStream | zipStream |
Memory stream with the zip data. | |
Static Private Attributes | |
static System.Text.StringBuilder | _stringBuilder = new System.Text.StringBuilder() |
Cached StringBuilder to avoid excessive allocations. | |
AstarSerializer | ( | AstarData | data | ) |
AstarSerializer | ( | AstarData | data, |
SerializeSettings | settings | ||
) |
|
private |
|
private |
void CloseDeserialize | ( | ) |
|
staticprivate |
byte [] CloseSerialize | ( | ) |
|
private |
void DeserializeEditorSettings | ( | GraphEditorBase[] | graphEditors | ) |
Deserializes graph editor settings.
For future compatibility this method does not assume that the graphEditors array matches the graphs array in order and/or count. It searches for a matching graph (matching if graphEditor.target == graph) for every graph editor. Multiple graph editors should not refer to the same graph.
|
private |
void DeserializeExtraInfo | ( | ) |
Deserializes extra graph info.
Extra graph info is specified by the graph types.
|
private |
NavGraph [] DeserializeGraphs | ( | ) |
Deserializes graph settings.
|
private |
|
private |
|
private |
|
staticprivate |
Returns a version with all fields fully defined.
This is used because by default new Version(3,0,0) > new Version(3,0). This is not the desired behaviour so we make sure that all fields are defined here
|
staticprivate |
Returns a binary reader for the data in the zip entry.
uint GetChecksum | ( | ) |
|
staticprivate |
|
staticprivate |
Returns the data in the zip entry as a string.
|
staticprivate |
Returns a cached StringBuilder.
This function only has one string builder cached and should thus only be called from a single thread and should not be called while using an earlier got string builder.
|
static |
Load the specified data from the specified path.
bool OpenDeserialize | ( | byte[] | bytes | ) |
void OpenSerialize | ( | ) |
void PostDeserialization | ( | ) |
Calls PostDeserialization on all loaded graphs.
|
static |
Save the specified data at the specified path.
byte [] Serialize | ( | NavGraph | graph | ) |
Serializes the graph settings to JSON and returns the data.
void SerializeEditorSettings | ( | GraphEditorBase[] | editors | ) |
void SerializeExtraInfo | ( | ) |
|
staticprivate |
Serializes info returned by NavGraph.SerializeExtraInfo.
|
staticprivate |
Used to serialize references to other nodes e.g connections.
Nodes use the GraphSerializationContext.GetNodeIdentifier and GraphSerializationContext.GetNodeFromIdentifier methods for serialization and deserialization respectively.
void SerializeGraphs | ( | NavGraph[] | _graphs | ) |
|
private |
Serialize metadata about all graphs.
|
staticprivate |
|
private |
void SerializeNodes | ( | ) |
Deprecated method to serialize node data.
void SetGraphIndexOffset | ( | int | offset | ) |
|
staticprivate |
Cached StringBuilder to avoid excessive allocations.
|
private |
Extension to use for binary files.
|
private |
Checksum for the serialized data.
Used to provide a quick equality check in editor code
|
private |
|
private |
|
private |
Index used for the graph in the file.
If some graphs were null in the file then graphIndexInZip[graphs[i]] may not equal i. Used for deserialization.
|
private |
|
private |
Graphs that are being serialized or deserialized.
|
private |
Extension to use for json files.
|
private |
Graph metadata.
|
private |
Settings for serialization.
|
private |
Zip which the data is loaded from.
|
private |
Memory stream with the zip data.