28 lines
864 B
GDScript
28 lines
864 B
GDScript
extends WeaponState
|
|
|
|
const molik: PackedScene = preload("res://scenes/weapons/molik.tscn")
|
|
|
|
func enter() -> void:
|
|
fire()
|
|
machine.animation_player.animation_finished.connect(on_animation_finished)
|
|
|
|
func exit() -> void:
|
|
machine.animation_player.animation_finished.disconnect(on_animation_finished)
|
|
|
|
func on_animation_finished(animation):
|
|
if animation == machine.animation_prefix + "throw":
|
|
transition.emit("Idle")
|
|
|
|
func fire() -> void:
|
|
if machine.ammo == 0:
|
|
return
|
|
machine.ammo -= 1
|
|
|
|
machine.animation_player.stop()
|
|
machine.animation_player.play(machine.animation_prefix + "shoot")
|
|
|
|
if is_multiplayer_authority():
|
|
var molotov: RigidBody3D = molik.instantiate()
|
|
Session.dynamic_objects_spawner.get_parent().add_child(molotov)
|
|
molotov.global_transform = machine.player_camera.global_transform
|
|
molotov.apply_impulse(-molotov.global_basis.z * 10)
|