diff --git a/src/register_types.cpp b/src/register_types.cpp index cd341dd..f54187a 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -9,6 +9,7 @@ #include "tunnels_game_state.hpp" #include "tunnels_player.hpp" #include "weapon_data.hpp" +#include "weapon_muzzle.hpp" #include "utils/game_mode.hpp" #include "utils/game_root.hpp" #include "utils/game_state.hpp" @@ -35,16 +36,21 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level) ClassDB::register_class<PlayerInput>(); ClassDB::register_class<SpawnPoint3D>(); - ClassDB::register_class<CharacterData>(); - ClassDB::register_class<Enemy>(); - ClassDB::register_class<Health>(); - ClassDB::register_class<PelletProjectile>(); - ClassDB::register_class<PlayerCharacter>(); - ClassDB::register_class<ProjectilePool>(); ClassDB::register_class<TunnelsGameMode>(); ClassDB::register_class<TunnelsGameState>(); ClassDB::register_class<TunnelsPlayer>(); + + ClassDB::register_class<Enemy>(); + ClassDB::register_class<Health>(); + ClassDB::register_class<PlayerCharacter>(); + ClassDB::register_class<ProjectilePool>(); + ClassDB::register_class<WeaponMuzzle>(); + ClassDB::register_class<WeaponData>(); + ClassDB::register_class<CharacterData>(); + + ClassDB::register_class<Projectile>(); + ClassDB::register_class<PelletProjectile>(); } extern "C" diff --git a/src/weapon_muzzle.cpp b/src/weapon_muzzle.cpp new file mode 100644 index 0000000..cb7d932 --- /dev/null +++ b/src/weapon_muzzle.cpp @@ -0,0 +1,16 @@ +#include "weapon_muzzle.hpp" +#include "player_character.hpp" +#include "utils/godot_macros.h" + +namespace godot { +void WeaponMuzzle::_bind_methods() { +#define CLASSNAME WeaponMuzzle +} + +void WeaponMuzzle::_enter_tree() { GDGAMEONLY(); + PlayerCharacter *owner = Object::cast_to<PlayerCharacter>(this->get_owner()); + if(!owner) + return; + owner->set_weapon_muzzle(this); +} +} diff --git a/src/weapon_muzzle.hpp b/src/weapon_muzzle.hpp new file mode 100644 index 0000000..3c8922b --- /dev/null +++ b/src/weapon_muzzle.hpp @@ -0,0 +1,15 @@ +#ifndef WEAPON_MUZZLE_HPP +#define WEAPON_MUZZLE_HPP + +#include "godot_cpp/classes/node3d.hpp" + +namespace godot { +class WeaponMuzzle : public Node3D { + GDCLASS(WeaponMuzzle, Node3D); + static void _bind_methods(); +public: + virtual void _enter_tree() override; +}; +} + +#endif // !WEAPON_MUZZLE_HPP