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

40 lines
1.2 KiB
GDScript3
Raw Permalink Normal View History

2020-07-06 12:38:05 +00:00
extends Node2D
2020-07-06 22:00:39 +00:00
class_name GameWorld
enum Map { RUNTIME, ODYSSEY, EMPTY }
const playerRes = preload("res://Actors/Player/Player.tscn")
var map = null
var player = null
2020-07-06 12:38:05 +00:00
onready var scene_manager = $"/root/SceneManager"
func load_map(map_name):
match map_name:
Map.RUNTIME:
map = scene_manager.queue.get_resource("res://Scenes/Maps/runtime.tscn").instance()
Map.ODYSSEY:
map = scene_manager.queue.get_resource("res://Scenes/Maps/odyssey.tscn").instance()
Map.EMPTY:
map = preload("res://Scenes/Maps/empty.tscn").instance()
add_child(map)
func spawn_player(peer: int, is_current_user: bool):
var playerNode = playerRes.instance()
playerNode.set_network_master(peer, true)
playerNode.is_controlled = is_current_user
var spawnpoints = map.get_pois(POI.POIType.SpawnPoint, POI.POIClass.Player)
if spawnpoints.size() > 0:
playerNode.transform.origin = (spawnpoints[0] as Node2D).transform.origin
else:
print("Map does not have Player spawnpoint POI! Spawning at origin (very bad)")
$players.add_child(playerNode, true)
if is_current_user:
player = playerNode
for tilemap in map.tilemaps:
if tilemap is MapTiles:
tilemap.set_occluder_origin(playerNode)
return playerNode