feature/clang-format #54
@ -11,7 +11,7 @@ namespace alai
|
|||||||
*
|
*
|
||||||
* @details The camera will be limited based on the used width and height of the Middleground tilemap.
|
* @details The camera will be limited based on the used width and height of the Middleground tilemap.
|
||||||
*/
|
*/
|
||||||
class CameraLimit: public godot::Node2D
|
class CameraLimit : public godot::Node2D
|
||||||
{
|
{
|
||||||
GODOT_CLASS(CameraLimit, godot::Node2D)
|
GODOT_CLASS(CameraLimit, godot::Node2D)
|
||||||
|
|
||||||
@ -49,5 +49,5 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _ready();
|
void _ready();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,6 @@ void alai::Event::_register_methods()
|
|||||||
godot::register_signal<Event>("player_died");
|
godot::register_signal<Event>("player_died");
|
||||||
godot::register_signal<Event>("player_won");
|
godot::register_signal<Event>("player_won");
|
||||||
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
|
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
alai::Event::Event()
|
alai::Event::Event()
|
||||||
|
@ -15,6 +15,7 @@ namespace alai
|
|||||||
class Event : public godot::Node
|
class Event : public godot::Node
|
||||||
{
|
{
|
||||||
GODOT_CLASS(Event, godot::Node)
|
GODOT_CLASS(Event, godot::Node)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief This method registers classes with Godot.
|
* @brief This method registers classes with Godot.
|
||||||
@ -42,6 +43,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _init();
|
void _init();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "Main.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "Main.h"
|
||||||
|
|
||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
|
|
||||||
@ -66,8 +65,7 @@ void alai::Main::_ready()
|
|||||||
{
|
{
|
||||||
_os->set_window_size(window_size);
|
_os->set_window_size(window_size);
|
||||||
_os->set_window_position(
|
_os->set_window_position(
|
||||||
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5
|
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
success = _project_settings->load_resource_pack("crt.pck");
|
success = _project_settings->load_resource_pack("crt.pck");
|
||||||
@ -153,7 +151,7 @@ bool alai::Main::get_full_screen()
|
|||||||
|
|
||||||
void alai::Main::set_window_size(godot::Vector2 window_size)
|
void alai::Main::set_window_size(godot::Vector2 window_size)
|
||||||
{
|
{
|
||||||
this-> window_size = window_size;
|
this->window_size = window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
godot::Vector2 alai::Main::get_window_size()
|
godot::Vector2 alai::Main::get_window_size()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef ALAI_MAIN_H
|
#ifndef ALAI_MAIN_H
|
||||||
#define ALAI_MAIN_H
|
#define ALAI_MAIN_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <Node.hpp>
|
#include <Node.hpp>
|
||||||
@ -10,6 +9,7 @@
|
|||||||
#include <ProjectSettings.hpp>
|
#include <ProjectSettings.hpp>
|
||||||
#include <Ref.hpp>
|
#include <Ref.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the alai namespace for all the code included in the game.
|
* @brief This is the alai namespace for all the code included in the game.
|
||||||
@ -227,6 +227,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void load_level();
|
void load_level();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
#include "Event.h"
|
||||||
#include "coin/CoinCollected.h"
|
#include "coin/CoinCollected.h"
|
||||||
|
|
||||||
#include "Event.h"
|
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
|
||||||
#include <AnimationPlayer.hpp>
|
#include <AnimationPlayer.hpp>
|
||||||
|
#include <AudioStreamPlayer.hpp>
|
||||||
|
|
||||||
void alai::CoinCollected::_register_methods()
|
void alai::CoinCollected::_register_methods()
|
||||||
{
|
{
|
||||||
|
@ -68,6 +68,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _on_animation_finished(godot::String anim_name);
|
void _on_animation_finished(godot::String anim_name);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "coin/CoinCounter.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "coin/CoinCounter.h"
|
||||||
|
|
||||||
#include <String.hpp>
|
#include <String.hpp>
|
||||||
|
|
||||||
@ -43,7 +42,8 @@ void alai::CoinCounter::_on_coin_collected(int amount)
|
|||||||
{
|
{
|
||||||
coin_string = "0" + godot::String::num(coins);
|
coin_string = "0" + godot::String::num(coins);
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
coin_string = godot::String::num(coins);
|
coin_string = godot::String::num(coins);
|
||||||
}
|
}
|
||||||
set_text(coin_string);
|
set_text(coin_string);
|
||||||
|
@ -52,9 +52,8 @@ namespace alai
|
|||||||
void _on_CoinHUD_ready();
|
void _on_CoinHUD_ready();
|
||||||
void _on_coin_collected(int amount);
|
void _on_coin_collected(int amount);
|
||||||
void _ready();
|
void _ready();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,6 +69,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _on_body_entered(Node *node);
|
void _on_body_entered(Node *node);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,6 +69,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _on_Goal_body_entered(Node *node);
|
void _on_Goal_body_entered(Node *node);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "goal/GoalReached.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "goal/GoalReached.h"
|
||||||
|
|
||||||
#include <Area2D.hpp>
|
#include <Area2D.hpp>
|
||||||
|
|
||||||
|
@ -67,6 +67,6 @@ namespace alai
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include <Godot.hpp>
|
|
||||||
|
|
||||||
#include "Event.h"
|
|
||||||
#include "state_machine/StateMachine.h"
|
|
||||||
#include "state_machine/State.h"
|
|
||||||
#include "Main.h"
|
|
||||||
#include "CameraLimit.h"
|
#include "CameraLimit.h"
|
||||||
#include "player/Player.h"
|
#include "Event.h"
|
||||||
#include "player/states/PlayerIdle.h"
|
#include "Main.h"
|
||||||
#include "player/states/PlayerMove.h"
|
|
||||||
#include "player/states/PlayerJump.h"
|
|
||||||
#include "player/states/PlayerFall.h"
|
|
||||||
#include "coin/CoinNotCollected.h"
|
|
||||||
#include "coin/CoinCollected.h"
|
#include "coin/CoinCollected.h"
|
||||||
#include "coin/CoinCounter.h"
|
#include "coin/CoinCounter.h"
|
||||||
#include "goal/GoalReached.h"
|
#include "coin/CoinNotCollected.h"
|
||||||
#include "goal/GoalNotReached.h"
|
#include "goal/GoalNotReached.h"
|
||||||
|
#include "goal/GoalReached.h"
|
||||||
#include "gui/game_over/GameOverScreen.h"
|
#include "gui/game_over/GameOverScreen.h"
|
||||||
#include "gui/game_won/GameWonScreen.h"
|
#include "gui/game_won/GameWonScreen.h"
|
||||||
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerFall.h"
|
||||||
|
#include "player/states/PlayerIdle.h"
|
||||||
|
#include "player/states/PlayerJump.h"
|
||||||
|
#include "player/states/PlayerMove.h"
|
||||||
|
#include "state_machine/State.h"
|
||||||
|
#include "state_machine/StateMachine.h"
|
||||||
|
|
||||||
|
#include <Godot.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function connects the gdnative init function.
|
* @brief This function connects the gdnative init function.
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "gui/game_over/GameOverScreen.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "gui/game_over/GameOverScreen.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <PackedScene.hpp>
|
#include <PackedScene.hpp>
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace alai
|
namespace alai
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -57,6 +56,6 @@ namespace alai
|
|||||||
void connect_signal();
|
void connect_signal();
|
||||||
void _on_visibility_changed();
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "gui/game_won/GameWonScreen.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "gui/game_won/GameWonScreen.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
|
@ -47,6 +47,6 @@ namespace alai
|
|||||||
void connect_signal();
|
void connect_signal();
|
||||||
void _on_visibility_changed();
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "player/Player.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "player/Player.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <Camera2D.hpp>
|
#include <Camera2D.hpp>
|
||||||
@ -83,7 +82,8 @@ void alai::player::Player::_ready()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void alai::player::Player::_on_level_loaded() {
|
void alai::player::Player::_on_level_loaded()
|
||||||
|
{
|
||||||
auto state = get_node("StateMachine")->get_child(0);
|
auto state = get_node("StateMachine")->get_child(0);
|
||||||
if (state != nullptr)
|
if (state != nullptr)
|
||||||
{
|
{
|
||||||
@ -176,7 +176,8 @@ void alai::player::Player::_physics_process(float delta)
|
|||||||
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2) - sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().x);
|
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2) - sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().x);
|
||||||
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3) + sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().y);
|
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3) + sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().y);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
WARN_PRINT("Could not clamp player based on sprite frame size!");
|
WARN_PRINT("Could not clamp player based on sprite frame size!");
|
||||||
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2));
|
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2));
|
||||||
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
||||||
@ -196,11 +197,13 @@ void alai::player::Player::_physics_process(float delta)
|
|||||||
{
|
{
|
||||||
// The first time the notifier is checked always returns false in the first frame
|
// The first time the notifier is checked always returns false in the first frame
|
||||||
// So skip the check from the first frame
|
// So skip the check from the first frame
|
||||||
if (notifier_initialized) {
|
if (notifier_initialized)
|
||||||
|
{
|
||||||
auto event = get_node<alai::Event>("/root/Event");
|
auto event = get_node<alai::Event>("/root/Event");
|
||||||
event->emit_signal("player_died");
|
event->emit_signal("player_died");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
notifier_initialized = true;
|
notifier_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _on_level_loaded();
|
void _on_level_loaded();
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "player/states/PlayerFall.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerFall.h"
|
||||||
|
|
||||||
void alai::player::PlayerFall::_register_methods()
|
void alai::player::PlayerFall::_register_methods()
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "player/states/PlayerIdle.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerIdle.h"
|
||||||
|
|
||||||
void alai::player::PlayerIdle::_register_methods()
|
void alai::player::PlayerIdle::_register_methods()
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "player/states/PlayerJump.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerJump.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "player/states/PlayerMove.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerMove.h"
|
||||||
|
|
||||||
void alai::player::PlayerMove::_register_methods()
|
void alai::player::PlayerMove::_register_methods()
|
||||||
{
|
{
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "state_machine/State.h"
|
#include "state_machine/State.h"
|
||||||
|
|
||||||
|
#include <AnimatedSprite.hpp>
|
||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <AnimatedSprite.hpp>
|
|
||||||
|
|
||||||
namespace alai
|
namespace alai
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,6 +98,6 @@ namespace alai
|
|||||||
*/
|
*/
|
||||||
virtual StateMachine *get_state_machine() final;
|
virtual StateMachine *get_state_machine() final;
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "state_machine/StateMachine.h"
|
|
||||||
|
|
||||||
#include "state_machine/State.h"
|
#include "state_machine/State.h"
|
||||||
|
#include "state_machine/StateMachine.h"
|
||||||
|
|
||||||
void alai::StateMachine::_register_methods()
|
void alai::StateMachine::_register_methods()
|
||||||
{
|
{
|
||||||
@ -54,7 +53,7 @@ void alai::StateMachine::setup()
|
|||||||
if (children.size() > 0)
|
if (children.size() > 0)
|
||||||
{
|
{
|
||||||
WARN_PRINT("The state machine doesn't have a default state set, using first child!");
|
WARN_PRINT("The state machine doesn't have a default state set, using first child!");
|
||||||
auto child = Object::cast_to<Node>(children[0].operator Object*());
|
auto child = Object::cast_to<Node>(children[0].operator Object * ());
|
||||||
set_current_state(child->get_name());
|
set_current_state(child->get_name());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -66,7 +65,7 @@ void alai::StateMachine::setup()
|
|||||||
|
|
||||||
for (uint8_t i = 0; i < children.size(); i++)
|
for (uint8_t i = 0; i < children.size(); i++)
|
||||||
{
|
{
|
||||||
auto child = Object::cast_to<Node>(children[i].operator Object*());
|
auto child = Object::cast_to<Node>(children[i].operator Object * ());
|
||||||
|
|
||||||
child->call("set_state_machine", this);
|
child->call("set_state_machine", this);
|
||||||
|
|
||||||
@ -83,7 +82,8 @@ void alai::StateMachine::setup()
|
|||||||
{
|
{
|
||||||
this->call("_state_enter", get_current_state());
|
this->call("_state_enter", get_current_state());
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
|
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ void alai::StateMachine::add_states()
|
|||||||
auto children = get_children();
|
auto children = get_children();
|
||||||
for (uint8_t i = 0; i < children.size(); i++)
|
for (uint8_t i = 0; i < children.size(); i++)
|
||||||
{
|
{
|
||||||
auto child = Object::cast_to<Node>(children[i].operator Object*());
|
auto child = Object::cast_to<Node>(children[i].operator Object * ());
|
||||||
add_state(child->get_name(), child);
|
add_state(child->get_name(), child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ bool alai::StateMachine::has(const godot::String state)
|
|||||||
return states.has(state);
|
return states.has(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void alai::StateMachine::restart(const godot::String state, const godot::Array& args)
|
void alai::StateMachine::restart(const godot::String state, const godot::Array &args)
|
||||||
{
|
{
|
||||||
this->call("_state_exit", state, args);
|
this->call("_state_exit", state, args);
|
||||||
this->call("_state_enter", state, args);
|
this->call("_state_enter", state, args);
|
||||||
@ -162,7 +162,7 @@ void alai::StateMachine::change(const godot::String state, const godot::Array &a
|
|||||||
|
|
||||||
if (get_current_state() != "")
|
if (get_current_state() != "")
|
||||||
{
|
{
|
||||||
auto child = Object::cast_to<Node>(states[get_current_state()].operator Object*());
|
auto child = Object::cast_to<Node>(states[get_current_state()].operator Object * ());
|
||||||
if (child != nullptr)
|
if (child != nullptr)
|
||||||
{
|
{
|
||||||
this->remove_child(child);
|
this->remove_child(child);
|
||||||
@ -175,7 +175,7 @@ void alai::StateMachine::change(const godot::String state, const godot::Array &a
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_current_state(state);
|
set_current_state(state);
|
||||||
auto child = Object::cast_to<Node>(states[get_current_state()].operator Object*());
|
auto child = Object::cast_to<Node>(states[get_current_state()].operator Object * ());
|
||||||
this->add_child(child);
|
this->add_child(child);
|
||||||
|
|
||||||
state_node = Object::cast_to<Node>(this->states[get_current_state()]);
|
state_node = Object::cast_to<Node>(this->states[get_current_state()]);
|
||||||
@ -204,7 +204,7 @@ void alai::StateMachine::change(const godot::String state, const godot::Array &a
|
|||||||
|
|
||||||
godot::Variant alai::StateMachine::call(const godot::String method, const godot::Array &args)
|
godot::Variant alai::StateMachine::call(const godot::String method, const godot::Array &args)
|
||||||
{
|
{
|
||||||
auto node = Object::cast_to<Node>(states[get_current_state()].operator Object*());
|
auto node = Object::cast_to<Node>(states[get_current_state()].operator Object * ());
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
if (node->has_method(method))
|
if (node->has_method(method))
|
||||||
@ -269,7 +269,7 @@ void alai::StateMachine::_on_StateMachine_tree_exiting()
|
|||||||
auto keys = states.keys();
|
auto keys = states.keys();
|
||||||
for (uint8_t i = 0; i < keys.size(); i++)
|
for (uint8_t i = 0; i < keys.size(); i++)
|
||||||
{
|
{
|
||||||
auto child = Object::cast_to<Node>(states[keys[i]].operator Object*());
|
auto child = Object::cast_to<Node>(states[keys[i]].operator Object * ());
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
auto children = get_children();
|
auto children = get_children();
|
||||||
|
@ -126,7 +126,7 @@ namespace alai
|
|||||||
* @param[in] state The state that is being restarted.
|
* @param[in] state The state that is being restarted.
|
||||||
* @param[in] args The arguments to pass to the state on exit and enter.
|
* @param[in] args The arguments to pass to the state on exit and enter.
|
||||||
*/
|
*/
|
||||||
void restart(const godot::String state, const godot::Array& args = godot::Array());
|
void restart(const godot::String state, const godot::Array &args = godot::Array());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Change to a different state.
|
* @brief Change to a different state.
|
||||||
@ -214,7 +214,7 @@ namespace alai
|
|||||||
* @param[in] state The state being restarted.
|
* @param[in] state The state being restarted.
|
||||||
* @param[in] args The arguments to pass when restarting.
|
* @param[in] args The arguments to pass when restarting.
|
||||||
*/
|
*/
|
||||||
template <class ...Args> void restart(const godot::String state, Args ...args)
|
template<class... Args> void restart(const godot::String state, Args... args)
|
||||||
{
|
{
|
||||||
return restart(state, godot::Array::make(args...));
|
return restart(state, godot::Array::make(args...));
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ namespace alai
|
|||||||
* @param[in] state The state to change to.
|
* @param[in] state The state to change to.
|
||||||
* @param[in] args The arguments to pass to the new state.
|
* @param[in] args The arguments to pass to the new state.
|
||||||
*/
|
*/
|
||||||
template <class ...Args> void change(const godot::String state, Args ...args)
|
template<class... Args> void change(const godot::String state, Args... args)
|
||||||
{
|
{
|
||||||
return change(state, godot::Array::make(args...));
|
return change(state, godot::Array::make(args...));
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ namespace alai
|
|||||||
* @param[in] args The arguments to pass to it.
|
* @param[in] args The arguments to pass to it.
|
||||||
* @return Variant The Variant object returned by the method called.
|
* @return Variant The Variant object returned by the method called.
|
||||||
*/
|
*/
|
||||||
template <class ...Args> godot::Variant call(const godot::String method, Args ...args)
|
template<class... Args> godot::Variant call(const godot::String method, Args... args)
|
||||||
{
|
{
|
||||||
return call(method, godot::Array::make(args...));
|
return call(method, godot::Array::make(args...));
|
||||||
}
|
}
|
||||||
@ -252,11 +252,11 @@ namespace alai
|
|||||||
* @param[in] args The arguments to pass.
|
* @param[in] args The arguments to pass.
|
||||||
* @return Variant The Variant object returned by the method called.
|
* @return Variant The Variant object returned by the method called.
|
||||||
*/
|
*/
|
||||||
template <class ...Args> godot::Variant _call(const godot::String method, Args ...args)
|
template<class... Args> godot::Variant _call(const godot::String method, Args... args)
|
||||||
{
|
{
|
||||||
return _call(method, godot::Array::make(args...));
|
return _call(method, godot::Array::make(args...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user