#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<PlayerInput>(get_parent()->get_node(NodePath("%PlayerInput")));
	this->camera = cast_to<PlayerCamera>(get_parent());
	this->body = cast_to<PlayerBody>(get_parent()->get_owner());
	if (this->anim) {
		this->anim->play("RESET");
	}
}

void WeaponBase::_notification(int what) {
	if (Engine::get_singleton()->is_editor_hint()) {
		return;
	}
	switch (what) {
		default:
			return;
		case NOTIFICATION_READY:
			ready();
	}
}

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;
}
