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.
2020-07-06 12:38:05 +00:00
|
|
|
extends Node2D
|
|
|
|
|
2020-07-06 22:00:39 +00:00
|
|
|
class_name GameWorld
|
|
|
|
|
2020-07-10 08:45:57 +00:00
|
|
|
enum Map { RUNTIME, ODYSSEY }
|
2020-07-06 12:38:05 +00:00
|
|
|
|
2020-07-10 08:45:57 +00:00
|
|
|
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
|
2020-07-06 12:38:05 +00:00
|
|
|
|
|
|
|
func _ready():
|
2020-07-10 08:45:57 +00:00
|
|
|
match mapToLoad:
|
|
|
|
Map.RUNTIME:
|
|
|
|
map = runtimeRes.instance()
|
|
|
|
Map.ODYSSEY:
|
|
|
|
map = odysseyRes.instance()
|
|
|
|
add_child(map)
|
|
|
|
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)
|
2020-07-10 11:31:16 +00:00
|
|
|
for tilemap in map.tilemaps:
|
|
|
|
if tilemap is MapTiles:
|
|
|
|
tilemap.set_occluder_origin(player)
|