Class HexTerrainSerializer
HexTerrainSerializer is a static class that provides methods to serialize and deserialize HexTerrain data entity.
Inherited Members
Namespace: Fwt.HexTerrains
Assembly: fwt.hexterrains.dll
Syntax
public static class HexTerrainSerializer
Fields
Version
Version of the serializer. Used for backward compatibility. Will be incremented when changes are added to the serialization/deserialization process.
Declaration
public static int Version
Field Value
| Type | Description |
|---|---|
| int |
Methods
Deserialize(BinaryReader, Entity, EntityManager, CustomDeserializerCallback)
Deserializes the terrain entity from a binary reader.
Declaration
public static bool Deserialize(BinaryReader reader, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomDeserializerCallback customDeserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| Entity | terrainEntity | |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomDeserializerCallback | customDeserializer | If provided, this function is called to give the user an ability to insert their own load data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
Deserialize(Stream, Entity, EntityManager, CustomDeserializerCallback)
Deserializes the terrain entity from a stream.
Declaration
public static bool Deserialize(Stream stream, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomDeserializerCallback customDeserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | stream to deserialize data from |
| Entity | terrainEntity | |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomDeserializerCallback | customDeserializer | If provided, this function is called to give the user an ability to insert their own load data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
LoadTerrainFromFile(string, Entity, EntityManager, CustomDeserializerCallback)
Loads the terrain entity from a file.
Declaration
public static bool LoadTerrainFromFile(string fileName, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomDeserializerCallback customDeserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fileName | full file path |
| Entity | terrainEntity | entity to put the extracted data on |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomDeserializerCallback | customDeserializer | If provided, this function is called to give the user an ability to insert their own load data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadCellEntitiesData(BinaryReader, CellEntitiesLayer, HexTerrainSettings)
Reads the cell entities data from a binary reader.
Declaration
public static bool ReadCellEntitiesData(BinaryReader reader, CellEntitiesLayer entitiesData, HexTerrainSettings terrainSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| CellEntitiesLayer | entitiesData | Entities data to deserialize data into |
| HexTerrainSettings | terrainSettings | Deserialized settings of the terrain |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadCellItemsData(BinaryReader, CellItemsLayer, HexTerrainSettings)
Reads the cell items data from a binary reader.
Declaration
public static bool ReadCellItemsData(BinaryReader reader, CellItemsLayer itemsData, HexTerrainSettings terrainSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| CellItemsLayer | itemsData | Items data to deserialize data into |
| HexTerrainSettings | terrainSettings | Deserialized settings of the terrain |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadSurfaceData(BinaryReader, HexSurfaceLayer, HexTerrainSettings)
Reads the surface data from a binary reader.
Declaration
public static bool ReadSurfaceData(BinaryReader reader, HexSurfaceLayer surfaceData, HexTerrainSettings terrainSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| HexSurfaceLayer | surfaceData | Surface data to deserialize data into |
| HexTerrainSettings | terrainSettings | Deserialized settings of the terrain |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadTerrainByteAreas(BinaryReader, HexByteAreasLayer, HexTerrainSettings)
Reads the terrain areas data from a binary reader.
Declaration
public static bool ReadTerrainByteAreas(BinaryReader reader, HexByteAreasLayer areasData, HexTerrainSettings terrainSettings)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| HexByteAreasLayer | areasData | Areas data to deserialize data into |
| HexTerrainSettings | terrainSettings | Deserialized settings of the terrain |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadTerrainSettings(BinaryReader)
Reads the terrain settings from a binary reader.
Declaration
public static HexTerrainSettings ReadTerrainSettings(BinaryReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
Returns
| Type | Description |
|---|---|
| HexTerrainSettings | deserialized terrain settings |
ReadToNativeList(BinaryReader, NativeList<CellEntity>)
Reads a native list of CellEntity from a binary reader.
Declaration
public static bool ReadToNativeList(this BinaryReader reader, NativeList<CellEntity> list)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| NativeList<CellEntity> | list | List to deserialize data into |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadToNativeList(BinaryReader, NativeList<CellItem>)
Reads a native list of CellItem from a binary reader.
Declaration
public static bool ReadToNativeList(this BinaryReader reader, NativeList<CellItem> list)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| NativeList<CellItem> | list | List to deserialize data into |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
ReadVersion1(BinaryReader, Entity, EntityManager, HexTerrainSettings, CustomDeserializerCallback)
Reads the terrain entity data from a binary reader. Called if the data was saved by a Serializer of version 1 or more.
Declaration
public static bool ReadVersion1(BinaryReader reader, Entity terrainEntity, EntityManager entityManager, HexTerrainSettings terrainSettings, HexTerrainSerializer.CustomDeserializerCallback customDeserializer)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryReader | reader | binary reader that deserializes a terrain data |
| Entity | terrainEntity | |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSettings | terrainSettings | Deserialized settings of the terrain that is being deserialized |
| HexTerrainSerializer.CustomDeserializerCallback | customDeserializer | If provided, this function is called to give the user an ability to insert their own load data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
SaveTerrainToFile(string, Entity, EntityManager, CustomSerializerCallback)
Saves the terrain entity to a file.
Declaration
public static bool SaveTerrainToFile(string filePath, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomSerializerCallback customSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | full path to the file |
| Entity | terrainEntity | terrain entity to save |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomSerializerCallback | customSerializer | If provided, this function is called to give the user an ability to insert their own save data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
Serialize(BinaryWriter, Entity, EntityManager, CustomSerializerCallback)
Serializes the terrain entity using a binary writer
Declaration
public static bool Serialize(BinaryWriter writer, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomSerializerCallback customSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain data |
| Entity | terrainEntity | terrain entity to serialize |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomSerializerCallback | customSerializer | If provided, this function is called to give the user an ability to insert their own save data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
Serialize(Stream, Entity, EntityManager, CustomSerializerCallback)
Serializes the terrain entity to a stream.
Declaration
public static bool Serialize(Stream stream, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomSerializerCallback customSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | stream to serialize an entity into |
| Entity | terrainEntity | terrain entity to serialize |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomSerializerCallback | customSerializer | If provided, this function is called to give the user an ability to insert their own save data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
Write(BinaryWriter, CellEntity)
Writes a CellEntity to the binary writer.
Declaration
public static bool Write(this BinaryWriter writer, CellEntity cellEntity)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| CellEntity | cellEntity |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
Write(BinaryWriter, CellItem)
Writes a CellItem to the binary writer.
Declaration
public static bool Write(this BinaryWriter writer, CellItem cellItem)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| CellItem | cellItem | data to serialize |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
WriteCellEntitiesData(BinaryWriter, CellEntitiesLayer)
Writes the cell entities data to the binary writer.
Declaration
public static void WriteCellEntitiesData(BinaryWriter writer, CellEntitiesLayer entitiesData)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| CellEntitiesLayer | entitiesData | entities data to serialize |
WriteCellItemsData(BinaryWriter, CellItemsLayer)
Writes the cell items data to the binary writer.
Declaration
public static void WriteCellItemsData(BinaryWriter writer, CellItemsLayer itemsData)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| CellItemsLayer | itemsData | items data to serialize |
WriteNativeArray(BinaryWriter, NativeArray<CellEntity>)
Writes a native array of CellEntity to the binary writer.
Declaration
public static bool WriteNativeArray(this BinaryWriter writer, NativeArray<CellEntity> array)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| NativeArray<CellEntity> | array | data to serialize |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
WriteNativeArray(BinaryWriter, NativeArray<CellItem>)
Writes a native array of CellItem to the binary writer.
Declaration
public static bool WriteNativeArray(this BinaryWriter writer, NativeArray<CellItem> array)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| NativeArray<CellItem> | array | data to serialize |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
WriteSurfaceData(BinaryWriter, HexSurfaceLayer)
Writes the surface data to the binary writer.
Declaration
public static bool WriteSurfaceData(BinaryWriter writer, HexSurfaceLayer surfaceData)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| HexSurfaceLayer | surfaceData | surface data to serialize |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
WriteTerrainByteAreas(BinaryWriter, HexByteAreasLayer)
Writes the terrain areas data to the binary writer.
Declaration
public static void WriteTerrainByteAreas(BinaryWriter writer, HexByteAreasLayer areasData)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain |
| HexByteAreasLayer | areasData | area data to serialize |
WriteTerrainSettings(HexTerrainSettings, BinaryWriter)
Writes the terrain settings to the binary writer.
Declaration
public static bool WriteTerrainSettings(HexTerrainSettings terrainSettings, BinaryWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| HexTerrainSettings | terrainSettings | terrain settings to write |
| BinaryWriter | writer | binary writer that serializes the terrain |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |
WriteTypeHash(BinaryWriter, ComponentType)
Writes the type hash of the component type to the binary writer.
Declaration
public static void WriteTypeHash(BinaryWriter writer, ComponentType componentType)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain data |
| ComponentType | componentType | type of the component data that is being serialized |
WriteVersion1(BinaryWriter, Entity, EntityManager, CustomSerializerCallback)
Writes the terrain entity data to a binary writer. Called if the Serializer version is 1 or more.
Declaration
public static bool WriteVersion1(BinaryWriter writer, Entity terrainEntity, EntityManager entityManager, HexTerrainSerializer.CustomSerializerCallback customSerializer)
Parameters
| Type | Name | Description |
|---|---|---|
| BinaryWriter | writer | binary writer that serializes the terrain data |
| Entity | terrainEntity | terrain entity to serialize |
| EntityManager | entityManager | entity manager from the world the terrain entity lives |
| HexTerrainSerializer.CustomSerializerCallback | customSerializer | If provided, this function is called to give the user an ability to insert their own save data layer logic |
Returns
| Type | Description |
|---|---|
| bool | true if successfull, otherwise - false |