33 lines
917 B
GDScript
33 lines
917 B
GDScript
extends Node2D
|
|
|
|
class_name GameWorld
|
|
|
|
enum Map { RUNTIME, ODYSSEY }
|
|
|
|
export(Map) var mapToLoad = Map.RUNTIME
|
|
|
|
const runtimeRes = preload("res://Scenes/Maps/runtime.tscn")
|
|
const odysseyRes = preload("res://Scenes/Maps/odyssey.tscn")
|
|
const playerRes = preload("res://Actors/Player/Player.tscn")
|
|
|
|
var map = null
|
|
var player = null
|
|
|
|
func _ready():
|
|
match mapToLoad:
|
|
Map.RUNTIME:
|
|
map = runtimeRes.instance()
|
|
Map.ODYSSEY:
|
|
map = odysseyRes.instance()
|
|
add_child(map)
|
|
for tilemap in map.tilemaps:
|
|
if tilemap is MapTiles:
|
|
tilemap.set_occluder_origin(player)
|
|
player = playerRes.instance()
|
|
player.is_controlled = true
|
|
var spawnpoints = map.get_pois(POIData.POIType.SpawnPoint, POIData.POIClass.Player)
|
|
if spawnpoints.size() > 0:
|
|
player.transform.origin = (spawnpoints[0] as Node2D).transform.origin
|
|
else:
|
|
print("Map does not have Player spawnpoint POI! Spawning at origin (very bad)")
|
|
add_child(player)
|