feat: added revolver
This commit is contained in:
parent
3b22cd86f7
commit
6eba3b0454
17 changed files with 195 additions and 29 deletions
66
modules/wave_survival/weapons/revolver.cpp
Normal file
66
modules/wave_survival/weapons/revolver.cpp
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue