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

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)