diff --git a/assets/models/weapons/rifle.blend b/assets/models/weapons/rifle.blend index 14350ed0..a31e7a9f 100644 Binary files a/assets/models/weapons/rifle.blend and b/assets/models/weapons/rifle.blend differ diff --git a/assets/models/weapons/rifle.blend1 b/assets/models/weapons/rifle.blend1 index ec7c18bd..a2ea4e99 100644 Binary files a/assets/models/weapons/rifle.blend1 and b/assets/models/weapons/rifle.blend1 differ diff --git a/modules/wave_survival/player_body.h b/modules/wave_survival/player_body.h index 75b1a64a..090c76be 100644 --- a/modules/wave_survival/player_body.h +++ b/modules/wave_survival/player_body.h @@ -27,8 +27,8 @@ public: private: bool try_running{ false }; - float walk_speed{ 7.f }; - float run_speed{ 10.f }; + float walk_speed{ 6.f }; + float run_speed{ 8.f }; float acceleration{ 40.f }; float jump_strength{ 3.5f }; Vector2 movement_input{}; diff --git a/modules/wave_survival/weapon_base.cpp b/modules/wave_survival/weapon_base.cpp index 095c8ded..3fff652e 100644 --- a/modules/wave_survival/weapon_base.cpp +++ b/modules/wave_survival/weapon_base.cpp @@ -37,3 +37,11 @@ AnimationPlayer *WeaponBase::get_anim() const { PlayerCamera *WeaponBase::get_camera() const { return this->camera; } + +void WeaponBase::set_body(PlayerBody *body) { + this->body = body; +} + +PlayerBody *WeaponBase::get_body() const { + return this->body; +} diff --git a/modules/wave_survival/weapon_base.h b/modules/wave_survival/weapon_base.h index 50ce7357..065f8966 100644 --- a/modules/wave_survival/weapon_base.h +++ b/modules/wave_survival/weapon_base.h @@ -4,6 +4,7 @@ #include "scene/3d/node_3d.h" class AnimationPlayer; class PlayerCamera; +class PlayerBody; class WeaponBase : public Node3D { GDCLASS(WeaponBase, Node3D); @@ -16,12 +17,15 @@ protected: public: void set_anim(AnimationPlayer *player); AnimationPlayer *get_anim() const; - PlayerCamera *get_camera() const; + void set_body(PlayerBody *body); + PlayerBody *get_body() const; + private: AnimationPlayer *anim{ nullptr }; PlayerCamera *camera{ nullptr }; + PlayerBody *body{ nullptr }; }; #endif // !WEAPON_BASE_H diff --git a/modules/wave_survival/weapon_inventory.cpp b/modules/wave_survival/weapon_inventory.cpp new file mode 100644 index 00000000..4160c73e --- /dev/null +++ b/modules/wave_survival/weapon_inventory.cpp @@ -0,0 +1,10 @@ +#include "weapon_inventory.h" + +void WeaponInventory::_bind_methods() {} + +void WeaponInventory::on_switch_input() { + this->current = (this->current + 1) % 1; + this->select_weapon(this->weapons[this->current]); +} + + diff --git a/modules/wave_survival/weapon_inventory.h b/modules/wave_survival/weapon_inventory.h new file mode 100644 index 00000000..0487e38b --- /dev/null +++ b/modules/wave_survival/weapon_inventory.h @@ -0,0 +1,33 @@ +#ifndef WEAPON_INVENTORY_H +#define WEAPON_INVENTORY_H + +#include "scene/main/node.h" +#include "scene/resources/packed_scene.h" +class PlayerBody; +class WeaponBase; + +class WeaponInventory : public Node { + GDCLASS(WeaponInventory, Node); + static void _bind_methods(); + void on_switch_input(); + void ready(); + void select_weapon(WeaponBase *next); +protected: + void _notification(int what); + +public: + void set_fallback_weapon(Ref scene); + Ref get_fallback_weapon() const; + + WeaponBase *get_current_weapon() const; + +private: + unsigned current{ 0 }; + LocalVector weapons{ nullptr, nullptr }; + WeaponBase *current_weapon{ nullptr }; + WeaponBase *fallback_weapon{ nullptr }; + + Ref default_weapon_scene{}; +}; + +#endif // !WEAPON_INVENTORY_H