72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
#ifndef RTS_STATES_HPP
|
|
#define RTS_STATES_HPP
|
|
|
|
#include "goap/state.hpp"
|
|
#include "unit.hpp"
|
|
#include <godot_cpp/classes/animation_player.hpp>
|
|
#include <godot_cpp/classes/navigation_agent3d.hpp>
|
|
|
|
class UtilityLock;
|
|
|
|
/*! Uses navigation to chase the desired target node.
|
|
*/
|
|
class MoveTo : public goap::State {
|
|
GDCLASS(MoveTo, goap::State);
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
virtual void _ready() override;
|
|
virtual void _end_state() override;
|
|
virtual void _process(double) override;
|
|
void calculate_path();
|
|
void on_velocity_computed(gd::Vector3 vel);
|
|
float target_delta_position() const;
|
|
float distance_to_target() const;
|
|
double get_repath_interval() const;
|
|
|
|
public:
|
|
gd::Node3D *target_node{nullptr};
|
|
|
|
private:
|
|
gd::Callable nav_velocity_computed{callable_mp(this, &MoveTo::on_velocity_computed)};
|
|
Unit *parent_unit{nullptr};
|
|
gd::NavigationAgent3D *agent{nullptr};
|
|
gd::Vector3 target_position_at_last{};
|
|
double last_repath{0.0};
|
|
};
|
|
|
|
class Activate : public goap::State {
|
|
GDCLASS(Activate, goap::State);
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
virtual void _ready() override;
|
|
virtual void _process(double) override;
|
|
virtual void _end_state() override;
|
|
UtilityLock *lock{nullptr};
|
|
Item const *using_item{nullptr};
|
|
|
|
private:
|
|
gd::String animation{};
|
|
gd::AnimationPlayer *anim{nullptr};
|
|
Unit *parent_unit{nullptr};
|
|
};
|
|
|
|
class Animate : public goap::State {
|
|
GDCLASS(Animate, goap::State);
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
virtual void _ready() override;
|
|
virtual void _process(double delta_time) override;
|
|
virtual void _end_state() override;
|
|
void _on_animation_finished(gd::String new_anim);
|
|
gd::StringName animation{};
|
|
|
|
private:
|
|
bool is_finished{false};
|
|
gd::AnimationPlayer *anim{nullptr};
|
|
};
|
|
|
|
#endif // !RTS_STATES_HPP
|