feat: added section activators for optimization
parent
37afae2071
commit
8daa709aa7
|
@ -12,6 +12,7 @@
|
||||||
#include "camera_effects.hpp"
|
#include "camera_effects.hpp"
|
||||||
#include "camera_effect_source.hpp"
|
#include "camera_effect_source.hpp"
|
||||||
#include "artillery_target.hpp"
|
#include "artillery_target.hpp"
|
||||||
|
#include "section_activator.hpp"
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level)
|
||||||
GDREGISTER_CLASS(CameraEffects);
|
GDREGISTER_CLASS(CameraEffects);
|
||||||
GDREGISTER_RUNTIME_CLASS(CameraEffectSource);
|
GDREGISTER_RUNTIME_CLASS(CameraEffectSource);
|
||||||
GDREGISTER_RUNTIME_CLASS(ArtilleryTarget);
|
GDREGISTER_RUNTIME_CLASS(ArtilleryTarget);
|
||||||
|
GDREGISTER_RUNTIME_CLASS(SectionActivator);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include "section_activator.hpp"
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
|
void SectionActivator::_bind_methods() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionActivator::_enter_tree() {
|
||||||
|
this->connect("body_entered", callable_mp(this, &SectionActivator::_on_body_entered));
|
||||||
|
this->connect("body_exited", callable_mp(this, &SectionActivator::_on_body_exited));
|
||||||
|
this->set_visible(false);
|
||||||
|
this->set_process(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionActivator::_on_body_entered(gd::Node *node) {
|
||||||
|
if(gd::Object::cast_to<Player>(node)) {
|
||||||
|
this->set_visible(true);
|
||||||
|
this->set_process(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SectionActivator::_on_body_exited(gd::Node *node) {
|
||||||
|
if(gd::Object::cast_to<Player>(node)) {
|
||||||
|
this->set_visible(false);
|
||||||
|
this->set_process(false);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef SECTION_ACTIVATOR_HPP
|
||||||
|
#define SECTION_ACTIVATOR_HPP
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/area3d.hpp>
|
||||||
|
namespace gd = godot;
|
||||||
|
|
||||||
|
class SectionActivator : public gd::Area3D {
|
||||||
|
GDCLASS(SectionActivator, gd::Area3D);
|
||||||
|
static void _bind_methods();
|
||||||
|
public:
|
||||||
|
virtual void _enter_tree() override;
|
||||||
|
void _on_body_entered(gd::Node *node);
|
||||||
|
void _on_body_exited(gd::Node *node);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !SECTION_ACTIVATOR_HPP
|
Loading…
Reference in New Issue