Godot RGMap
rgmap.h
1#ifndef RGMAP_H
2#define RGMAP_H
3
4#define _USE_MATH_DEFINES
5
6#include <Godot.hpp>
7#include <Node.hpp>
8#include <Vector2.hpp>
9#include <Array.hpp>
10#include <AStar2D.hpp>
11#include <Rect2.hpp>
12#include <TileSet.hpp>
13#include <Texture.hpp>
14#include <ShaderMaterial.hpp>
15#include <Color.hpp>
16#include <Dictionary.hpp>
17#include <cmath>
18#include <vector>
19#include <algorithm>
20
21namespace godot {
41class RGMap : public Reference {
42 GODOT_CLASS(RGMap, Node)
43
44 // Structure needed for RPAS algorithm
45 struct CellAngles{
46 float near;
47 float center;
48 float far;
49 };
50
51 // Structure that stores data about one type of tile
52 struct RGTile {
53 String name;
54 String display_name;
55 bool passable = false;
56 bool transparent = false;
57 Dictionary custom_properties;
58 int z_index = 0;
59 Ref<Texture> texture;
60 Ref<Texture> normal_map;
61 Vector2 texture_offset = Vector2(0,0);
62 Ref<ShaderMaterial> material;
63 Color modulate = Color(1.0,1.0,1.0);
64 };
65
66 // Structure of one chunk
67 struct Chunk {
68 // Flat arrays that contain all data about the cells
69 std::vector<int> values;
70 std::vector<int> memory;
71 std::vector<int> entities;
72 bool loaded = false;
73 bool rendered = false;
74 };
75
76 // Structure of entity
77 struct Entity {
78 Vector2 position = Vector2(0,0);
79 bool passable = true;
80 bool transparent = true;
81 bool discovered = false;
82 bool rewrite = false;
83 };
84
85private:
86 // All tiles in a game
87 std::vector<RGTile> tiles;
88 // Store all chunks
89 std::vector<Chunk> chunks;
90 // Epsilon for float error calculation
91 const float FLOAT_EPSILON = 0.00001;
92 // Visibility of cells within fov radius. Temporary variable
93 std::vector<int> visibility;
94 // Opaque obstacles for FOV. Temporary variable
95 std::vector<int> fov_obstacles;
96 // Current fov zone
97 Rect2 fov_zone = Rect2(Vector2(0,0), Vector2(0,0));
98 std::vector<Vector2> pathfinding_exception_allowed;
99 std::vector<Vector2> pathfinding_exception_disallowed;
100 // Number of Arrays stored in Chunk structure
101 const int NUM_CHUNK_ARRAYS = 2;
102 // Array with all registered entities
103 std::vector<Entity> entities;
104 // Ids of loaded chunks
105 std::vector<int> loaded_chunks;
106 // Ids of rendered chunks
107 std::vector<int> rendered_chunks;
108 // Dictionary with custom tile property names as keys and their default values
109 Dictionary custom_tile_properties;
110
111 // Functions for Restrictive Precise Angle Shadowcasting. More details in rpas.cpp
112 PoolVector2Array rpas_visible_cells_in_quadrant_from(Vector2 center, Vector2 quad, int radius);
113 PoolVector2Array rpas_visible_cells_in_octant_from(Vector2 center, Vector2 quad, int radius, bool is_vertical);
114 Vector2 rpas_cell_at(Vector2 center, Vector2 quad, int step, int iteration, bool is_vertical);
115 bool rpas_cell_in_radius(Vector2 center, Vector2 cell, int radius);
116 bool rpas_cell_is_visible(CellAngles cell_angles, std::vector<CellAngles>& obstructions);
117 void rpas_add_obstruction(std::vector<CellAngles> & obstructions, CellAngles new_obstruction);
118 bool rpas_combine_obstructions(CellAngles &old_o, CellAngles &new_o);
119 // Draw points based on 4-way symmetry (for Bresenham's ellipse algorithm)
120 void draw_4_way_symmetry(int xc, int yc, int x, int y, int value, float start_angle, float end_angle);
121
122 // Get a set of points in Bresenham's line
123 PoolVector2Array get_line_bresenham(Vector2 start, Vector2 end, bool allow_diagonal);
124 // Draw ellipse using Bresenham's midpoint algorithm
125 void draw_ellipse_bresenham(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value, bool allow_diagonal);
126 // Get loaded chunk
127 Chunk& get_chunk(int index);
128 // Find path from start to end using A* algorithm
129 PoolVector2Array _find_path(Vector2 start, Vector2 end, Rect2 pathfinding_zone, bool exclude_undiscovered=false);
130
131public:
136
138 Vector2 chunk_size = Vector2(50,50);
140 Vector2 size = Vector2(3,3);
142
148
156
161
163 int fov_radius = 15;
165 float RPAS_RADIUS_FUDGE = 1.0 / 3.0;
169
178
179 // Note: these functions placed here to ease documentation generation with Doxygen
180 // Tell me if you know a better way to do so
184
185
187 PoolIntArray chunks_load_requested() {return PoolIntArray();}
189 PoolIntArray chunks_free_requested() {return PoolIntArray();}
191 PoolIntArray chunks_render_requested() {return PoolIntArray();}
193 PoolIntArray chunks_hide_requested() {return PoolIntArray();}
195 int chunk_loaded() {return 0;}
197 int chunk_freed() {return 0;}
199
202
203 static void _register_methods();
204 RGMap();
205 ~RGMap();
206 void _init();
207 void _ready();
209
210 // tiles.cpp
214
215
217
221 int add_tile(String name, String display_name);
223 void set_tile_transparency(int index, bool value);
225 void set_tile_passability(int index, bool value);
227
231 void add_tile_property(String property_name, Variant default_value);
233 void set_tile_z_index(int index, int z_index);
235 void set_tile_texture_offset(int index, Vector2 offset);
237 void set_tile_texture(int index, Ref<Texture> texture);
239 void set_tile_normal_map(int index, Ref<Texture> texture);
241 void set_tile_material(int index, Ref<Material> material);
243 void set_tile_modulate(int index, Color color);
245 void set_tile_property(int index, String property_name, Variant new_value);
247 int get_tiles_count();
249 int get_tile_index(String name);
251 String get_tile_name(int index);
253 String get_tile_display_name(int index);
255 bool is_tile_passable(int index);
257 bool is_tile_transparent(int index);
259 int get_tile_z_index(int index);
261 Vector2 get_tile_texture_offset(int index);
263 Ref<Texture> get_tile_texture(int index);
265 Ref<Texture> get_tile_normal_map(int index);
267 Ref<Material> get_tile_material(int index);
269 Color get_tile_modulate(int index);
271 Variant get_tile_property(int index, String property_name);
273 Ref<TileSet> generate_tileset();
275
276 // chunks.cpp
280
281
283 int get_chunk_index(Vector2 position);
285 Vector2 chunk_index_int_to_v2(int index);
287 int chunk_index_v2_to_int(Vector2 index);
289 bool is_chunk_in_bounds(int index);
291 bool is_chunk_loaded(int index);
293 void load_chunk(int index, PoolIntArray data = PoolIntArray());
295 PoolIntArray dump_chunk_data(int index);
297 void free_chunk(int index);
299 void reset_chunk(int index);
301 bool is_chunk_rendered(int index);
303 void set_chunk_rendered(int index, bool value);
305 PoolIntArray get_loaded_chunks();
307 PoolIntArray get_chunks_in_distance(Vector2 point, int distance);
309
314 PoolIntArray get_chunks_to_load(Vector2 player_position);
316
320 PoolIntArray get_chunks_to_free(Vector2 player_position);
322
328 void request_chunks_load(Vector2 player_position);
330 PoolIntArray get_rendered_chunks();
332
337 PoolIntArray get_chunks_to_render(Vector2 player_position);
339
343 PoolIntArray get_chunks_to_hide(Vector2 player_position);
345
351 void request_chunks_render(Vector2 player_position);
353
354 // cells.cpp
358
359
361 int get_local_index(Vector2 position);
363 int get_value(Vector2 position);
365 String get_name(Vector2 position);
367 String get_display_name(Vector2 position);
369 Variant get_property(Vector2 position, String property_name);
371 bool is_in_bounds(Vector2 position);
373 bool is_transparent(Vector2 position);
375 bool is_passable(Vector2 position);
377 bool is_visible(Vector2 position);
379 bool is_discovered(Vector2 position);
381 void set_value(Vector2 position, int value);
383 void set_visibility(Vector2 position, bool value);
385 void set_discovered(Vector2 position, bool value);
387
388 // view.cpp
392
393
395 PoolVector2Array rpas_calc_visible_cells_from(Vector2 center, int radius);
397 void calculate_fov(Vector2 view_position);
399 void add_pathfinding_exception(Vector2 position, bool value);
401 void remove_pathfinding_exception(Vector2 position);
403
406 PoolVector2Array show_pathfinding_exceptions(bool exception_type);
408 bool is_pathfinding_allowed(Vector2 position);
410
416 PoolVector2Array find_path(Vector2 start, Vector2 end, Rect2 pathfinding_zone);
418
424 PoolVector2Array find_discovered_path(Vector2 start, Vector2 end, Rect2 pathfinding_zone);
426
427 PoolVector2Array get_line(Vector2 start, Vector2 end);
429 PoolVector2Array get_line_orthogonal(Vector2 start, Vector2 end);
431 Vector2 raycast_vision(Vector2 start, Vector2 end);
433 Vector2 raycast_path(Vector2 start, Vector2 end);
435
440 bool visibility_between(Vector2 start, Vector2 end, int max_distance);
442
443 // editing.cpp
447
448
450 void clean_map();
452 void resize_map(Vector2 new_size, Vector2 new_chunk_size);
454 void place_map(RGMap* another_map, Vector2 start);
456 void draw_line(Vector2 start, Vector2 end, int value);
458 void draw_line_orthogonal(Vector2 start, Vector2 end, int value);
460 void draw_rect(Rect2 rect, int value);
462 void fill_rect(Rect2 rect, int value);
464
465 void draw_ellipse(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value);
467 void draw_ellipse_orthogonal(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value);
469 void fill_ellipse(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value);
471 void draw_circle(Vector2 center, float radius, int value);
473 void draw_circle_orthogonal(Vector2 center, float radius, int value);
475 void fill_circle(Vector2 center, float radius, int value);
477 void draw_arc(Vector2 center, float radius, float start_angle, float end_angle, int value);
479 void draw_arc_orthogonal(Vector2 center, float radius, float start_angle, float end_angle, int value);
481 void fill_arc(Vector2 center, float radius, float start_angle, float end_angle, int value);
483
484 // entities.cpp
488
489
491 int add_entity(Vector2 position, bool passability, bool transparency);
493 void remove_entity(int id);
495 void move_entity(int id, Vector2 position);
497 void set_entity_transparency(int id, bool value);
499 void set_entity_passability(int id, bool value);
501 void set_entity_discovered(int id, bool value);
503 bool is_entity_visible(int id);
505 bool is_entity_transparent(int id);
507 bool is_entity_passable(int id);
509 bool is_entity_discovered(int id);
511 bool is_entity_chunk_loaded(int id);
513 bool is_entity_chunk_rendered(int id);
515 Vector2 get_entity_position(int id);
517 PoolIntArray get_entities_in_position(Vector2 position);
519 PoolIntArray get_entities_in_rect(Rect2 rect);
521 PoolIntArray get_entities_in_radius(Vector2 position, int radius);
523 PoolIntArray get_entities_in_chunk(int chunk_index);
525
530
532 PoolIntArray dump_map_data();
534 void load_map_data(PoolIntArray map_data);
536};
537
538}
539
540#endif
Class for managing maps for roguelike.
Definition: rgmap.h:41
Vector2 get_entity_position(int id)
Get position of the entity.
Definition: entities.cpp:92
int get_tile_z_index(int index)
Get tile's drawing index.
Definition: tiles.cpp:60
void fill_rect(Rect2 rect, int value)
Fill rect.
Definition: editing.cpp:62
void set_chunk_rendered(int index, bool value)
Set rendering status of chunk.
Definition: chunks.cpp:105
PoolIntArray dump_chunk_data(int index)
Returns all cell data for chunk as PoolIntArray.
Definition: chunks.cpp:60
int get_value(Vector2 position)
Get value of cell.
Definition: cells.cpp:19
bool is_entity_visible(int id)
Check if entity is visible.
Definition: entities.cpp:65
void draw_line_orthogonal(Vector2 start, Vector2 end, int value)
Draw orthogonal straight line (No diagonals allowed)
Definition: editing.cpp:43
bool is_entity_discovered(int id)
Check if entity is discovered.
Definition: entities.cpp:78
bool allow_diagonal_pathfinding
Allow/Disallow diagonal pathfinding.
Definition: rgmap.h:154
void set_tile_texture_offset(int index, Vector2 offset)
Set tile's texture offset.
Definition: tiles.cpp:40
bool is_entity_chunk_rendered(int id)
Check if entity is on rendered chunk.
Definition: entities.cpp:87
int get_tiles_count()
Get number of tiles.
Definition: tiles.cpp:89
void set_visibility(Vector2 position, bool value)
Set visibility of cell.
Definition: cells.cpp:71
PoolIntArray get_entities_in_position(Vector2 position)
Find ids of all entities in position.
Definition: entities.cpp:96
bool is_discovered(Vector2 position)
Check if cell is discovered.
Definition: cells.cpp:53
bool is_chunk_rendered(int index)
Check if chunk is rendered.
Definition: chunks.cpp:101
void draw_rect(Rect2 rect, int value)
Draw rect borders.
Definition: editing.cpp:51
int get_chunk_index(Vector2 position)
Get index of chunk which contains a given position.
Definition: chunks.cpp:9
void set_tile_z_index(int index, int z_index)
Set tile's drawing index.
Definition: tiles.cpp:36
void draw_circle(Vector2 center, float radius, int value)
Draw circle.
Definition: editing.cpp:187
bool is_tile_transparent(int index)
Check if tile is transparent.
Definition: tiles.cpp:105
PoolIntArray get_chunks_to_hide(Vector2 player_position)
Get ids of chunks that are rendered, but not needed anymore because player is too far.
Definition: chunks.cpp:184
PoolIntArray get_entities_in_rect(Rect2 rect)
Find ids of all entities in rect.
Definition: entities.cpp:108
void set_tile_normal_map(int index, Ref< Texture > texture)
Set tile's normal map.
Definition: tiles.cpp:48
bool is_visible(Vector2 position)
Check if cell is visible.
Definition: cells.cpp:47
PoolIntArray chunks_free_requested()
Signal. Emited when chunks need to be freed. Emited on calling request_chunks_load function
Definition: rgmap.h:189
PoolIntArray get_rendered_chunks()
Get ids of rendered chunks.
Definition: chunks.cpp:166
void calculate_fov(Vector2 view_position)
Calculate visibility from given position.
Definition: view.cpp:6
void set_entity_passability(int id, bool value)
Change entity passability.
Definition: entities.cpp:57
String get_tile_display_name(int index)
Get tile display name.
Definition: tiles.cpp:103
PoolIntArray get_entities_in_chunk(int chunk_index)
Find ids of all entities in chunk.
Definition: entities.cpp:146
bool is_in_bounds(Vector2 position)
Check if cell is in bounds.
Definition: cells.cpp:14
void add_tile_property(String property_name, Variant default_value)
Add custom property field for all tiles.
Definition: tiles.cpp:26
Ref< Texture > get_tile_normal_map(int index)
Get tile's normal map.
Definition: tiles.cpp:72
int chunk_index_v2_to_int(Vector2 index)
Convert index of chunk from Vector2 to int format.
Definition: chunks.cpp:20
Vector2 chunk_size
Size of one chunk (Default: 50x50)
Definition: rgmap.h:138
String get_display_name(Vector2 position)
Get display name of cell.
Definition: cells.cpp:30
String get_name(Vector2 position)
Get name of cell.
Definition: cells.cpp:27
void add_pathfinding_exception(Vector2 position, bool value)
Allow/disallow patfinding for this cell ignoring passability.
Definition: view.cpp:46
Vector2 size
Size of the whole map in chunks (Default: 3x3)
Definition: rgmap.h:140
void request_chunks_load(Vector2 player_position)
Request chunk load/unload depending on player_position and load_distance.
Definition: chunks.cpp:159
Ref< Texture > get_tile_texture(int index)
Get tile's texture.
Definition: tiles.cpp:68
Variant get_tile_property(int index, String property_name)
Get value of custom tile property.
Definition: tiles.cpp:84
PoolVector2Array show_pathfinding_exceptions(bool exception_type)
Show all pathfinding exceptions of a type.
Definition: view.cpp:55
PoolIntArray dump_map_data()
Save map data.
Definition: rgmap.cpp:169
bool is_passable(Vector2 position)
Check if cell is passable.
Definition: cells.cpp:44
void draw_ellipse(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value)
Draw ellipse using Bresenham's midpoint algorithm.
Definition: editing.cpp:172
void place_map(RGMap *another_map, Vector2 start)
Place another map inside this map.
Definition: editing.cpp:25
void remove_pathfinding_exception(Vector2 position)
Remove all pathfinding exceptions for this cell if they exist.
Definition: view.cpp:51
void draw_circle_orthogonal(Vector2 center, float radius, int value)
Draw circle (No diagonals allowed)
Definition: editing.cpp:190
bool is_entity_passable(int id)
Check if entity is passable.
Definition: entities.cpp:74
Vector2 raycast_path(Vector2 start, Vector2 end)
Cast ray from start to end and return position where path is blocked by an obstacle.
Definition: view.cpp:217
PoolIntArray get_chunks_to_render(Vector2 player_position)
Get ids of chunks around player that needs to be rendered.
Definition: chunks.cpp:174
PoolIntArray get_entities_in_radius(Vector2 position, int radius)
Find ids of all entities in radius.
Definition: entities.cpp:131
int chunk_freed()
Signal. Emited when chunk is freed from memory. Emited on calling free_chunk function
Definition: rgmap.h:197
void set_tile_texture(int index, Ref< Texture > texture)
Set tile's texture.
Definition: tiles.cpp:44
void move_entity(int id, Vector2 position)
Move entity to a new position.
Definition: entities.cpp:38
void clean_map()
Free all chunks and forget pathfinding exceptions.
Definition: editing.cpp:6
void set_entity_discovered(int id, bool value)
Change memory status of entity.
Definition: entities.cpp:61
void draw_arc_orthogonal(Vector2 center, float radius, float start_angle, float end_angle, int value)
Draw orthogonal arc (No diagonals allowed)
Definition: editing.cpp:199
void set_tile_transparency(int index, bool value)
Set transparency of the tile.
Definition: tiles.cpp:18
void resize_map(Vector2 new_size, Vector2 new_chunk_size)
Change size and chunk size of the map.
Definition: editing.cpp:17
PoolVector2Array get_line(Vector2 start, Vector2 end)
Get a set of points in Bresenham's line.
Definition: view.cpp:205
Color get_tile_modulate(int index)
Get tile's modulation color.
Definition: tiles.cpp:80
int chunk_loaded()
Signal. Emited when is loaded for the first time. Emited on calling load_chunk function
Definition: rgmap.h:195
bool is_pathfinding_allowed(Vector2 position)
Check if pathfinding on this cell is allowed.
Definition: view.cpp:136
bool is_transparent(Vector2 position)
Check if cell is transparent.
Definition: cells.cpp:36
bool is_entity_chunk_loaded(int id)
Check if entity is on loaded chunk.
Definition: entities.cpp:82
void free_chunk(int index)
Free chunk from memory.
Definition: chunks.cpp:75
void set_tile_passability(int index, bool value)
Set passability of the tile.
Definition: tiles.cpp:22
int RPAS_RESTRICTIVENESS
Determines how restrictive the algorithm is.
Definition: rgmap.h:174
void set_entity_transparency(int id, bool value)
Change entity transparency.
Definition: entities.cpp:53
String get_tile_name(int index)
Get tile name (unique)
Definition: tiles.cpp:102
void draw_arc(Vector2 center, float radius, float start_angle, float end_angle, int value)
Draw arc.
Definition: editing.cpp:196
Vector2 chunk_index_int_to_v2(int index)
Convert index of chunk from int to Vector2 format.
Definition: chunks.cpp:15
bool visibility_between(Vector2 start, Vector2 end, int max_distance)
Check if end point is visisble from start point.
Definition: view.cpp:226
void load_map_data(PoolIntArray map_data)
Load map data.
Definition: rgmap.cpp:184
void set_tile_material(int index, Ref< Material > material)
Set tile's material.
Definition: tiles.cpp:52
PoolIntArray get_chunks_in_distance(Vector2 point, int distance)
Get indexes of chunks forming a square grid with a given point in its center.
Definition: chunks.cpp:124
void set_discovered(Vector2 position, bool value)
Set cell discovered/undiscovered.
Definition: cells.cpp:79
PoolIntArray get_loaded_chunks()
Get ids of loaded chunks.
Definition: chunks.cpp:117
PoolIntArray chunks_hide_requested()
Signal. Emited when rendered chunks need to be hidden. Emited on calling request_chunks_render functi...
Definition: rgmap.h:193
int load_distance
Number of chunks loaded around the player.
Definition: rgmap.h:146
int get_local_index(Vector2 position)
Get local index of cell within a chunk.
Definition: cells.cpp:6
void draw_ellipse_orthogonal(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value)
Draw orthogonal ellipse (No diagonals allowed)
Definition: editing.cpp:175
PoolVector2Array rpas_calc_visible_cells_from(Vector2 center, int radius)
Get list of cells visible from position within radius using RPAS algorithm.
Definition: rpas.cpp:34
Ref< Material > get_tile_material(int index)
Get tile's material.
Definition: tiles.cpp:76
Vector2 get_tile_texture_offset(int index)
Get tile's texture offset.
Definition: tiles.cpp:64
PoolIntArray chunks_render_requested()
Signal. Emited when chunks need to be rendered. Emited on calling request_chunks_render function
Definition: rgmap.h:191
void set_value(Vector2 position, int value)
Set value of cell.
Definition: cells.cpp:61
bool RPAS_NOT_VISIBLE_BLOCKS_VISION
If this is false, some cells will unexpectedly be visible.
Definition: rgmap.h:167
PoolVector2Array get_line_orthogonal(Vector2 start, Vector2 end)
Get a set of points in Bresenham's line (No diagonals allowed)
Definition: view.cpp:206
bool is_chunk_in_bounds(int index)
Check if chunk is in bounds.
Definition: chunks.cpp:22
bool RPAS_VISIBLE_ON_EQUAL
If false, an obstruction will obstruct its endpoints.
Definition: rgmap.h:176
int get_tile_index(String name)
Get tile index by name.
Definition: tiles.cpp:93
void set_tile_modulate(int index, Color color)
Set tile's modulation color.
Definition: tiles.cpp:56
bool is_entity_transparent(int id)
Check if entity is transparent;.
Definition: entities.cpp:70
void fill_ellipse(Vector2 center, Vector2 radius, float start_angle, float end_angle, int value)
Fill ellipse.
Definition: editing.cpp:179
int add_tile(String name, String display_name)
Add new tile. Returns unique tile index.
Definition: tiles.cpp:6
PoolIntArray get_chunks_to_free(Vector2 player_position)
Get ids of chunks that are loaded, but not needed anymore because player is too far.
Definition: chunks.cpp:146
bool is_tile_passable(int index)
Check if tile is passable.
Definition: tiles.cpp:104
float RPAS_RADIUS_FUDGE
How smooth the edges of the vision bubble are. Between 0 and 1.
Definition: rgmap.h:165
PoolVector2Array find_path(Vector2 start, Vector2 end, Rect2 pathfinding_zone)
Find path from start to end using A* algorithm.
Definition: view.cpp:150
Variant get_property(Vector2 position, String property_name)
Get custom property value of cell's tile.
Definition: cells.cpp:33
void set_tile_property(int index, String property_name, Variant new_value)
Set value of custom property for specified tile.
Definition: tiles.cpp:32
void fill_circle(Vector2 center, float radius, int value)
Fill circle.
Definition: editing.cpp:193
void remove_entity(int id)
Remove entity from memory. The id of this entity will also be given to a new entity.
Definition: entities.cpp:30
PoolVector2Array find_discovered_path(Vector2 start, Vector2 end, Rect2 pathfinding_zone)
Find path from start to end using A* algorithm including only discovered cells.
Definition: view.cpp:153
void fill_arc(Vector2 center, float radius, float start_angle, float end_angle, int value)
Fill arc.
Definition: editing.cpp:202
int add_entity(Vector2 position, bool passability, bool transparency)
Add new entity to the map. Returns id given to a new entity.
Definition: entities.cpp:6
int fov_radius
Radius in which cells are visible for player.
Definition: rgmap.h:163
int render_distance
Number of chunks rendered around the player.
Definition: rgmap.h:152
void reset_chunk(int index)
Clear all cell data in chunk.
Definition: chunks.cpp:89
Vector2 raycast_vision(Vector2 start, Vector2 end)
Cast ray from start to end and return position where vision is blocked by an obstacle.
Definition: view.cpp:208
PoolIntArray get_chunks_to_load(Vector2 player_position)
Get ids of chunks around player that needs to be loaded.
Definition: chunks.cpp:138
void request_chunks_render(Vector2 player_position)
Request chunk render/hide depending on player_position and render_distance.
Definition: chunks.cpp:198
bool is_chunk_loaded(int index)
Check if chunk is loaded.
Definition: chunks.cpp:23
PoolIntArray chunks_load_requested()
Signal. Emited when chunks need to be loaded. Emited on calling request_chunks_load function
Definition: rgmap.h:187
void draw_line(Vector2 start, Vector2 end, int value)
Draw straight line using Bresenham's line algorithm.
Definition: editing.cpp:36
Ref< TileSet > generate_tileset()
Generate Tileset for using with 2d Tilemap.
Definition: tiles.cpp:106
void load_chunk(int index, PoolIntArray data=PoolIntArray())
Load saved chunk to memory or generate a new chunk. "data" argument is optional.
Definition: chunks.cpp:27