Skip to content

DS_BaseGrid

Kamran Wali edited this page Dec 13, 2024 · 11 revisions

Inherits: Node

Inherited By ds_grid_rect

Base class for all the stage grid objects.

Description

DS_BaseGrid is the parent/base class for all the stage grid scripts in the tool/plugin Duniya Skapare. This script has been designed in a way that every current or new stage grid shape or algorithm scripts will need to extend from DS_BaseGrid. That way it will be easier to keep the grid types organized and having common parent. This will also help in making sure that the grid scripts can be just dragged and dropped into other scripts that will use the grid script and it will work no matter the different grid script, SOLID principles. Well that is the idea for now.

Properties

Type Name Default Value
int _grid_x 3
int _grid_y 3
int _grid_z 0
bool _is_start_setup true
DS_Tile[] _tiles

Methods

Return Type Name
int get_grid_size_x()
int get_grid_size_y()
int get_grid_size_z()
int get_grid_size()
int get_tiles_size()
DS_Tile get_tile( int index )
void add_tile( DS_Tile tile )
DS_Tile get_tile_coord_grid( DS_Tile tile, DS_Tile[] grid )
DS_Tile get_tile_coord( DS_Tile tile )
DS_Tile get_tile_coord_x_y_z_grid( int x, int y, int z, DS_Tile[] grid )
DS_Tile get_tile_coord_x_y_z
bool has_tile_coord_grid( DS_Tile tile, DS_Tile[] grid )
bool has_tile_coord( DS_Tile tile )
bool has_tile_coord_x_y_z_grid( int x, int y, int z, DS_Tile[] grid )
void setup()
void set_custom_coords( int x, int y, int z )
void reset()
String show_grid_tile()
String show_grid_tile_index( int index )
String show_grid_tile_array( int[] tiles )
String show_grid_tile_rot()
String show_grid_tile_rot_index( int index )
String show_grid_tile_rot_array( int[] tiles )
String show_grid_index()
String show_grid_index_index( int index )
String show_grid_index_array( int[] tiles )
String show_grid_coord()
String show_grid_coord_index( int index )
String show_grid_coord_array(int[] tiles)
bool _is_grid()

Property Descriptions

int _grid_x = 3

The maximum length in the x coordinate. Minimum value of _grid_x is 1. Starting x coordinate value is 0.


int _grid_y = 3

The maximum length in the y coordinate. Minimum value of _grid_y is 1. Starting y coordinate value is 0.


int _grid_z = 0

The maximum length in the z coordinate. Minimum value of _grid_z is 0. Starting z coordinate value is 0.

Note: The _grid_z is permanently set to 0 because at the moment _grid_z higher than 0 seems to cause problem in some algorithms. Once issues have been fixed _grid_z will be enabled again for the user to be set.


bool _is_start_setup = true

This flag checks if the grid should be setup when the application starts. True means the grid will be setup automatically when the application starts. False means the grid will NOT be setup automatically.

Note: If the flag is disabled, meaning automatic setup is disabled, then you MUST call the method setup() manually through other scripts. If the setup() is NOT called then a null error will be thrown.


DS_Tile[] _tiles

An array that contains all the tiles for the grid.


Method Descriptions

int get_grid_size_x ()

This method gets the x-axis size of the grid which is the _grid_x property.


int get_grid_size_y ()

This method gets the y-axis size of the grid which is the _grid_y property.


int get_grid_size_z ()

This method gets the z-axis size of the grid which is the _grid_z property.


int get_grid_size ()

This method gets the total size of the grid.


int get_tiles_size ()

This method gets the size of _tiles array.


DS_Tile get_tile ( int index )

This method gets the indexth tile, DS_Tile.


void add_tile ( DS_Tile tile )

This method adds a tile to the _tiles array.


DS_Tile get_tile_coord_grid ( DS_Tile tile, DS_Tile[] grid )

This method checks if the given tile exists in the given grid's tiles array and if it does exists then it will return the given tile otherwise it will return null.


DS_Tile get_tile_coord( DS_Tile tile )

This method checks if the given tile exists in the current grid's _tiles array and if it does exists then it will return the given tile otherwise it will return null.


DS_Tile get_tile_coord_x_y_z_grid ( int x, int y, int z, DS_Tile[] grid )

This method searches for the x, y and z coordinated tile in the given grid and returns it.


DS_Tile get_tile_coord_x_y_z ( int x, int y, int z )

This method searches for the x, y and z coordinated tile in the _tiles array and returns it.


bool has_tile_coord_grid ( DS_Tile tile, DS_Tile[] grid )

This method checks if the given tile exists in the given grid.


bool has_tile_coord ( DS_Tile tile )

This method checks if the given tile exists in the _tiles array.


bool has_tile_coord_x_y_z_grid ( int x, int y, int z, DS_Tile[] grid )

This method checks if the given coordinates x, y and z exists in the given grid. True means the tile in the coordinate exists, false otherwise.


void setup () virtual

This method sets up the grid.


void set_custom_coords ( int x, int y, int z ) virtual

This method sets the custom co-ordinates for the tiles from which the tiles' co-ordinates will start. Default is 0. Example: If -1 is given for x axis and the grid size is 3X3 then the co-ordinates for x will be -1, 0 and 1.


void reset () virtual

This method resets the grid.


String show_grid_tile () virtual

This method returns the grid in string format. The gird's _tiles information are shown. Use this for debugging.


String show_grid_tile_index ( int index ) virtual

This method returns the grid in string format. The gird's _tiles information are shown. It also highlights the index tile. Use this for debugging.


String show_grid_tile_array ( int[] tiles ) virtual virtual

This method returns the grid in string format. The gird's _tiles information are shown. It also highlights all the given tiles. The first tile in the array tiles is highlighted green and the rest are blue. Use this for debugging.


String show_grid_tile_rot () virtual virtual virtual

This method returns the grid in string format. The gird's _tiles's rotation information are shown. Use this for debugging.


String show_grid_tile_rot_index ( int index ) virtual

This method returns the grid in string format. The gird's _tiles's rotation information are shown. It also highlights the index tile. Use this for debugging.


String show_grid_tile_rot_array ( int[] tiles ) virtual

This method returns the grid in string format. The gird's _tiles's rotation information are shown. It also highlights all the given tiles. The first tile in the array tiles is highlighted green and the rest are blue. Use this for debugging.


String show_grid_index () virtual

This method returns the grid in string format. The gird's _tiles's index information are shown. Use this for debugging.


String show_grid_index_index ( int index ) virtual

This method returns the grid in string format. The gird's _tiles's index information are shown. It also highlights the index tile. Use this for debugging.


String show_grid_index_array ( int[] tiles ) virtual

This method returns the grid in string format. The gird's _tiles's index information are shown. It also highlights all the given tiles. The first tile in the array tiles is highlighted green and the rest are blue. Use this for debugging.


String show_grid_coord () virtual

This method returns the grid in string format. The gird's _tiles's coordinate information are shown. Use this for debugging.


String show_grid_coord_index ( int index ) virtual

This method returns the grid in string format. The gird's _tiles's coordinate information are shown. It also highlights the index tile. Use this for debugging.


String show_grid_coord_array ( int[] tiles ) virtual

This method returns the grid in string format. The gird's _tiles's coordinate information are shown. It also highlights all the given tiles. The first tile in the array tiles is highlighted green and the rest are blue. Use this for debugging.


bool _is_grid ()

This method always returns true as the script is a grid script. This method is needed for duck typing check and SHOULD NOT be OVERRIDDEN!


Clone this wiki locally