This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Scenes/Maps/Objects.gd
2020-07-06 18:41:30 +02:00

17 lines
458 B
GDScript

extends TileMap
const objects = {
"Door": preload("res://Actors/Objects/Door/Door.tscn")
}
func _ready():
for cell in get_used_cells():
var id = get_cellv(cell)
var name = tile_set.tile_get_name(id)
if objects.has(name):
var obj = objects[name].instance() as Node2D
add_child(obj)
obj.transform.origin = map_to_world(cell)
else:
print("Placed object tile ", name, " at ", cell, " but has no object associated!")
set_cellv(cell, -1)