1 /** 2 Node for 2D tile-based maps. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.tilemap; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.node2d; 25 import godot.canvasitem; 26 import godot.node; 27 import godot.tileset; 28 /** 29 Node for 2D tile-based maps. 30 31 Tilemaps use a $(D TileSet) which contain a list of tiles (textures plus optional collision, navigation, and/or occluder shapes) which are used to create grid-based maps. 32 When doing physics queries against the tilemap, the cell coordinates are encoded as `metadata` for each detected collision shape returned by methods such as $(D Physics2DDirectSpaceState.intersectShape), $(D Physics2DDirectBodyState.getContactColliderShapeMetadata), etc. 33 */ 34 @GodotBaseClass struct TileMap 35 { 36 package(godot) enum string _GODOT_internal_name = "TileMap"; 37 public: 38 @nogc nothrow: 39 union { /** */ godot_object _godot_object; /** */ Node2D _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct GDNativeClassBinding 44 { 45 __gshared: 46 @GodotName("_clear_quadrants") GodotMethod!(void) _clearQuadrants; 47 @GodotName("_get_old_cell_size") GodotMethod!(long) _getOldCellSize; 48 @GodotName("_get_tile_data") GodotMethod!(PoolIntArray) _getTileData; 49 @GodotName("_recreate_quadrants") GodotMethod!(void) _recreateQuadrants; 50 @GodotName("_set_celld") GodotMethod!(void, Vector2, Dictionary) _setCelld; 51 @GodotName("_set_old_cell_size") GodotMethod!(void, long) _setOldCellSize; 52 @GodotName("_set_tile_data") GodotMethod!(void, PoolIntArray) _setTileData; 53 @GodotName("clear") GodotMethod!(void) clear; 54 @GodotName("fix_invalid_tiles") GodotMethod!(void) fixInvalidTiles; 55 @GodotName("get_cell") GodotMethod!(long, long, long) getCell; 56 @GodotName("get_cell_autotile_coord") GodotMethod!(Vector2, long, long) getCellAutotileCoord; 57 @GodotName("get_cell_size") GodotMethod!(Vector2) getCellSize; 58 @GodotName("get_cellv") GodotMethod!(long, Vector2) getCellv; 59 @GodotName("get_clip_uv") GodotMethod!(bool) getClipUv; 60 @GodotName("get_collision_bounce") GodotMethod!(double) getCollisionBounce; 61 @GodotName("get_collision_friction") GodotMethod!(double) getCollisionFriction; 62 @GodotName("get_collision_layer") GodotMethod!(long) getCollisionLayer; 63 @GodotName("get_collision_layer_bit") GodotMethod!(bool, long) getCollisionLayerBit; 64 @GodotName("get_collision_mask") GodotMethod!(long) getCollisionMask; 65 @GodotName("get_collision_mask_bit") GodotMethod!(bool, long) getCollisionMaskBit; 66 @GodotName("get_collision_use_kinematic") GodotMethod!(bool) getCollisionUseKinematic; 67 @GodotName("get_collision_use_parent") GodotMethod!(bool) getCollisionUseParent; 68 @GodotName("get_custom_transform") GodotMethod!(Transform2D) getCustomTransform; 69 @GodotName("get_half_offset") GodotMethod!(TileMap.HalfOffset) getHalfOffset; 70 @GodotName("get_mode") GodotMethod!(TileMap.Mode) getMode; 71 @GodotName("get_occluder_light_mask") GodotMethod!(long) getOccluderLightMask; 72 @GodotName("get_quadrant_size") GodotMethod!(long) getQuadrantSize; 73 @GodotName("get_tile_origin") GodotMethod!(TileMap.TileOrigin) getTileOrigin; 74 @GodotName("get_tileset") GodotMethod!(TileSet) getTileset; 75 @GodotName("get_used_cells") GodotMethod!(Array) getUsedCells; 76 @GodotName("get_used_cells_by_id") GodotMethod!(Array, long) getUsedCellsById; 77 @GodotName("get_used_rect") GodotMethod!(Rect2) getUsedRect; 78 @GodotName("is_cell_transposed") GodotMethod!(bool, long, long) isCellTransposed; 79 @GodotName("is_cell_x_flipped") GodotMethod!(bool, long, long) isCellXFlipped; 80 @GodotName("is_cell_y_flipped") GodotMethod!(bool, long, long) isCellYFlipped; 81 @GodotName("is_centered_textures_enabled") GodotMethod!(bool) isCenteredTexturesEnabled; 82 @GodotName("is_compatibility_mode_enabled") GodotMethod!(bool) isCompatibilityModeEnabled; 83 @GodotName("is_show_collision_enabled") GodotMethod!(bool) isShowCollisionEnabled; 84 @GodotName("is_y_sort_mode_enabled") GodotMethod!(bool) isYSortModeEnabled; 85 @GodotName("map_to_world") GodotMethod!(Vector2, Vector2, bool) mapToWorld; 86 @GodotName("set_cell") GodotMethod!(void, long, long, long, bool, bool, bool, Vector2) setCell; 87 @GodotName("set_cell_size") GodotMethod!(void, Vector2) setCellSize; 88 @GodotName("set_cellv") GodotMethod!(void, Vector2, long, bool, bool, bool) setCellv; 89 @GodotName("set_centered_textures") GodotMethod!(void, bool) setCenteredTextures; 90 @GodotName("set_clip_uv") GodotMethod!(void, bool) setClipUv; 91 @GodotName("set_collision_bounce") GodotMethod!(void, double) setCollisionBounce; 92 @GodotName("set_collision_friction") GodotMethod!(void, double) setCollisionFriction; 93 @GodotName("set_collision_layer") GodotMethod!(void, long) setCollisionLayer; 94 @GodotName("set_collision_layer_bit") GodotMethod!(void, long, bool) setCollisionLayerBit; 95 @GodotName("set_collision_mask") GodotMethod!(void, long) setCollisionMask; 96 @GodotName("set_collision_mask_bit") GodotMethod!(void, long, bool) setCollisionMaskBit; 97 @GodotName("set_collision_use_kinematic") GodotMethod!(void, bool) setCollisionUseKinematic; 98 @GodotName("set_collision_use_parent") GodotMethod!(void, bool) setCollisionUseParent; 99 @GodotName("set_compatibility_mode") GodotMethod!(void, bool) setCompatibilityMode; 100 @GodotName("set_custom_transform") GodotMethod!(void, Transform2D) setCustomTransform; 101 @GodotName("set_half_offset") GodotMethod!(void, long) setHalfOffset; 102 @GodotName("set_mode") GodotMethod!(void, long) setMode; 103 @GodotName("set_occluder_light_mask") GodotMethod!(void, long) setOccluderLightMask; 104 @GodotName("set_quadrant_size") GodotMethod!(void, long) setQuadrantSize; 105 @GodotName("set_show_collision") GodotMethod!(void, bool) setShowCollision; 106 @GodotName("set_tile_origin") GodotMethod!(void, long) setTileOrigin; 107 @GodotName("set_tileset") GodotMethod!(void, TileSet) setTileset; 108 @GodotName("set_y_sort_mode") GodotMethod!(void, bool) setYSortMode; 109 @GodotName("update_bitmask_area") GodotMethod!(void, Vector2) updateBitmaskArea; 110 @GodotName("update_bitmask_region") GodotMethod!(void, Vector2, Vector2) updateBitmaskRegion; 111 @GodotName("update_dirty_quadrants") GodotMethod!(void) updateDirtyQuadrants; 112 @GodotName("world_to_map") GodotMethod!(Vector2, Vector2) worldToMap; 113 } 114 /// 115 pragma(inline, true) bool opEquals(in TileMap other) const 116 { return _godot_object.ptr is other._godot_object.ptr; } 117 /// 118 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 119 { _godot_object.ptr = n; return null; } 120 /// 121 pragma(inline, true) bool opEquals(typeof(null) n) const 122 { return _godot_object.ptr is n; } 123 /// 124 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 125 mixin baseCasts; 126 /// Construct a new instance of TileMap. 127 /// Note: use `memnew!TileMap` instead. 128 static TileMap _new() 129 { 130 static godot_class_constructor constructor; 131 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TileMap"); 132 if(constructor is null) return typeof(this).init; 133 return cast(TileMap)(constructor()); 134 } 135 @disable new(size_t s); 136 /// 137 enum Mode : int 138 { 139 /** 140 Orthogonal orientation mode. 141 */ 142 modeSquare = 0, 143 /** 144 Isometric orientation mode. 145 */ 146 modeIsometric = 1, 147 /** 148 Custom orientation mode. 149 */ 150 modeCustom = 2, 151 } 152 /// 153 enum TileOrigin : int 154 { 155 /** 156 Tile origin at its top-left corner. 157 */ 158 tileOriginTopLeft = 0, 159 /** 160 Tile origin at its center. 161 */ 162 tileOriginCenter = 1, 163 /** 164 Tile origin at its bottom-left corner. 165 */ 166 tileOriginBottomLeft = 2, 167 } 168 /// 169 enum HalfOffset : int 170 { 171 /** 172 Half offset on the X coordinate. 173 */ 174 halfOffsetX = 0, 175 /** 176 Half offset on the Y coordinate. 177 */ 178 halfOffsetY = 1, 179 /** 180 Half offset disabled. 181 */ 182 halfOffsetDisabled = 2, 183 /** 184 Half offset on the X coordinate (negative). 185 */ 186 halfOffsetNegativeX = 3, 187 /** 188 Half offset on the Y coordinate (negative). 189 */ 190 halfOffsetNegativeY = 4, 191 } 192 /// 193 enum Constants : int 194 { 195 /** 196 Returned when a cell doesn't exist. 197 */ 198 invalidCell = -1, 199 tileOriginTopLeft = 0, 200 halfOffsetX = 0, 201 modeSquare = 0, 202 tileOriginCenter = 1, 203 modeIsometric = 1, 204 halfOffsetY = 1, 205 tileOriginBottomLeft = 2, 206 halfOffsetDisabled = 2, 207 modeCustom = 2, 208 halfOffsetNegativeX = 3, 209 halfOffsetNegativeY = 4, 210 } 211 /** 212 213 */ 214 void _clearQuadrants() 215 { 216 Array _GODOT_args = Array.make(); 217 String _GODOT_method_name = String("_clear_quadrants"); 218 this.callv(_GODOT_method_name, _GODOT_args); 219 } 220 /** 221 222 */ 223 long _getOldCellSize() const 224 { 225 Array _GODOT_args = Array.make(); 226 String _GODOT_method_name = String("_get_old_cell_size"); 227 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long); 228 } 229 /** 230 231 */ 232 PoolIntArray _getTileData() const 233 { 234 Array _GODOT_args = Array.make(); 235 String _GODOT_method_name = String("_get_tile_data"); 236 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolIntArray); 237 } 238 /** 239 240 */ 241 void _recreateQuadrants() 242 { 243 Array _GODOT_args = Array.make(); 244 String _GODOT_method_name = String("_recreate_quadrants"); 245 this.callv(_GODOT_method_name, _GODOT_args); 246 } 247 /** 248 249 */ 250 void _setCelld(in Vector2 position, in Dictionary data) 251 { 252 Array _GODOT_args = Array.make(); 253 _GODOT_args.append(position); 254 _GODOT_args.append(data); 255 String _GODOT_method_name = String("_set_celld"); 256 this.callv(_GODOT_method_name, _GODOT_args); 257 } 258 /** 259 260 */ 261 void _setOldCellSize(in long size) 262 { 263 Array _GODOT_args = Array.make(); 264 _GODOT_args.append(size); 265 String _GODOT_method_name = String("_set_old_cell_size"); 266 this.callv(_GODOT_method_name, _GODOT_args); 267 } 268 /** 269 270 */ 271 void _setTileData(in PoolIntArray arg0) 272 { 273 Array _GODOT_args = Array.make(); 274 _GODOT_args.append(arg0); 275 String _GODOT_method_name = String("_set_tile_data"); 276 this.callv(_GODOT_method_name, _GODOT_args); 277 } 278 /** 279 Clears all cells. 280 */ 281 void clear() 282 { 283 checkClassBinding!(typeof(this))(); 284 ptrcall!(void)(GDNativeClassBinding.clear, _godot_object); 285 } 286 /** 287 Clears cells that do not exist in the tileset. 288 */ 289 void fixInvalidTiles() 290 { 291 checkClassBinding!(typeof(this))(); 292 ptrcall!(void)(GDNativeClassBinding.fixInvalidTiles, _godot_object); 293 } 294 /** 295 Returns the tile index of the given cell. If no tile exists in the cell, returns $(D constant INVALID_CELL). 296 */ 297 long getCell(in long x, in long y) const 298 { 299 checkClassBinding!(typeof(this))(); 300 return ptrcall!(long)(GDNativeClassBinding.getCell, _godot_object, x, y); 301 } 302 /** 303 Returns the coordinate (subtile column and row) of the autotile variation in the tileset. Returns a zero vector if the cell doesn't have autotiling. 304 */ 305 Vector2 getCellAutotileCoord(in long x, in long y) const 306 { 307 checkClassBinding!(typeof(this))(); 308 return ptrcall!(Vector2)(GDNativeClassBinding.getCellAutotileCoord, _godot_object, x, y); 309 } 310 /** 311 312 */ 313 Vector2 getCellSize() const 314 { 315 checkClassBinding!(typeof(this))(); 316 return ptrcall!(Vector2)(GDNativeClassBinding.getCellSize, _godot_object); 317 } 318 /** 319 Returns the tile index of the cell given by a Vector2. If no tile exists in the cell, returns $(D constant INVALID_CELL). 320 */ 321 long getCellv(in Vector2 position) const 322 { 323 checkClassBinding!(typeof(this))(); 324 return ptrcall!(long)(GDNativeClassBinding.getCellv, _godot_object, position); 325 } 326 /** 327 328 */ 329 bool getClipUv() const 330 { 331 checkClassBinding!(typeof(this))(); 332 return ptrcall!(bool)(GDNativeClassBinding.getClipUv, _godot_object); 333 } 334 /** 335 336 */ 337 double getCollisionBounce() const 338 { 339 checkClassBinding!(typeof(this))(); 340 return ptrcall!(double)(GDNativeClassBinding.getCollisionBounce, _godot_object); 341 } 342 /** 343 344 */ 345 double getCollisionFriction() const 346 { 347 checkClassBinding!(typeof(this))(); 348 return ptrcall!(double)(GDNativeClassBinding.getCollisionFriction, _godot_object); 349 } 350 /** 351 352 */ 353 long getCollisionLayer() const 354 { 355 checkClassBinding!(typeof(this))(); 356 return ptrcall!(long)(GDNativeClassBinding.getCollisionLayer, _godot_object); 357 } 358 /** 359 Returns `true` if the given collision layer bit is set. 360 */ 361 bool getCollisionLayerBit(in long bit) const 362 { 363 checkClassBinding!(typeof(this))(); 364 return ptrcall!(bool)(GDNativeClassBinding.getCollisionLayerBit, _godot_object, bit); 365 } 366 /** 367 368 */ 369 long getCollisionMask() const 370 { 371 checkClassBinding!(typeof(this))(); 372 return ptrcall!(long)(GDNativeClassBinding.getCollisionMask, _godot_object); 373 } 374 /** 375 Returns `true` if the given collision mask bit is set. 376 */ 377 bool getCollisionMaskBit(in long bit) const 378 { 379 checkClassBinding!(typeof(this))(); 380 return ptrcall!(bool)(GDNativeClassBinding.getCollisionMaskBit, _godot_object, bit); 381 } 382 /** 383 384 */ 385 bool getCollisionUseKinematic() const 386 { 387 checkClassBinding!(typeof(this))(); 388 return ptrcall!(bool)(GDNativeClassBinding.getCollisionUseKinematic, _godot_object); 389 } 390 /** 391 392 */ 393 bool getCollisionUseParent() const 394 { 395 checkClassBinding!(typeof(this))(); 396 return ptrcall!(bool)(GDNativeClassBinding.getCollisionUseParent, _godot_object); 397 } 398 /** 399 400 */ 401 Transform2D getCustomTransform() const 402 { 403 checkClassBinding!(typeof(this))(); 404 return ptrcall!(Transform2D)(GDNativeClassBinding.getCustomTransform, _godot_object); 405 } 406 /** 407 408 */ 409 TileMap.HalfOffset getHalfOffset() const 410 { 411 checkClassBinding!(typeof(this))(); 412 return ptrcall!(TileMap.HalfOffset)(GDNativeClassBinding.getHalfOffset, _godot_object); 413 } 414 /** 415 416 */ 417 TileMap.Mode getMode() const 418 { 419 checkClassBinding!(typeof(this))(); 420 return ptrcall!(TileMap.Mode)(GDNativeClassBinding.getMode, _godot_object); 421 } 422 /** 423 424 */ 425 long getOccluderLightMask() const 426 { 427 checkClassBinding!(typeof(this))(); 428 return ptrcall!(long)(GDNativeClassBinding.getOccluderLightMask, _godot_object); 429 } 430 /** 431 432 */ 433 long getQuadrantSize() const 434 { 435 checkClassBinding!(typeof(this))(); 436 return ptrcall!(long)(GDNativeClassBinding.getQuadrantSize, _godot_object); 437 } 438 /** 439 440 */ 441 TileMap.TileOrigin getTileOrigin() const 442 { 443 checkClassBinding!(typeof(this))(); 444 return ptrcall!(TileMap.TileOrigin)(GDNativeClassBinding.getTileOrigin, _godot_object); 445 } 446 /** 447 448 */ 449 Ref!TileSet getTileset() const 450 { 451 checkClassBinding!(typeof(this))(); 452 return ptrcall!(TileSet)(GDNativeClassBinding.getTileset, _godot_object); 453 } 454 /** 455 Returns a $(D Vector2) array with the positions of all cells containing a tile from the tileset (i.e. a tile index different from `-1`). 456 */ 457 Array getUsedCells() const 458 { 459 checkClassBinding!(typeof(this))(); 460 return ptrcall!(Array)(GDNativeClassBinding.getUsedCells, _godot_object); 461 } 462 /** 463 Returns an array of all cells with the given tile index specified in `id`. 464 */ 465 Array getUsedCellsById(in long id) const 466 { 467 checkClassBinding!(typeof(this))(); 468 return ptrcall!(Array)(GDNativeClassBinding.getUsedCellsById, _godot_object, id); 469 } 470 /** 471 Returns a rectangle enclosing the used (non-empty) tiles of the map. 472 */ 473 Rect2 getUsedRect() 474 { 475 checkClassBinding!(typeof(this))(); 476 return ptrcall!(Rect2)(GDNativeClassBinding.getUsedRect, _godot_object); 477 } 478 /** 479 Returns `true` if the given cell is transposed, i.e. the X and Y axes are swapped. 480 */ 481 bool isCellTransposed(in long x, in long y) const 482 { 483 checkClassBinding!(typeof(this))(); 484 return ptrcall!(bool)(GDNativeClassBinding.isCellTransposed, _godot_object, x, y); 485 } 486 /** 487 Returns `true` if the given cell is flipped in the X axis. 488 */ 489 bool isCellXFlipped(in long x, in long y) const 490 { 491 checkClassBinding!(typeof(this))(); 492 return ptrcall!(bool)(GDNativeClassBinding.isCellXFlipped, _godot_object, x, y); 493 } 494 /** 495 Returns `true` if the given cell is flipped in the Y axis. 496 */ 497 bool isCellYFlipped(in long x, in long y) const 498 { 499 checkClassBinding!(typeof(this))(); 500 return ptrcall!(bool)(GDNativeClassBinding.isCellYFlipped, _godot_object, x, y); 501 } 502 /** 503 504 */ 505 bool isCenteredTexturesEnabled() const 506 { 507 checkClassBinding!(typeof(this))(); 508 return ptrcall!(bool)(GDNativeClassBinding.isCenteredTexturesEnabled, _godot_object); 509 } 510 /** 511 512 */ 513 bool isCompatibilityModeEnabled() const 514 { 515 checkClassBinding!(typeof(this))(); 516 return ptrcall!(bool)(GDNativeClassBinding.isCompatibilityModeEnabled, _godot_object); 517 } 518 /** 519 520 */ 521 bool isShowCollisionEnabled() const 522 { 523 checkClassBinding!(typeof(this))(); 524 return ptrcall!(bool)(GDNativeClassBinding.isShowCollisionEnabled, _godot_object); 525 } 526 /** 527 528 */ 529 bool isYSortModeEnabled() const 530 { 531 checkClassBinding!(typeof(this))(); 532 return ptrcall!(bool)(GDNativeClassBinding.isYSortModeEnabled, _godot_object); 533 } 534 /** 535 Returns the local position of the top left corner of the cell corresponding to the given tilemap (grid-based) coordinates. 536 To get the global position, use $(D Node2D.toGlobal): 537 538 539 var local_position = my_tilemap.map_to_world(map_position) 540 var global_position = my_tilemap.to_global(local_position) 541 542 543 Optionally, the tilemap's half offset can be ignored. 544 */ 545 Vector2 mapToWorld(in Vector2 map_position, in bool ignore_half_ofs = false) const 546 { 547 checkClassBinding!(typeof(this))(); 548 return ptrcall!(Vector2)(GDNativeClassBinding.mapToWorld, _godot_object, map_position, ignore_half_ofs); 549 } 550 /** 551 Sets the tile index for the cell given by a Vector2. 552 An index of `-1` clears the cell. 553 Optionally, the tile can also be flipped, transposed, or given autotile coordinates. The autotile coordinate refers to the column and row of the subtile. 554 $(B Note:) Data such as navigation polygons and collision shapes are not immediately updated for performance reasons. 555 If you need these to be immediately updated, you can call $(D updateDirtyQuadrants). 556 Overriding this method also overrides it internally, allowing custom logic to be implemented when tiles are placed/removed: 557 558 559 func set_cell(x, y, tile, flip_x=false, flip_y=false, transpose=false, autotile_coord=Vector2()): 560 # Write your custom logic here. 561 # To call the default method: 562 .set_cell(x, y, tile, flip_x, flip_y, transpose, autotile_coord) 563 564 565 */ 566 void setCell(in long x, in long y, in long tile, in bool flip_x = false, in bool flip_y = false, in bool transpose = false, in Vector2 autotile_coord = Vector2(0, 0)) 567 { 568 checkClassBinding!(typeof(this))(); 569 ptrcall!(void)(GDNativeClassBinding.setCell, _godot_object, x, y, tile, flip_x, flip_y, transpose, autotile_coord); 570 } 571 /** 572 573 */ 574 void setCellSize(in Vector2 size) 575 { 576 checkClassBinding!(typeof(this))(); 577 ptrcall!(void)(GDNativeClassBinding.setCellSize, _godot_object, size); 578 } 579 /** 580 Sets the tile index for the given cell. 581 An index of `-1` clears the cell. 582 Optionally, the tile can also be flipped or transposed. 583 $(B Note:) Data such as navigation polygons and collision shapes are not immediately updated for performance reasons. 584 If you need these to be immediately updated, you can call $(D updateDirtyQuadrants). 585 */ 586 void setCellv(in Vector2 position, in long tile, in bool flip_x = false, in bool flip_y = false, in bool transpose = false) 587 { 588 checkClassBinding!(typeof(this))(); 589 ptrcall!(void)(GDNativeClassBinding.setCellv, _godot_object, position, tile, flip_x, flip_y, transpose); 590 } 591 /** 592 593 */ 594 void setCenteredTextures(in bool enable) 595 { 596 checkClassBinding!(typeof(this))(); 597 ptrcall!(void)(GDNativeClassBinding.setCenteredTextures, _godot_object, enable); 598 } 599 /** 600 601 */ 602 void setClipUv(in bool enable) 603 { 604 checkClassBinding!(typeof(this))(); 605 ptrcall!(void)(GDNativeClassBinding.setClipUv, _godot_object, enable); 606 } 607 /** 608 609 */ 610 void setCollisionBounce(in double value) 611 { 612 checkClassBinding!(typeof(this))(); 613 ptrcall!(void)(GDNativeClassBinding.setCollisionBounce, _godot_object, value); 614 } 615 /** 616 617 */ 618 void setCollisionFriction(in double value) 619 { 620 checkClassBinding!(typeof(this))(); 621 ptrcall!(void)(GDNativeClassBinding.setCollisionFriction, _godot_object, value); 622 } 623 /** 624 625 */ 626 void setCollisionLayer(in long layer) 627 { 628 checkClassBinding!(typeof(this))(); 629 ptrcall!(void)(GDNativeClassBinding.setCollisionLayer, _godot_object, layer); 630 } 631 /** 632 Sets the given collision layer bit. 633 */ 634 void setCollisionLayerBit(in long bit, in bool value) 635 { 636 checkClassBinding!(typeof(this))(); 637 ptrcall!(void)(GDNativeClassBinding.setCollisionLayerBit, _godot_object, bit, value); 638 } 639 /** 640 641 */ 642 void setCollisionMask(in long mask) 643 { 644 checkClassBinding!(typeof(this))(); 645 ptrcall!(void)(GDNativeClassBinding.setCollisionMask, _godot_object, mask); 646 } 647 /** 648 Sets the given collision mask bit. 649 */ 650 void setCollisionMaskBit(in long bit, in bool value) 651 { 652 checkClassBinding!(typeof(this))(); 653 ptrcall!(void)(GDNativeClassBinding.setCollisionMaskBit, _godot_object, bit, value); 654 } 655 /** 656 657 */ 658 void setCollisionUseKinematic(in bool use_kinematic) 659 { 660 checkClassBinding!(typeof(this))(); 661 ptrcall!(void)(GDNativeClassBinding.setCollisionUseKinematic, _godot_object, use_kinematic); 662 } 663 /** 664 665 */ 666 void setCollisionUseParent(in bool use_parent) 667 { 668 checkClassBinding!(typeof(this))(); 669 ptrcall!(void)(GDNativeClassBinding.setCollisionUseParent, _godot_object, use_parent); 670 } 671 /** 672 673 */ 674 void setCompatibilityMode(in bool enable) 675 { 676 checkClassBinding!(typeof(this))(); 677 ptrcall!(void)(GDNativeClassBinding.setCompatibilityMode, _godot_object, enable); 678 } 679 /** 680 681 */ 682 void setCustomTransform(in Transform2D custom_transform) 683 { 684 checkClassBinding!(typeof(this))(); 685 ptrcall!(void)(GDNativeClassBinding.setCustomTransform, _godot_object, custom_transform); 686 } 687 /** 688 689 */ 690 void setHalfOffset(in long half_offset) 691 { 692 checkClassBinding!(typeof(this))(); 693 ptrcall!(void)(GDNativeClassBinding.setHalfOffset, _godot_object, half_offset); 694 } 695 /** 696 697 */ 698 void setMode(in long mode) 699 { 700 checkClassBinding!(typeof(this))(); 701 ptrcall!(void)(GDNativeClassBinding.setMode, _godot_object, mode); 702 } 703 /** 704 705 */ 706 void setOccluderLightMask(in long mask) 707 { 708 checkClassBinding!(typeof(this))(); 709 ptrcall!(void)(GDNativeClassBinding.setOccluderLightMask, _godot_object, mask); 710 } 711 /** 712 713 */ 714 void setQuadrantSize(in long size) 715 { 716 checkClassBinding!(typeof(this))(); 717 ptrcall!(void)(GDNativeClassBinding.setQuadrantSize, _godot_object, size); 718 } 719 /** 720 721 */ 722 void setShowCollision(in bool enable) 723 { 724 checkClassBinding!(typeof(this))(); 725 ptrcall!(void)(GDNativeClassBinding.setShowCollision, _godot_object, enable); 726 } 727 /** 728 729 */ 730 void setTileOrigin(in long origin) 731 { 732 checkClassBinding!(typeof(this))(); 733 ptrcall!(void)(GDNativeClassBinding.setTileOrigin, _godot_object, origin); 734 } 735 /** 736 737 */ 738 void setTileset(TileSet tileset) 739 { 740 checkClassBinding!(typeof(this))(); 741 ptrcall!(void)(GDNativeClassBinding.setTileset, _godot_object, tileset); 742 } 743 /** 744 745 */ 746 void setYSortMode(in bool enable) 747 { 748 checkClassBinding!(typeof(this))(); 749 ptrcall!(void)(GDNativeClassBinding.setYSortMode, _godot_object, enable); 750 } 751 /** 752 Applies autotiling rules to the cell (and its adjacent cells) referenced by its grid-based X and Y coordinates. 753 */ 754 void updateBitmaskArea(in Vector2 position) 755 { 756 checkClassBinding!(typeof(this))(); 757 ptrcall!(void)(GDNativeClassBinding.updateBitmaskArea, _godot_object, position); 758 } 759 /** 760 Applies autotiling rules to the cells in the given region (specified by grid-based X and Y coordinates). 761 Calling with invalid (or missing) parameters applies autotiling rules for the entire tilemap. 762 */ 763 void updateBitmaskRegion(in Vector2 start = Vector2(0, 0), in Vector2 end = Vector2(0, 0)) 764 { 765 checkClassBinding!(typeof(this))(); 766 ptrcall!(void)(GDNativeClassBinding.updateBitmaskRegion, _godot_object, start, end); 767 } 768 /** 769 Updates the tile map's quadrants, allowing things such as navigation and collision shapes to be immediately used if modified. 770 */ 771 void updateDirtyQuadrants() 772 { 773 checkClassBinding!(typeof(this))(); 774 ptrcall!(void)(GDNativeClassBinding.updateDirtyQuadrants, _godot_object); 775 } 776 /** 777 Returns the tilemap (grid-based) coordinates corresponding to the given local position. 778 To use this with a global position, first determine the local position with $(D Node2D.toLocal): 779 780 781 var local_position = my_tilemap.to_local(global_position) 782 var map_position = my_tilemap.world_to_map(local_position) 783 784 785 */ 786 Vector2 worldToMap(in Vector2 world_position) const 787 { 788 checkClassBinding!(typeof(this))(); 789 return ptrcall!(Vector2)(GDNativeClassBinding.worldToMap, _godot_object, world_position); 790 } 791 /** 792 If `true`, the cell's UVs will be clipped. 793 */ 794 @property bool cellClipUv() 795 { 796 return getClipUv(); 797 } 798 /// ditto 799 @property void cellClipUv(bool v) 800 { 801 setClipUv(v); 802 } 803 /** 804 The custom $(D Transform2D) to be applied to the TileMap's cells. 805 */ 806 @property Transform2D cellCustomTransform() 807 { 808 return getCustomTransform(); 809 } 810 /// ditto 811 @property void cellCustomTransform(Transform2D v) 812 { 813 setCustomTransform(v); 814 } 815 /** 816 Amount to offset alternating tiles. See $(D halfoffset) for possible values. 817 */ 818 @property TileMap.HalfOffset cellHalfOffset() 819 { 820 return getHalfOffset(); 821 } 822 /// ditto 823 @property void cellHalfOffset(long v) 824 { 825 setHalfOffset(v); 826 } 827 /** 828 The TileMap's quadrant size. Optimizes drawing by batching, using chunks of this size. 829 */ 830 @property long cellQuadrantSize() 831 { 832 return getQuadrantSize(); 833 } 834 /// ditto 835 @property void cellQuadrantSize(long v) 836 { 837 setQuadrantSize(v); 838 } 839 /** 840 The TileMap's cell size. 841 */ 842 @property Vector2 cellSize() 843 { 844 return getCellSize(); 845 } 846 /// ditto 847 @property void cellSize(Vector2 v) 848 { 849 setCellSize(v); 850 } 851 /** 852 Position for tile origin. See $(D tileorigin) for possible values. 853 */ 854 @property TileMap.TileOrigin cellTileOrigin() 855 { 856 return getTileOrigin(); 857 } 858 /// ditto 859 @property void cellTileOrigin(long v) 860 { 861 setTileOrigin(v); 862 } 863 /** 864 If `true`, the TileMap's direct children will be drawn in order of their Y coordinate. 865 */ 866 @property bool cellYSort() 867 { 868 return isYSortModeEnabled(); 869 } 870 /// ditto 871 @property void cellYSort(bool v) 872 { 873 setYSortMode(v); 874 } 875 /** 876 If `true`, the textures will be centered in the middle of each tile. This is useful for certain isometric or top-down modes when textures are made larger or smaller than the tiles (e.g. to avoid flickering on tile edges). The offset is still applied, but from the center of the tile. If used, $(D compatibilityMode) is ignored. 877 If `false`, the texture position start in the top-left corner unless $(D compatibilityMode) is enabled. 878 */ 879 @property bool centeredTextures() 880 { 881 return isCenteredTexturesEnabled(); 882 } 883 /// ditto 884 @property void centeredTextures(bool v) 885 { 886 setCenteredTextures(v); 887 } 888 /** 889 Bounce value for static body collisions (see `collision_use_kinematic`). 890 */ 891 @property double collisionBounce() 892 { 893 return getCollisionBounce(); 894 } 895 /// ditto 896 @property void collisionBounce(double v) 897 { 898 setCollisionBounce(v); 899 } 900 /** 901 Friction value for static body collisions (see `collision_use_kinematic`). 902 */ 903 @property double collisionFriction() 904 { 905 return getCollisionFriction(); 906 } 907 /// ditto 908 @property void collisionFriction(double v) 909 { 910 setCollisionFriction(v); 911 } 912 /** 913 The collision layer(s) for all colliders in the TileMap. See $(D url=https://docs.godotengine.org/en/3.3/tutorials/physics/physics_introduction.html#collision-layers-and-masks)Collision layers and masks$(D /url) in the documentation for more information. 914 */ 915 @property long collisionLayer() 916 { 917 return getCollisionLayer(); 918 } 919 /// ditto 920 @property void collisionLayer(long v) 921 { 922 setCollisionLayer(v); 923 } 924 /** 925 The collision mask(s) for all colliders in the TileMap. See $(D url=https://docs.godotengine.org/en/3.3/tutorials/physics/physics_introduction.html#collision-layers-and-masks)Collision layers and masks$(D /url) in the documentation for more information. 926 */ 927 @property long collisionMask() 928 { 929 return getCollisionMask(); 930 } 931 /// ditto 932 @property void collisionMask(long v) 933 { 934 setCollisionMask(v); 935 } 936 /** 937 If `true`, TileMap collisions will be handled as a kinematic body. If `false`, collisions will be handled as static body. 938 */ 939 @property bool collisionUseKinematic() 940 { 941 return getCollisionUseKinematic(); 942 } 943 /// ditto 944 @property void collisionUseKinematic(bool v) 945 { 946 setCollisionUseKinematic(v); 947 } 948 /** 949 If `true`, this tilemap's collision shape will be added to the collision shape of the parent. The parent has to be a $(D CollisionObject2D). 950 */ 951 @property bool collisionUseParent() 952 { 953 return getCollisionUseParent(); 954 } 955 /// ditto 956 @property void collisionUseParent(bool v) 957 { 958 setCollisionUseParent(v); 959 } 960 /** 961 If `true`, the compatibility with the tilemaps made in Godot 3.1 or earlier is maintained (textures move when the tile origin changes and rotate if the texture size is not homogeneous). This mode presents problems when doing `flip_h`, `flip_v` and `transpose` tile operations on non-homogeneous isometric tiles (e.g. 2:1), in which the texture could not coincide with the collision, thus it is not recommended for isometric or non-square tiles. 962 If `false`, the textures do not move when doing `flip_h`, `flip_v` operations if no offset is used, nor when changing the tile origin. 963 The compatibility mode doesn't work with the $(D centeredTextures) option, because displacing textures with the $(D cellTileOrigin) option or in irregular tiles is not relevant when centering those textures. 964 */ 965 @property bool compatibilityMode() 966 { 967 return isCompatibilityModeEnabled(); 968 } 969 /// ditto 970 @property void compatibilityMode(bool v) 971 { 972 setCompatibilityMode(v); 973 } 974 /** 975 The TileMap orientation mode. See $(D mode) for possible values. 976 */ 977 @property TileMap.Mode mode() 978 { 979 return getMode(); 980 } 981 /// ditto 982 @property void mode(long v) 983 { 984 setMode(v); 985 } 986 /** 987 The light mask assigned to all light occluders in the TileMap. The TileSet's light occluders will cast shadows only from Light2D(s) that have the same light mask(s). 988 */ 989 @property long occluderLightMask() 990 { 991 return getOccluderLightMask(); 992 } 993 /// ditto 994 @property void occluderLightMask(long v) 995 { 996 setOccluderLightMask(v); 997 } 998 /** 999 If `true`, collision shapes are visible in the editor. Doesn't affect collision shapes visibility at runtime. To show collision shapes at runtime, enable $(B Visible Collision Shapes) in the $(B Debug) menu instead. 1000 */ 1001 @property bool showCollision() 1002 { 1003 return isShowCollisionEnabled(); 1004 } 1005 /// ditto 1006 @property void showCollision(bool v) 1007 { 1008 setShowCollision(v); 1009 } 1010 /** 1011 The assigned $(D TileSet). 1012 */ 1013 @property TileSet tileSet() 1014 { 1015 return getTileset(); 1016 } 1017 /// ditto 1018 @property void tileSet(TileSet v) 1019 { 1020 setTileset(v); 1021 } 1022 }