#include "weapon_base.h" #include "macros.h" #include "player_body.h" #include "player_camera.h" #include "player_input.h" #include "scene/animation/animation_player.h" void WeaponBase::_bind_methods() { BIND_HPROPERTY(Variant::OBJECT, anim, PROPERTY_HINT_NODE_TYPE, AnimationPlayer::get_class_static()); } void WeaponBase::ready() { this->input = cast_to(get_parent()->get_node(NodePath("%PlayerInput"))); this->camera = cast_to(get_parent()); this->body = cast_to(get_parent()->get_owner()); } void WeaponBase::_notification(int what) { if (Engine::get_singleton()->is_editor_hint()) { return; } switch (what) { default: return; case NOTIFICATION_READY: ready(); } } PackedStringArray WeaponBase::get_configuration_warnings() const { PackedStringArray warnings{ super_type::get_configuration_warnings() }; if (this->anim == nullptr) { warnings.push_back("Weapons need something to animate them.\nRemember to configure the 'anim' property on this weapon"); } return warnings; } bool WeaponBase::is_animating() const { return !get_anim()->get_current_animation().is_empty() || !get_anim()->get_queue().is_empty(); } void WeaponBase::set_anim(AnimationPlayer *anim) { this->anim = anim; } AnimationPlayer *WeaponBase::get_anim() const { return this->anim; } PlayerInput *WeaponBase::get_input() const { return this->input; } 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; }