Bomb fix
This commit is contained in:
parent
b4f6f65f2b
commit
02842948ba
4 changed files with 24 additions and 12 deletions
|
|
@ -16,3 +16,5 @@ metadata/_custom_type_script = "uid://e6lqknfl4ngt"
|
|||
|
||||
[node name="Main" type="Node" parent="."]
|
||||
script = ExtResource("2_870cc")
|
||||
|
||||
[node name="Idle" type="Node" parent="."]
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ var player_nodes: Dictionary[int,Player] = {}
|
|||
|
||||
var dynamic_objects_spawner: MultiplayerSpawner
|
||||
|
||||
## Spawns dynamic object at game scene [br]
|
||||
## Dictionary keys: [br]
|
||||
## (Required) scene - path/uuid to scene [br]
|
||||
## (Optional) position - position to spawn [br]
|
||||
## (Optional) impulse - impulse to apply [br]
|
||||
## (Optional but required for each other) [br]
|
||||
## ammo, remaining_ammo, slot - data for dropped weapon [br]
|
||||
## for more, see dyn_objects_spawner.gd
|
||||
func spawn(data: Dictionary) -> void:
|
||||
spawn_internal.rpc_id(1,data)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,15 @@ func _ready() -> void:
|
|||
Session.dynamic_objects_spawner = self
|
||||
|
||||
func request_spawn(data: Variant) -> Node:
|
||||
if data.has_all(["scene","impulse"]):
|
||||
var projectile: RigidBody3D = load(data.scene).instantiate()
|
||||
if data.has("scene") == false:
|
||||
return Node.new()
|
||||
var node = load(data.scene).instantiate()
|
||||
if data.has(["impulse"]):
|
||||
if data.has_all(["ammo","remaining_ammo","slot"]):
|
||||
projectile.weapon.ammo = data.ammo
|
||||
projectile.weapon.remaining_ammo = data.remaining_ammo
|
||||
projectile.slot = data.slot
|
||||
node.weapon.ammo = data.ammo
|
||||
node.weapon.remaining_ammo = data.remaining_ammo
|
||||
node.slot = data.slot
|
||||
|
||||
projectile.apply_impulse(data.impulse)
|
||||
return projectile
|
||||
return Node.new()
|
||||
node.apply_impulse(data.impulse)
|
||||
return node
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
extends WeaponState
|
||||
|
||||
const active_bomb: PackedScene = preload("res://scenes/weapons/active_bomb.tscn")
|
||||
const active_bomb: StringName = "uid://dtbpyfdawb02b"
|
||||
|
||||
func enter():
|
||||
machine.animation_player.play(machine.animation_prefix+"plant")
|
||||
|
|
@ -11,10 +11,10 @@ func exit():
|
|||
|
||||
func on_animation_finished(animation: StringName):
|
||||
if animation == machine.animation_prefix + "plant":
|
||||
var bomb = active_bomb.instantiate()
|
||||
Session.dynamic_objects_container.add_child(bomb,true)
|
||||
bomb.global_position = machine.player_camera.get_parent().global_position
|
||||
|
||||
Session.spawn({"scene": active_bomb, "position": machine.player_camera.get_parent().global_position})
|
||||
|
||||
machine.ammo -= 1
|
||||
return_to_previous.emit()
|
||||
|
||||
func state_input(event: InputEvent) -> void:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue