blob: 8401ec64047e3675fae80e2c7cbd0f1d9dfe3bf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
|