diff options
author | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-16 17:14:36 +0100 |
---|---|---|
committer | jacopograndi <jacopo.grandi@outlook.it> | 2022-01-16 17:14:36 +0100 |
commit | 5781b7dad68c3e01d83365f73b0d35d9e5252f97 (patch) | |
tree | dada65ab375ed8287b33e6ffe023f5df5e666d24 /scripts/pointer.gd | |
parent | 8e5358aaefa1df729ffc02047e53b62705d6b3b1 (diff) |
control system
Diffstat (limited to 'scripts/pointer.gd')
-rw-r--r-- | scripts/pointer.gd | 28 |
1 files changed, 28 insertions, 0 deletions
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 |