67 lines
1.4 KiB
C++
67 lines
1.4 KiB
C++
#include "revolver.h"
|
|
#include "scene/animation/animation_player.h"
|
|
#include "wave_survival/player_input.h"
|
|
|
|
void Revolver::_bind_methods() {
|
|
}
|
|
|
|
void Revolver::play_equip_anim() {
|
|
get_anim()->play("equip", 0.0);
|
|
get_anim()->queue("idle_double");
|
|
get_anim()->advance(0.0);
|
|
}
|
|
|
|
void Revolver::shoot() {
|
|
if (!is_animating()) {
|
|
this->muzzle->shoot();
|
|
if (this->alt_requested) {
|
|
get_anim()->queue("fire_single");
|
|
get_anim()->queue("idle_single");
|
|
} else {
|
|
get_anim()->queue("fire_double");
|
|
get_anim()->queue("idle_double");
|
|
}
|
|
}
|
|
}
|
|
|
|
void Revolver::on_primary_fire(bool pressed) {
|
|
if (pressed) {
|
|
shoot();
|
|
}
|
|
}
|
|
|
|
void Revolver::on_alt_mode(bool pressed) {
|
|
this->alt_requested = pressed;
|
|
}
|
|
|
|
void Revolver::ready() {
|
|
this->muzzle = cast_to<HitscanMuzzle>(get_node(NodePath("%HitscanMuzzle")));
|
|
get_input()->connect(PlayerInput::sig_primary_fire, callable_mp(this, &self_type::on_primary_fire));
|
|
get_input()->connect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode));
|
|
play_equip_anim();
|
|
}
|
|
|
|
void Revolver::process(double delta) {
|
|
}
|
|
|
|
void Revolver::_notification(int what) {
|
|
if (Engine::get_singleton()->is_editor_hint()) {
|
|
return;
|
|
}
|
|
switch (what) {
|
|
default:
|
|
return;
|
|
case NOTIFICATION_READY:
|
|
set_process(true);
|
|
ready();
|
|
return;
|
|
case NOTIFICATION_PROCESS:
|
|
process(get_process_delta_time());
|
|
return;
|
|
}
|
|
}
|
|
|
|
void Revolver::notify_selected() {
|
|
play_equip_anim();
|
|
}
|