feat: added minimum distance from player to artillery targets
parent
2ebbe66dd1
commit
4928f8663c
|
@ -1,4 +1,5 @@
|
|||
#include "artillery_target.hpp"
|
||||
#include "player.hpp"
|
||||
#include "utils/godot_macros.hpp"
|
||||
#include <godot_cpp/variant/utility_functions.hpp>
|
||||
|
||||
|
@ -51,6 +52,9 @@ float ArtilleryTarget::get_frequency_max() const {
|
|||
|
||||
void ArtilleryTarget::timer_end() {
|
||||
this->start_timer();
|
||||
gd::Vector3 const player_position{Player::get_player_instance()->get_global_position()};
|
||||
if(player_position.distance_squared_to(this->get_global_position()) >= this->ACTIVATION_RANGE * this->ACTIVATION_RANGE)
|
||||
return; // only spawn explosions if in range
|
||||
gd::Node *instance{this->effect->instantiate()};
|
||||
this->add_child(instance);
|
||||
if(gd::Node3D *inst3d{gd::Object::cast_to<gd::Node3D>(instance)}) {
|
||||
|
|
|
@ -23,6 +23,7 @@ private:
|
|||
void timer_end();
|
||||
void start_timer();
|
||||
private:
|
||||
float const ACTIVATION_RANGE{20.f};
|
||||
float spread{5.f};
|
||||
float frequency_min{0.5f};
|
||||
float frequency_max{2.f};
|
||||
|
|
Loading…
Reference in New Issue