Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes

Unigine::TileSetFile Class

Header:#include <UnigineTilesetFile.h>

This class is used to create a tileset file — the file that keeps data that is based on X and Y indices. The values of X and Y are limited to the integer and can be both positive and negative. The maximum size of the tile is limited to 2Gb. The maximum size of a tileset is limited to the unsigned integer value. Tileset files are stored using the .UTS and .UTSH formats. To unpack the file, use the TilesetFile console tool.

TilesetFile Class

Members


static TilesetFilePtr create()

Constructor. Creates a tileset file.

int getNumTiles()

Returns the number of tiles in the tileset file.

Return value

Number of tiles.

long long getOffset(int x, int y)

Returns the offset for the tile with specified coordinates.

Arguments

  • int x - X-coordinate value.
  • int y - Y-coordinate value.

Return value

Offset value.

int isOpened()

Returns a value indicating if the tileset file is opened.

Return value

1 if the tileset file is opened; otherwise, 0.

int isOwner()

Returns the owner flag. If the pointer is the owner, on its deletion the tileset file also will be deleted. Use grab() and release() functions to change ownership.

Return value

Owner flag.

int setTile(int x, int y, unsigned char * data, int force = 1)

Sets the data of the specified tile by copying from the source buffer.

Arguments

  • int x - X-coordinate value.
  • int y - Y-coordinate value.
  • unsigned char * data - Source buffer.
  • int force - Force flag.
    • If 1 is specified, the data will be updated immediately.
    • If 0 is specified, the data will be updated only when the flushHeader() method is called.
    Notice
    To improve performance it is recommended to set this flag to 0 to accumulate multiple tile update operations and apply them all at once by calling the flushHeader() method.

Return value

1, if the operation was successful; otherwise, 0.

int getTile(int x, int y, unsigned char * data)

Copies the data of the specified tile to the destination buffer.

Arguments

  • int x - X-coordinate value.
  • int y - Y-coordinate value.
  • unsigned char * data - Destination buffer.

Return value

1, if the operation was successful; otherwise, 0.

int getTilePos(int num, int & x, int & y)

Retrieves the coordinates of the tile with a given index and puts them to x and y respectively.

Arguments

  • int num - Tile index.
  • int & x - X-coordinate of the tile.
  • int & y - Y-coordinate of the tile.

Return value

1, if the operation was successful; otherwise, 0.

int getTileSize()

Returns the size of the tile for the tileset file.

Return value

Tile size.

int close()

Closes the tileset file.

Return value

1, if the operation was successful; otherwise, 0.

int createFile(const char * name, int tile_size)

Creates a tileset file with a given name and tile size.

Arguments

  • const char * name - File name.
  • int tile_size - Tile size.

Return value

1, if the operation was successful; otherwise, 0.

int flushHeader()

Applies all pending setTile() and removeTile() operations.

Return value

1, if the operation was successful; otherwise, 0.

void grab()

Grabs the tileset file (sets the owner flag to 1). The tileset file should not be handled by the engine after this function is called.

int hasTile(int x, int y)

Returns a value indicating if there is a tile with the specified coordinates in the file.

Arguments

  • int x - X-coordinate value.
  • int y - Y-coordinate value.

Return value

1, if the file contains the specified tile; otherwise, 0.

int load(const char * name)

Loads the given tileset file.

Arguments

  • const char * name - File name.

Return value

1, if the operation was successful; otherwise, 0.

void release()

Releases the tileset file (sets the owner flag to 0). The tileset file should be handled by the engine after this function is called.

int removeTile(int x, int y, int force = 1)

Removes the tile with specified coordinates from the file.

Arguments

  • int x - X-coordinate value.
  • int y - Y-coordinate value.
  • int force - Force flag.
    • If 1 is specified, the data will be updated immediately.
    • If 0 is specified, the data will be updated only when the flushHeader() method is called.
    Notice
    To improve performance it is recommended to set this flag to 0 to accumulate multiple tile update operations and apply them all at once by calling the flushHeader() method.

Return value

1, if the operation was successful; otherwise, 0.

int CLOSED

Description

The tileset file is closed.

int READING

Description

The system is reading from the tileset class.

int WRITING

Description

The system is writing to the tileset class.
Last update: 2017-07-03