# Rally Rush: src/drone.hpp Source File

Loading...
Searching...
No Matches
drone.hpp
Go to the documentation of this file.
#ifndef DRONE_HPP
#define DRONE_HPP
#include "car_player.hpp"
#include "godot_cpp/classes/animation_player.hpp"
#include "godot_cpp/classes/navigation_agent3d.hpp"
#include "godot_cpp/classes/packed_scene.hpp"
#include <godot_cpp/classes/node3d.hpp>
namespace godot {
enum class DroneState {
CHASE,
DROP,
FLEE
};
class Drone : public Node3D {
GDCLASS(Drone, Node3D);
static void _bind_methods();
public:
virtual void _ready() override;
virtual void _process(double delta_time) override;
void process_chase(double delta_time);
void process_flee(double delta_time);
void process_navigate(double delta_time);
void recalculate_navigation();
void spawn_explosion();
void key_found(int total);
void start_flee();
void end_flee();
void set_explosion_scene(Ref<PackedScene> scene);
Ref<PackedScene> get_explosion_scene() const;
private:
int recalc_frame_interval{10};
int next_recalc{10};
float speed{30.f};
float lead_time{2.f};
float target_distance{3.f};
DroneState state{DroneState::CHASE};
CarPlayer *player{nullptr};
Ref<PackedScene> explosion_scene{};
NavigationAgent3D *agent{nullptr};
AnimationPlayer *anim{nullptr};
};
}
#endif // !DRONE_HPP
car_player.hpp
godot::CarPlayer
Sandboxed subclass of CarPhysics.
Definition car_player.hpp:18
godot::Drone
An enemy drone, moves around using navigation. Model is expected to float well above the transform or...
Definition drone.hpp:22
godot::Drone::agent
NavigationAgent3D * agent
Navigation agent Component.
Definition drone.hpp:72
godot::Drone::anim
AnimationPlayer * anim
Animation player component.
Definition drone.hpp:74
godot::Drone::speed
float speed
Movement speed in m/s.
Definition drone.hpp:59
godot::Drone::_bind_methods
static void _bind_methods()
Register properties.
Definition drone.cpp:11
godot::Drone::_process
virtual void _process(double delta_time) override
Update the state machine.
Definition drone.cpp:27
godot::Drone::target_distance
float target_distance
distance at which to drop
Definition drone.hpp:63
godot::Drone::explosion_scene
Ref< PackedScene > explosion_scene
Scene to spawn when exploding.
Definition drone.hpp:69
godot::Drone::end_flee
void end_flee()
Listener for when the player drop their turret pickup.
Definition drone.cpp:94
godot::Drone::spawn_explosion
void spawn_explosion()
Spawn an explosion after dropping.
Definition drone.cpp:74
godot::Drone::process_navigate
void process_navigate(double delta_time)
Navigate according to path.
Definition drone.cpp:54
godot::Drone::lead_time
float lead_time
How far ahead of the player to target.
Definition drone.hpp:61
godot::Drone::next_recalc
int next_recalc
Frame timer for next pathing recalculation.
Definition drone.hpp:57
godot::Drone::get_explosion_scene
Ref< PackedScene > get_explosion_scene() const
The explosion to spawn after dropping.
Definition drone.cpp:103
godot::Drone::recalc_frame_interval
int recalc_frame_interval
Time between pathing recalculations.
Definition drone.hpp:55
godot::Drone::recalculate_navigation
void recalculate_navigation()
Recalculate pathing based on current state.
Definition drone.cpp:64
godot::Drone::process_flee
void process_flee(double delta_time)
Flee state, Flee away from the player.
Definition drone.cpp:50
godot::Drone::player
CarPlayer * player
Target to chase / flee from.
Definition drone.hpp:67
godot::Drone::start_flee
void start_flee()
Listener for when the player grabs a turret pickup.
Definition drone.cpp:88
godot::Drone::GDCLASS
GDCLASS(Drone, Node3D)
godot::Drone::process_chase
void process_chase(double delta_time)
Process the chase state. Navigate ahead of player player and drop when near target.
Definition drone.cpp:42
godot::Drone::state
DroneState state
Current state machine state.
Definition drone.hpp:65
godot::Drone::_ready
virtual void _ready() override
Get required object references and connect observers.
Definition drone.cpp:16
godot::Drone::key_found
void key_found(int total)
Listener for when a key is found, to up the difficulty.
Definition drone.cpp:82
godot::Drone::set_explosion_scene
void set_explosion_scene(Ref< PackedScene > scene)
The explosion to spawn after dropping.
Definition drone.cpp:100
godot
Definition beacon_powerup.cpp:6
godot::DroneState
DroneState
State of a drone.
Definition drone.hpp:12
godot::DroneState::CHASE
@ CHASE
Chase the player.
godot::DroneState::DROP
@ DROP
Stop, drop, and explode.
godot::DroneState::FLEE
@ FLEE
Go anywhere but where the player is.