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

18 lines
458 B
GDScript3
Raw Permalink Normal View History

2020-07-06 16:41:30 +00:00
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)