From 5781b7dad68c3e01d83365f73b0d35d9e5252f97 Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Sun, 16 Jan 2022 17:14:36 +0100 Subject: control system --- scripts/pointer.gd | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 scripts/pointer.gd (limited to 'scripts/pointer.gd') diff --git a/scripts/pointer.gd b/scripts/pointer.gd new file mode 100644 index 0000000..8401ec6 --- /dev/null +++ b/scripts/pointer.gd @@ -0,0 +1,28 @@ +extends Spatial + +var load_turrets : Node + +func fetch (): + if load_turrets != null: return + var root = get_tree().root.get_node("world") + + load_turrets = root.get_node("saveload").get_node("load_turrets") + if !load_turrets.loaded: yield(load_turrets, "done_loading") + +func refresh (state, statetype, turret_name : String = ""): + fetch() + for child in get_children(): + if child.name != "base": child.queue_free(); + get_node("base").visible = false + + if state == Globals.PlayerState.PLACE: + if statetype == Globals.StateType.TURRET: + if turret_name != "": + var info = load_turrets.info[turret_name] + var model = load_turrets.models[info.model_name] + var instance_model = model.instance() + instance_model.name = "preview" + add_child(instance_model) + get_node("base").visible = false + else: + get_node("base").visible = true -- cgit v1.2.3-54-g00ecf