feat: implemented bullet impacts

This commit is contained in:
Sara 2025-07-19 12:33:40 +02:00
parent 7a5c129bb9
commit a7b3f97b3b
14 changed files with 644 additions and 12 deletions

View file

@ -1,5 +1,6 @@
#include "rifle.h"
#include "scene/animation/animation_player.h"
#include "wave_survival/hitscan_muzzle.h"
#include "wave_survival/player_body.h"
#include "wave_survival/player_input.h"
@ -36,6 +37,7 @@ void Rifle::stop_run_anim() {
void Rifle::shoot() {
if (!is_animating()) {
this->muzzle->shoot();
if (this->request_alt_mode) {
get_anim()->queue("fire_aim");
} else {
@ -76,6 +78,7 @@ void Rifle::on_animation_changed(String new_animation) {
}
void Rifle::ready() {
this->muzzle = cast_to<HitscanMuzzle>(get_node(NodePath("%HitscanMuzzle")));
get_anim()->connect("current_animation_changed", callable_mp(this, &self_type::on_animation_changed));
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));

View file

@ -4,6 +4,7 @@
#include "wave_survival/player_camera.h"
#include "wave_survival/weapon_base.h"
class PlayerBody;
class HitscanMuzzle;
class Rifle : public WeaponBase {
GDCLASS(Rifle, WeaponBase);
@ -35,6 +36,8 @@ private:
bool request_alt_mode{ false };
bool in_alt_mode{ false };
bool running{ false };
HitscanMuzzle *muzzle{ nullptr };
};
#endif // !WEAPONS_RIFLE_H