diff options
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 |