bomb spawn im crying
This commit is contained in:
parent
9d0e09220d
commit
3302fcfc96
16 changed files with 148 additions and 15 deletions
|
|
@ -27,9 +27,10 @@ signal switched_to(state: WeaponSubStateMachine)
|
|||
|
||||
func _ready() -> void:
|
||||
current_state = default_pistol
|
||||
add(default_knife,"knife")
|
||||
add(default_pistol,"secondary")
|
||||
current_state.enter()
|
||||
$WeaponSpawner.spawn_function = pick_up_weapon
|
||||
$WeaponSpawner.spawned.connect(on_weapon_added)
|
||||
|
||||
func can_add(slot: StringName) -> bool:
|
||||
return slots.has(slot) and slots[slot] == null
|
||||
|
|
@ -38,12 +39,13 @@ func can_add(slot: StringName) -> bool:
|
|||
func add(state: WeaponSubStateMachine, slot: StringName) -> void:
|
||||
if can_add(slot) == false:
|
||||
return
|
||||
print('leech')
|
||||
|
||||
if state.get_parent() == null:
|
||||
add_child(state)
|
||||
add_child(state, true)
|
||||
if state.get_parent() != self:
|
||||
state.reparent(self)
|
||||
state.get_parent().remove_child(state)
|
||||
add_child(state,true)
|
||||
state.ready.emit()
|
||||
|
||||
slots[slot] = state
|
||||
state.system = self
|
||||
|
|
@ -67,6 +69,25 @@ func switch(to: StringName):
|
|||
|
||||
update_remotes.rpc(to)
|
||||
|
||||
func drop(): pass
|
||||
|
||||
# Spawn function
|
||||
# Data should be a dictionary with these keys:
|
||||
# ammo
|
||||
# remaining_ammo
|
||||
# scene_file_path
|
||||
func pick_up_weapon(data: Variant) -> Node:
|
||||
if data.has("ammo") == false or data.has("remaining_ammo") == false or data.has("scene_file_path") == false or data.has("slot") == false:
|
||||
return null
|
||||
var scene: WeaponSubStateMachine = load(data["scene_file_path"]).instantiate()
|
||||
scene.ammo = data["ammo"]
|
||||
scene.remaining_ammo = data["remaining_ammo"]
|
||||
scene.slot = data["slot"]
|
||||
return scene
|
||||
|
||||
func on_weapon_added(weapon: Node):
|
||||
add(weapon,weapon.slot)
|
||||
|
||||
func return_to_previous():
|
||||
if last_slot != "":
|
||||
switch(last_slot)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue