Compare commits
No commits in common. "1dd1d3b961f12a22296eb1bd43c6bb40e15cabec" and "c85947f187caf5a414db4a2074fb94514b25362b" have entirely different histories.
1dd1d3b961
...
c85947f187
|
@ -138,14 +138,6 @@ void GameRoot::set_game_mode(Ref<GameMode> prototype) {
|
||||||
} while(new_player_id != 0);
|
} while(new_player_id != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<GameMode> GameRoot::get_game_mode() const {
|
|
||||||
return this->game_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ref<GameState> GameRoot::get_game_state() const {
|
|
||||||
return this->game_mode->get_game_state();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPlayer *GameRoot::spawn_player(uint32_t id) {
|
IPlayer *GameRoot::spawn_player(uint32_t id) {
|
||||||
UtilityFunctions::push_error("GameRoot::spawn_player not implemented");
|
UtilityFunctions::push_error("GameRoot::spawn_player not implemented");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -210,7 +202,7 @@ void GameRoot3D::set_first_boot_level(Ref<PackedScene> level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringName const root_type = level->get_state()->get_node_type(0);
|
StringName const root_type = level->get_state()->get_node_type(0);
|
||||||
if(!ClassDB::is_parent_class(root_type, "Level3D")) {
|
if(!ClassDB::is_parent_class("Level3D", root_type)) {
|
||||||
UtilityFunctions::push_error("First boot level cannot be of type '", root_type, "'. First boot level has to inherit from Level3D");
|
UtilityFunctions::push_error("First boot level cannot be of type '", root_type, "'. First boot level has to inherit from Level3D");
|
||||||
this->first_boot_level.unref();
|
this->first_boot_level.unref();
|
||||||
return;
|
return;
|
||||||
|
@ -247,7 +239,7 @@ bool GameRoot3D::is_valid_level(Ref<PackedScene> &level) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
StringName const root_type = level->get_state()->get_node_type(0);
|
StringName const root_type = level->get_state()->get_node_type(0);
|
||||||
if(!ClassDB::is_parent_class(root_type, "Level3D")) {
|
if(!ClassDB::is_parent_class("Level3D", root_type)) {
|
||||||
UtilityFunctions::push_error("Can't load level with root type '", root_type, "'. Root node has to be of type Level3D");
|
UtilityFunctions::push_error("Can't load level with root type '", root_type, "'. Root node has to be of type Level3D");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,6 @@ public:
|
||||||
// override the current gamemode
|
// override the current gamemode
|
||||||
// force-respawns all players
|
// force-respawns all players
|
||||||
void set_game_mode(Ref<GameMode> prototype);
|
void set_game_mode(Ref<GameMode> prototype);
|
||||||
Ref<GameMode> get_game_mode() const;
|
|
||||||
Ref<GameState> get_game_state() const;
|
|
||||||
protected:
|
protected:
|
||||||
// attempt to make 'this' the current singleton instance
|
// attempt to make 'this' the current singleton instance
|
||||||
void grab_singleton();
|
void grab_singleton();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "player_input.hpp"
|
#include "player_input.hpp"
|
||||||
#include "godot_cpp/variant/utility_functions.hpp"
|
|
||||||
#include "godot_macros.h"
|
#include "godot_macros.h"
|
||||||
#include "godot_cpp/classes/input.hpp"
|
#include "godot_cpp/classes/input.hpp"
|
||||||
#include "godot_cpp/classes/input_event.hpp"
|
#include "godot_cpp/classes/input_event.hpp"
|
||||||
|
@ -21,7 +20,7 @@ PlayerInput::Listener::Listener(String positive, String negative, Node *object,
|
||||||
, isMouseEvent{positive.begins_with("_mouse_") || negative.begins_with("_mouse_")} {}
|
, isMouseEvent{positive.begins_with("_mouse_") || negative.begins_with("_mouse_")} {}
|
||||||
|
|
||||||
PlayerInput::Listener::Listener(String action, Node *object, String method)
|
PlayerInput::Listener::Listener(String action, Node *object, String method)
|
||||||
: PlayerInput::Listener::Listener(action, String(), object, method) {}
|
: PlayerInput::Listener::Listener(action, "", object, method) {}
|
||||||
|
|
||||||
std::optional<float> PlayerInput::Listener::evaluate_action(String const &action) {
|
std::optional<float> PlayerInput::Listener::evaluate_action(String const &action) {
|
||||||
Input *input = Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
|
@ -35,8 +34,9 @@ std::optional<float> PlayerInput::Listener::evaluate_action(String const &action
|
||||||
return vector.x > 0.f ? vector.x : 0.f;
|
return vector.x > 0.f ? vector.x : 0.f;
|
||||||
else if(action.ends_with("_left"))
|
else if(action.ends_with("_left"))
|
||||||
return vector.x < 0.f ? -vector.x : 0.f;
|
return vector.x < 0.f ? -vector.x : 0.f;
|
||||||
}
|
else
|
||||||
if(action.is_empty()) {
|
return std::nullopt;
|
||||||
|
} else if(action.is_empty()) {
|
||||||
return 0.f;
|
return 0.f;
|
||||||
} else {
|
} else {
|
||||||
return float(input->is_action_pressed(action));
|
return float(input->is_action_pressed(action));
|
||||||
|
@ -44,10 +44,12 @@ std::optional<float> PlayerInput::Listener::evaluate_action(String const &action
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerInput::Listener::has_changed(Ref<InputEvent> const &event) {
|
bool PlayerInput::Listener::has_changed(Ref<InputEvent> const &event) {
|
||||||
bool const mouse_changed{this->isMouseEvent && event->is_class("InputEventMouseMotion")};
|
return (
|
||||||
bool const negative_changed{!this->actionNegative.is_empty() && event->is_action(this->actionNegative)};
|
(!event->is_class("InputEventMouseMotion") ||
|
||||||
bool const positive_changed{!this->actionPositive.is_empty() && event->is_action(this->actionPositive)};
|
this->isMouseEvent) ||
|
||||||
return mouse_changed || negative_changed || positive_changed;
|
event->is_action(this->actionNegative) ||
|
||||||
|
event->is_action(this->actionPositive)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
float PlayerInput::Listener::evaluate(Ref<InputEvent> const &event) {
|
float PlayerInput::Listener::evaluate(Ref<InputEvent> const &event) {
|
||||||
|
@ -100,7 +102,6 @@ void PlayerInput::_unhandled_input(Ref<InputEvent> const &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerInput::_process(double deltaTime) {
|
void PlayerInput::_process(double deltaTime) {
|
||||||
if(this->isPrimary)
|
|
||||||
PlayerInput::lastMouseMotion = {0.f, 0.f};
|
PlayerInput::lastMouseMotion = {0.f, 0.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue