Generic turret class with the ability to target any type of node as configured. Used for both the player's roof turret pickup and the enemy turrets.
More...
#include <turret.hpp>
|
virtual void | _enter_tree () override |
| Freeze physics and connect awareness observers. Fetch child nodes and initialize them. Update current awareness.
|
|
virtual void | _process (double delta_time) override |
| Update state machine. Update gun node position.
|
|
void | awareness_changed () |
| Check if a new target needs to be found. Find a new target if required.
|
|
Node3D * | select_target () |
| Select a target from the currently known nodes.
|
|
void | lead_target (double delta_time) |
| Aim ahead of the current target.
|
|
void | detect_node (Node3D *node) |
| Become aware of a node in the awareness area.
|
|
void | lose_node (Node3D *node) |
| Lose track of a node exiting the awareness area.
|
|
void | try_next_state () |
| Try transition to the next state if possible.
|
|
void | create_beam () |
| Create a damaging beam.
|
|
void | create_guiding_beam () |
| Create a non-damaging guiding beam.
|
|
void | beam_ended () |
| End the fire state.
|
|
void | set_fire_time (float val) |
| The duration of the damaging lazer.
|
|
float | get_fire_time () const |
| The duration of the damaging lazer.
|
|
void | set_charge_time (float val) |
| The duration of the guiding lazer.
|
|
float | get_charge_time () const |
| The duration of the guiding lazer.
|
|
void | set_lock_time (float val) |
| The delay between firing and charging the next shot.
|
|
float | get_lock_time () const |
| The delay between firing and charging the next shot.
|
|
void | set_invert_targets (bool value) |
| Set to true to target everything but the attack_classes.
|
|
void | set_attack_classes (Array array) |
| Set the node classes to attack while invert_targets is false.
|
|
Array | get_attack_classes () const |
| Set the node classes to attack while invert_targets is false.
|
|
void | set_beam_scene (Ref< PackedScene > scene) |
| Set the scene to spawn when firing.
|
|
Ref< PackedScene > | get_beam_scene () const |
| Set the scene to spawn when firing.
|
|
void | set_guiding_beam_scene (Ref< PackedScene > scene) |
| Set the scene to spawn when charging.
|
|
Ref< PackedScene > | get_guiding_beam_scene () const |
| Set the scene to spawn when charging.
|
|
Generic turret class with the ability to target any type of node as configured. Used for both the player's roof turret pickup and the enemy turrets.
◆ _bind_methods()
void godot::Turret::_bind_methods |
( |
| ) |
|
|
staticprivate |
register editor properties
◆ _enter_tree()
void godot::Turret::_enter_tree |
( |
| ) |
|
|
overridevirtual |
Freeze physics and connect awareness observers. Fetch child nodes and initialize them. Update current awareness.
◆ _process()
void godot::Turret::_process |
( |
double |
delta_time | ) |
|
|
overridevirtual |
Update state machine. Update gun node position.
◆ awareness_changed()
void godot::Turret::awareness_changed |
( |
| ) |
|
Check if a new target needs to be found. Find a new target if required.
◆ beam_ended()
void godot::Turret::beam_ended |
( |
| ) |
|
◆ create_beam()
void godot::Turret::create_beam |
( |
| ) |
|
◆ create_guiding_beam()
void godot::Turret::create_guiding_beam |
( |
| ) |
|
Create a non-damaging guiding beam.
◆ detect_node()
void godot::Turret::detect_node |
( |
Node3D * |
node | ) |
|
Become aware of a node in the awareness area.
◆ GDCLASS()
godot::Turret::GDCLASS |
( |
Turret |
, |
|
|
RigidBody3D |
|
|
) |
| |
|
private |
◆ get_attack_classes()
Array godot::Turret::get_attack_classes |
( |
| ) |
const |
Set the node classes to attack while invert_targets is false.
◆ get_beam_scene()
Ref< PackedScene > godot::Turret::get_beam_scene |
( |
| ) |
const |
Set the scene to spawn when firing.
◆ get_charge_time()
float godot::Turret::get_charge_time |
( |
| ) |
const |
The duration of the guiding lazer.
◆ get_fire_time()
float godot::Turret::get_fire_time |
( |
| ) |
const |
The duration of the damaging lazer.
◆ get_guiding_beam_scene()
Ref< PackedScene > godot::Turret::get_guiding_beam_scene |
( |
| ) |
const |
Set the scene to spawn when charging.
◆ get_lock_time()
float godot::Turret::get_lock_time |
( |
| ) |
const |
The delay between firing and charging the next shot.
◆ lead_target()
void godot::Turret::lead_target |
( |
double |
delta_time | ) |
|
Aim ahead of the current target.
◆ lose_node()
void godot::Turret::lose_node |
( |
Node3D * |
node | ) |
|
Lose track of a node exiting the awareness area.
◆ select_target()
Node3D * godot::Turret::select_target |
( |
| ) |
|
Select a target from the currently known nodes.
◆ set_attack_classes()
void godot::Turret::set_attack_classes |
( |
Array |
array | ) |
|
Set the node classes to attack while invert_targets is false.
◆ set_beam_scene()
void godot::Turret::set_beam_scene |
( |
Ref< PackedScene > |
scene | ) |
|
Set the scene to spawn when firing.
◆ set_charge_time()
void godot::Turret::set_charge_time |
( |
float |
val | ) |
|
The duration of the guiding lazer.
◆ set_fire_time()
void godot::Turret::set_fire_time |
( |
float |
val | ) |
|
The duration of the damaging lazer.
◆ set_guiding_beam_scene()
void godot::Turret::set_guiding_beam_scene |
( |
Ref< PackedScene > |
scene | ) |
|
Set the scene to spawn when charging.
◆ set_invert_targets()
void godot::Turret::set_invert_targets |
( |
bool |
value | ) |
|
Set to true to target everything but the attack_classes.
◆ set_lock_time()
void godot::Turret::set_lock_time |
( |
float |
val | ) |
|
The delay between firing and charging the next shot.
◆ try_next_state()
void godot::Turret::try_next_state |
( |
| ) |
|
Try transition to the next state if possible.
◆ aim_position
Vector3 godot::Turret::aim_position {0.f, 0.f, 0.f} |
|
private |
Position currently being aimed at.
◆ attack_classes
Vector<StringName> godot::Turret::attack_classes {} |
|
private |
Names of classes to attack.
◆ awareness
HashSet<Node3D*> godot::Turret::awareness {} |
|
private |
Set of all nodes the turret is currently aware of.
◆ beam_scene
Ref<PackedScene> godot::Turret::beam_scene {} |
|
private |
Scene to spawn when firing.
◆ charge_time
float godot::Turret::charge_time {1.f} |
|
private |
◆ current_target
Node3D* godot::Turret::current_target {nullptr} |
|
private |
◆ fire_time
float godot::Turret::fire_time {1.0f} |
|
private |
◆ guiding_beam_scene
Ref<PackedScene> godot::Turret::guiding_beam_scene {} |
|
private |
Scene to spawn when charging.
◆ gun_node
Node3D* godot::Turret::gun_node {nullptr} |
|
private |
The child node representing the gun.
◆ gun_node_offset
Vector3 godot::Turret::gun_node_offset {0.f, 0.f, 0.f} |
|
private |
Position offset of the gun.
◆ invert_attack_classes
bool godot::Turret::invert_attack_classes {false} |
|
private |
If true, target classes not in attack_classes.
◆ last_state_switch
float godot::Turret::last_state_switch {0.f} |
|
private |
Last time the state was changed.
◆ last_target_position
Vector3 godot::Turret::last_target_position {0.f, 0.f, 0.f} |
|
private |
Position of the current_target on the last frame.
◆ lead_distance
float godot::Turret::lead_distance {1.2f} |
|
private |
Distance ahead of target to aim.
◆ lock_time
float godot::Turret::lock_time {1.3f} |
|
private |
◆ state
Current state-machine state of the turret.
The documentation for this class was generated from the following files: