aboutsummaryrefslogtreecommitdiff
path: root/client/map
diff options
context:
space:
mode:
Diffstat (limited to 'client/map')
-rw-r--r--client/map/map.gd26
1 files changed, 17 insertions, 9 deletions
diff --git a/client/map/map.gd b/client/map/map.gd
index ef7c69c9..161b14fb 100644
--- a/client/map/map.gd
+++ b/client/map/map.gd
@@ -16,7 +16,15 @@
class_name Map
extends Node3D
-var tile_by_pos: Dictionary = {} # Dictionary[String, [Vector2i, String, Tile, Array]]
+class TileInfo:
+ func _init(position_, name_, tile_, neighbours_) -> void:
+ position = position_; name = name_; tile = tile_; neighbours = neighbours_
+ var position: Vector2i
+ var name: String
+ var tile: Tile
+ var neighbours: Array
+
+var tile_by_pos: Dictionary[String, TileInfo] = {}
var autobake = false
var currently_baked = false
var floor_node := MeshInstance3D.new()
@@ -24,11 +32,11 @@ var tile_factory = TileFactory.new()
func get_tile_name(pos: Vector2i): # -> String?
var e = tile_by_pos.get(str(pos))
- if e != null: return e[1]
+ if e != null: return e.name
else: return null
func get_tile_instance(pos: Vector2i) -> Tile:
var e = tile_by_pos.get(str(pos))
- if e != null: return e[2]
+ if e != null: return e.tile
else: return null
func set_tile(pos: Vector2i, name_: String, neighbors: Array = [null,null,null,null]) -> Tile:
@@ -36,7 +44,7 @@ func set_tile(pos: Vector2i, name_: String, neighbors: Array = [null,null,null,n
var tile := tile_factory.produce(name_, pos, neighbors)
add_child(tile)
tile.position = Vector3(pos.x, 0, pos.y)
- tile_by_pos[str(pos)] = [pos, name_, tile, neighbors]
+ tile_by_pos[str(pos)] = TileInfo.new(pos, name_, tile, neighbors)
return tile
func clear_tile(pos: Vector2i):
@@ -95,9 +103,9 @@ func gi_bake_blocking():
func extents() -> Array[Vector2]:
var extent_min = Vector2(0,0)
var extent_max = Vector2(0,0)
- for e in tile_by_pos.values():
- extent_min.x = min(extent_min.x, e[0].x)
- extent_min.y = min(extent_min.y, e[0].y)
- extent_max.x = max(extent_max.x, e[0].x)
- extent_max.y = max(extent_max.y, e[0].y)
+ for e: TileInfo in tile_by_pos.values():
+ extent_min.x = min(extent_min.x, e.position.x)
+ extent_min.y = min(extent_min.y, e.position.y)
+ extent_max.x = max(extent_max.x, e.position.x)
+ extent_max.y = max(extent_max.y, e.position.y)
return [extent_min, extent_max + Vector2(1., 1.)]