Files

48 lines
1.0 KiB
GDScript

class_name cCamera
var cam: Dictionary
var camID: int
var camGraph = Global.loadJSON("res://Data/cameras.json")
var name: String
var disabled: bool
var rendersChart: Dictionary
var renders: Dictionary
var locationID: int
var location: cLocation
# Called when the node enters the scene tree for the first time.
func _init(id: int) -> void:
camID = id
if not camGraph.has(str(camID)):
camID = 0
cam = camGraph[str(camID)]
name = cam.get("name")
disabled = cam.get("disabled")
rendersChart = cam.get("renders")
locationID = int( cam.get("location") )
location = Global.locationManager.getLocation(id)
_loadRenders()
func _loadRenders():
renders = {}
for key in rendersChart:
var renderPath = rendersChart[key]
if renderPath == null or not FileAccess.file_exists(renderPath):
push_error("Missing render: " + str(renderPath))
continue
renders[key] = load(renderPath)
func getFeed() -> Texture2D:
var hash = location.makeHash()
if not renders.has(hash): return null
return renders[hash]