4#include <godot_cpp/classes/area3d.hpp>
5#include <godot_cpp/classes/packed_scene.hpp>
6#include <godot_cpp/classes/rigid_body3d.hpp>
7#include <godot_cpp/templates/hash_set.hpp>
8#include <godot_cpp/templates/vector.hpp>
32 virtual void _process(
double delta_time)
override;
Generic turret class with the ability to target any type of node as configured. Used for both the pla...
Definition turret.hpp:24
Ref< PackedScene > guiding_beam_scene
Scene to spawn when charging.
Definition turret.hpp:113
void set_charge_time(float val)
The duration of the guiding lazer.
Definition turret.cpp:177
virtual void _process(double delta_time) override
Update state machine. Update gun node position.
Definition turret.cpp:33
void set_lock_time(float val)
The delay between firing and charging the next shot.
Definition turret.cpp:185
float get_fire_time() const
The duration of the damaging lazer.
Definition turret.cpp:173
Node3D * select_target()
Select a target from the currently known nodes.
Definition turret.cpp:59
GDCLASS(Turret, RigidBody3D)
float get_lock_time() const
The delay between firing and charging the next shot.
Definition turret.cpp:189
Ref< PackedScene > beam_scene
Scene to spawn when firing.
Definition turret.hpp:111
void detect_node(Node3D *node)
Become aware of a node in the awareness area.
Definition turret.cpp:92
TurretState state
Current state-machine state of the turret.
Definition turret.hpp:103
HashSet< Node3D * > awareness
Set of all nodes the turret is currently aware of.
Definition turret.hpp:108
float fire_time
Definition turret.hpp:115
Vector3 last_target_position
Position of the current_target on the last frame.
Definition turret.hpp:91
void lose_node(Node3D *node)
Lose track of a node exiting the awareness area.
Definition turret.cpp:99
void beam_ended()
End the fire state.
Definition turret.cpp:164
void lead_target(double delta_time)
Aim ahead of the current target.
Definition turret.cpp:73
Array get_attack_classes() const
Set the node classes to attack while invert_targets is false.
Definition turret.cpp:212
float last_state_switch
Last time the state was changed.
Definition turret.hpp:93
float get_charge_time() const
The duration of the guiding lazer.
Definition turret.cpp:181
float lead_distance
Distance ahead of target to aim.
Definition turret.hpp:95
void set_attack_classes(Array array)
Set the node classes to attack while invert_targets is false.
Definition turret.cpp:202
Vector3 gun_node_offset
Position offset of the gun.
Definition turret.hpp:100
Ref< PackedScene > get_beam_scene() const
Set the scene to spawn when firing.
Definition turret.cpp:223
void awareness_changed()
Check if a new target needs to be found. Find a new target if required.
Definition turret.cpp:45
bool invert_attack_classes
If true, target classes not in attack_classes.
Definition turret.hpp:87
void set_fire_time(float val)
The duration of the damaging lazer.
Definition turret.cpp:169
static void _bind_methods()
register editor properties
Definition turret.cpp:12
Node3D * current_target
The current target node.
Definition turret.hpp:85
void set_invert_targets(bool value)
Set to true to target everything but the attack_classes.
Definition turret.cpp:193
void try_next_state()
Try transition to the next state if possible.
Definition turret.cpp:109
void create_guiding_beam()
Create a non-damaging guiding beam.
Definition turret.cpp:152
float lock_time
Definition turret.hpp:117
Node3D * gun_node
The child node representing the gun.
Definition turret.hpp:98
Ref< PackedScene > get_guiding_beam_scene() const
Set the scene to spawn when charging.
Definition turret.cpp:231
Vector3 aim_position
Position currently being aimed at.
Definition turret.hpp:89
Vector< StringName > attack_classes
Names of classes to attack.
Definition turret.hpp:106
virtual void _enter_tree() override
Freeze physics and connect awareness observers. Fetch child nodes and initialize them....
Definition turret.cpp:22
float charge_time
Definition turret.hpp:116
void create_beam()
Create a damaging beam.
Definition turret.cpp:139
void set_beam_scene(Ref< PackedScene > scene)
Set the scene to spawn when firing.
Definition turret.cpp:219
void set_guiding_beam_scene(Ref< PackedScene > scene)
Set the scene to spawn when charging.
Definition turret.cpp:227
Definition beacon_powerup.cpp:6
TurretState
Current state of a turret.
Definition turret.hpp:12
@ WAITING
No known valid targets.
@ FIRING
Wait for beam to end.
@ LOCKING
Aim in front of an enemy.