class_name cLocationManager extends Node var locationsJSON: Dictionary var locations: Array enum eCharacter { CONSTRUCT, YOSHIDA, AKERS, FLESHER } # Called when the node enters the scene tree for the first time. func _init() -> void: print("Init location manager") locationsJSON = Global.loadJSON("res://Data/locations.json") _cache() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: pass func _cache() -> void: var location: cLocation for l in locationsJSON: location = cLocation.new(int(l), locationsJSON) locations.append(location) func setLocationByID(character: eCharacter, currentLocationID: int, newLocationID: int) -> void: pass func setLocationBy(character: eCharacter, currentLocation: cLocation, newLocation: cLocation) -> void: pass func getCharacterLocation(character: eCharacter) -> cLocation: return null func clearLocation(character: eCharacter) -> void: pass # Mainly for the flesher enemy # Will pick a random location, has the option to exclude locations which are not connected # If the office is picked, it will by default roll back to the hangar to prevent an unfair death func randomLocation( currentLocation: int = 0, teleport: bool = false, allowOffice: bool = false, ) -> cLocation: if teleport: var location: cLocation = locations[currentLocation] var validLocations = location.connections return validLocations.pick_random() else: var location: cLocation = locations.pick_random() if not allowOffice && location.id == 0: location = locations[1] return location func canMove(currentLocation: int, newLocation: int) -> bool: var locationA: cLocation = locations[currentLocation] var locationB: cLocation = locations[newLocation] if locationB.connections.has(locationA.id): return true else: return false func getLocation(location: int) -> cLocation: return locations[location]