Merge remote-tracking branch 'origin' into temp
commit
b1d5e5d263
|
@ -36,20 +36,20 @@ bool GameRoot3D::has_singleton() {
|
||||||
return GameRoot3D::singleton_instance != nullptr;
|
return GameRoot3D::singleton_instance != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRoot3D::_enter_tree() { GDGAMEONLY();
|
void GameRoot3D::_enter_tree() {
|
||||||
// TODO: Replace this with detecting input devices
|
// TODO: Replace this with detecting input devices
|
||||||
this->player_input_connected();
|
this->player_input_connected();
|
||||||
this->grab_singleton();
|
this->grab_singleton();
|
||||||
this->rng = godot::Ref<godot::RandomNumberGenerator>(memnew(godot::RandomNumberGenerator));
|
this->rng = godot::Ref<godot::RandomNumberGenerator>(memnew(godot::RandomNumberGenerator));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRoot3D::_ready() { GDGAMEONLY();
|
void GameRoot3D::_ready() {
|
||||||
this->load_level(this->first_boot_level);
|
this->load_level(this->first_boot_level);
|
||||||
// TODO: try load save data from file.
|
// TODO: try load save data from file.
|
||||||
this->game_state = this->game_state_prototype->duplicate(true);
|
this->game_state = this->game_state_prototype->duplicate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRoot3D::_exit_tree() { GDGAMEONLY();
|
void GameRoot3D::_exit_tree() {
|
||||||
this->release_singleton();
|
this->release_singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,28 +37,28 @@
|
||||||
|
|
||||||
/*! \def GDFUNCTION(FnName_)
|
/*! \def GDFUNCTION(FnName_)
|
||||||
* \brief Register a function CLASSNAME::FnName_() to godot.
|
* \brief Register a function CLASSNAME::FnName_() to godot.
|
||||||
*
|
*
|
||||||
* Requires setting CLASSNAME as a #define first.
|
* Requires setting CLASSNAME as a #define first.
|
||||||
*/
|
*/
|
||||||
#define GDFUNCTION(FnName_) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_), &CLASSNAME::FnName_)
|
#define GDFUNCTION(FnName_) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_), &CLASSNAME::FnName_)
|
||||||
|
|
||||||
/*! \def GDFUNCTION_ARGS(FnName_, ...)
|
/*! \def GDFUNCTION_ARGS(FnName_, ...)
|
||||||
* \brief Register a function CLASSNAME::FnName_(...) to godot.
|
* \brief Register a function CLASSNAME::FnName_(...) to godot.
|
||||||
*
|
*
|
||||||
* Requires setting CLASSNAME as a #define first.
|
* Requires setting CLASSNAME as a #define first.
|
||||||
*/
|
*/
|
||||||
#define GDFUNCTION_ARGS(FnName_, ...) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_)
|
#define GDFUNCTION_ARGS(FnName_, ...) godot::ClassDB::bind_method(godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_)
|
||||||
|
|
||||||
/*! \def GDFUNCTION_STATIC(FnName_)
|
/*! \def GDFUNCTION_STATIC(FnName_)
|
||||||
* \brief Register a static member function CLASSNAME::FnName_() to godot.
|
* \brief Register a static member function CLASSNAME::FnName_() to godot.
|
||||||
*
|
*
|
||||||
* Requires setting CLASSNAME as a #define first.
|
* Requires setting CLASSNAME as a #define first.
|
||||||
*/
|
*/
|
||||||
#define GDFUNCTION_STATIC(FnName_) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_), &CLASSNAME::_FnName)
|
#define GDFUNCTION_STATIC(FnName_) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_), &CLASSNAME::_FnName)
|
||||||
|
|
||||||
/*! \def GDFUNCTION_STATIC_ARGS(FnName_, ...)
|
/*! \def GDFUNCTION_STATIC_ARGS(FnName_, ...)
|
||||||
* \brief Register a static member function CLASSNAME::FnName_(...) to godot.
|
* \brief Register a static member function CLASSNAME::FnName_(...) to godot.
|
||||||
*
|
*
|
||||||
* Requires setting CLASSNAME as a #define first.
|
* Requires setting CLASSNAME as a #define first.
|
||||||
*/
|
*/
|
||||||
#define GDFUNCTION_STATIC_ARGS(FnName_, ...) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_)
|
#define GDFUNCTION_STATIC_ARGS(FnName_, ...) godot::ClassDB::bind_static_method(MACRO_STRING(CLASSNAME), godot::D_METHOD(#FnName_, __VA_ARGS__), &CLASSNAME::FnName_)
|
||||||
|
@ -77,19 +77,6 @@
|
||||||
#define GDNODETYPE(Class_) godot::vformat("%s/%s:%s", godot::Variant::OBJECT, godot::PROPERTY_HINT_NODE_TYPE, Class_)
|
#define GDNODETYPE(Class_) godot::vformat("%s/%s:%s", godot::Variant::OBJECT, godot::PROPERTY_HINT_NODE_TYPE, Class_)
|
||||||
#define GDENUMTYPE(EnumString_) godot::vformat("%s/%s:%s", godot::Variant::INT, godot::PROPERTY_HINT_ENUM, EnumString_)
|
#define GDENUMTYPE(EnumString_) godot::vformat("%s/%s:%s", godot::Variant::INT, godot::PROPERTY_HINT_ENUM, EnumString_)
|
||||||
|
|
||||||
/*! \def GDEDITORONLY()
|
|
||||||
* \brief Execute the rest of the function only if currently running as editor.
|
|
||||||
*
|
|
||||||
* Useful for _ready, _enter/_exit, _process, etc. functions.
|
|
||||||
*/
|
|
||||||
#define GDEDITORONLY() if(!godot::Engine::get_singleton()->is_editor_hint()) return;
|
|
||||||
/*! \def GDGAMEONLY()
|
|
||||||
* \brief Execute the rest of the function only if currently running as game.
|
|
||||||
*
|
|
||||||
* Useful for _ready, _enter/_exit, _process, etc. functions.
|
|
||||||
*/
|
|
||||||
#define GDGAMEONLY() if(godot::Engine::get_singleton()->is_editor_hint()) return;
|
|
||||||
|
|
||||||
/*! \def GDENUM(Name_, ...)
|
/*! \def GDENUM(Name_, ...)
|
||||||
* \brief Declare a scoped enum struct.
|
* \brief Declare a scoped enum struct.
|
||||||
*
|
*
|
||||||
|
|
|
@ -74,21 +74,21 @@ gd::Vector2 PlayerInput::get_last_mouse_motion() {
|
||||||
return PlayerInput::lastMouseMotion;
|
return PlayerInput::lastMouseMotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerInput::_enter_tree() { GDGAMEONLY();
|
void PlayerInput::_enter_tree() {
|
||||||
if(!PlayerInput::primaryExists) {
|
if(!PlayerInput::primaryExists) {
|
||||||
this->isPrimary = true;
|
this->isPrimary = true;
|
||||||
PlayerInput::primaryExists = true;
|
PlayerInput::primaryExists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerInput::_exit_tree() { GDGAMEONLY();
|
void PlayerInput::_exit_tree() {
|
||||||
if(this->isPrimary) {
|
if(this->isPrimary) {
|
||||||
this->isPrimary = false;
|
this->isPrimary = false;
|
||||||
PlayerInput::primaryExists = false;
|
PlayerInput::primaryExists = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerInput::_unhandled_input(gd::Ref<gd::InputEvent> const &event) { GDGAMEONLY();
|
void PlayerInput::_unhandled_input(gd::Ref<gd::InputEvent> const &event) {
|
||||||
if(this->isPrimary && event->is_class("InputEventMouseMotion"))
|
if(this->isPrimary && event->is_class("InputEventMouseMotion"))
|
||||||
PlayerInput::lastMouseMotion = gd::Object::cast_to<gd::InputEventMouseMotion>(*event)->get_relative();
|
PlayerInput::lastMouseMotion = gd::Object::cast_to<gd::InputEventMouseMotion>(*event)->get_relative();
|
||||||
for(Listener& listener: this->listeners) {
|
for(Listener& listener: this->listeners) {
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
void godot_cpp_utils_register_types() {
|
void godot_cpp_utils_register_types() {
|
||||||
GDREGISTER_CLASS(utils::GameMode);
|
GDREGISTER_RUNTIME_CLASS(utils::GameMode);
|
||||||
GDREGISTER_CLASS(utils::GameRoot3D);
|
GDREGISTER_RUNTIME_CLASS(utils::GameRoot3D);
|
||||||
GDREGISTER_CLASS(utils::GameState);
|
GDREGISTER_CLASS(utils::GameState);
|
||||||
GDREGISTER_CLASS(utils::Level3D);
|
GDREGISTER_RUNTIME_CLASS(utils::Level3D);
|
||||||
GDREGISTER_CLASS(utils::PlayerInput);
|
GDREGISTER_RUNTIME_CLASS(utils::PlayerInput);
|
||||||
GDREGISTER_CLASS(utils::SpawnPoint3D);
|
GDREGISTER_RUNTIME_CLASS(utils::SpawnPoint3D);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue