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/InEditorMap.gd

38 lines
1.0 KiB
GDScript3
Raw Normal View History

2020-09-11 09:29:06 +00:00
extends Node2D
2020-09-15 23:23:45 +00:00
var debug_areas := false
2020-09-11 09:29:06 +00:00
2020-09-15 23:23:45 +00:00
const ProbeElectricity := preload("res://Actors/Systems/Electricity/ElectricProbe.tscn")
2020-09-11 09:29:06 +00:00
2020-09-15 23:23:45 +00:00
onready var tilemaps := [ $tiles/base, $tiles/cables, $tiles/floor, $tiles/walls ]
2020-09-11 09:29:06 +00:00
2020-09-15 23:23:45 +00:00
onready var pois := $pois
2020-09-11 09:29:06 +00:00
func _ready():
pass
# Run autotile conversions and generate occlusions
#$tiles/walls.run_conversions()
# Electricity setup
#make_electric_probes($tiles/cables, "Wire")
# Tileset related functions
func make_electric_probes(tilemap: TileMap, tile_name: String):
2020-09-15 23:23:45 +00:00
var tile_id := tilemap.tile_set.find_tile_by_name(tile_name)
2020-09-11 09:29:06 +00:00
for cell in tilemap.get_used_cells_by_id(tile_id):
2020-09-15 23:23:45 +00:00
var coord := tilemap.map_to_world(cell)
var probe := ProbeElectricity.instance()
2020-09-11 09:29:06 +00:00
probe.position = coord
tilemap.add_child(probe)
func get_pois(type_filter, class_filter) -> Array:
2020-09-15 23:23:45 +00:00
var filtered := []
2020-09-11 09:29:06 +00:00
for child in $pois.get_children():
if type_filter != null and child.poitype != type_filter:
continue
if class_filter != null and child.poiclass != class_filter:
continue
filtered.append(child)
return filtered