cleanup code

This commit is contained in:
2022-08-28 01:08:04 -04:00
parent 3c8107ba9f
commit 39173cef21
18 changed files with 393 additions and 451 deletions

View File

@@ -1,55 +1,46 @@
#include "goal/GoalNotReached.h"
#include <Area2D.hpp>
using namespace godot;
void GoalNotReached::_register_methods()
void alai::GoalNotReached::_register_methods()
{
register_method("_state_enter", &GoalNotReached::_state_enter);
register_method("_state_exit", &GoalNotReached::_state_exit);
register_method("_on_Goal_body_entered", &GoalNotReached::_on_Goal_body_entered);
}
GoalNotReached::GoalNotReached()
alai::GoalNotReached::GoalNotReached()
{
}
GoalNotReached::~GoalNotReached()
alai::GoalNotReached::~GoalNotReached()
{
}
void GoalNotReached::_init()
void alai::GoalNotReached::_init()
{
}
void GoalNotReached::_state_enter()
void alai::GoalNotReached::_state_enter()
{
animated_sprite = get_parent()->get_node<AnimatedSprite>("AnimatedSprite");
animated_sprite = get_parent()->get_node<godot::AnimatedSprite>("AnimatedSprite");
animated_sprite->set_animation("flagmove");
animated_sprite->play();
}
void GoalNotReached::_state_exit()
void alai::GoalNotReached::_state_exit()
{
}
void GoalNotReached::_on_Goal_body_entered(Node *node)
void alai::GoalNotReached::_on_Goal_body_entered(Node *node)
{
auto parent_node = get_parent();
if (parent_node != nullptr)
{
auto goal = Object::cast_to<Area2D>(parent_node);
auto goal = Object::cast_to<godot::Area2D>(parent_node);
goal->set_collision_mask_bit(0, false);
}
get_state_machine()->change("GoalReached");
}

View File

@@ -1,76 +1,74 @@
#ifndef ALAI_GOAL_NOT_REACHED
#define ALAI_GOAL_NOT_REACHED
#ifndef ALAI_GOAL_GOAL_NOT_REACHED_H
#define ALAI_GOAL_GOAL_NOT_REACHED_H
#include "state_machine/State.h"
#include <Godot.hpp>
#include <Node.hpp>
#include <AnimatedSprite.hpp>
#include <Godot.hpp>
namespace godot
namespace alai
{
/**
* @brief This class controls what happens when the Coin is in the not collected state.
*
*/
class GoalNotReached : public State
{
GODOT_CLASS(GoalNotReached, State)
/**
* @brief This class controls what happens when the Coin is in the not collected state.
*
*/
class GoalNotReached : public alai::State
{
GODOT_CLASS(GoalNotReached, alai::State)
private:
/**
* @brief The animated sprite of the Coin.
*
*/
AnimatedSprite *animated_sprite;
private:
/**
* @brief The animated sprite of the Coin.
*
*/
godot::AnimatedSprite *animated_sprite;
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
/**
* @brief Construct a new GoalNotReached object.
*
*/
GoalNotReached();
/**
* @brief Construct a new GoalNotReached object.
*
*/
GoalNotReached();
/**
* @brief Destroy the GoalNotReached object.
*
*/
~GoalNotReached();
/**
* @brief Destroy the GoalNotReached object.
*
*/
~GoalNotReached();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Called when the not collected state of the coin is entered.
*
*/
void _state_enter();
/**
* @brief Called when the not collected state of the coin is entered.
*
*/
void _state_enter();
/**
* @brief Called when the not collected state of the coin is exited.
*
*/
void _state_exit();
/**
* @brief Called when the not collected state of the coin is exited.
*
*/
void _state_exit();
/**
* @brief Method called on body entered.
*
* @param[in] node Node interacting with whoever
*/
void _on_Goal_body_entered(Node *node);
};
/**
* @brief Method called on body entered.
*
* @param[in] node Node interacting with whoever
*/
void _on_Goal_body_entered(Node *node);
};
}
#endif

View File

@@ -1,36 +1,30 @@
#include "goal/GoalReached.h"
#include <Area2D.hpp>
using namespace godot;
void GoalReached::_register_methods()
void alai::GoalReached::_register_methods()
{
register_method("_state_enter", &GoalReached::_state_enter);
register_method("_state_exit", &GoalReached::_state_exit);
}
GoalReached::GoalReached()
alai::GoalReached::GoalReached()
{
}
GoalReached::~GoalReached()
alai::GoalReached::~GoalReached()
{
}
void GoalReached::_init()
void alai::GoalReached::_init()
{
}
void GoalReached::_state_enter()
void alai::GoalReached::_state_enter()
{
Godot::print("Flag touched");
godot::Godot::print("Flag touched");
}
void GoalReached::_state_exit()
void alai::GoalReached::_state_exit()
{
}

View File

@@ -1,74 +1,72 @@
#ifndef ALAI_GOAL_REACHED
#define ALAI_GOAL_REACHED
#ifndef ALAI_GOAL_GOAL_REACHED_H
#define ALAI_GOAL_GOAL_REACHED_H
#include "state_machine/State.h"
#include <Godot.hpp>
#include <Node.hpp>
#include <AnimatedSprite.hpp>
#include <Godot.hpp>
namespace godot
namespace alai
{
/**
* @brief This class controls what happens when the goal flag is in the reached state.
*
*/
class GoalReached : public State
{
GODOT_CLASS(GoalReached, State)
/**
* @brief This class controls what happens when the goal flag is in the reached state.
*
*/
class GoalReached : public alai::State
{
GODOT_CLASS(GoalReached, alai::State)
private:
/**
* @brief The animated sprite of the Coin.
*
*/
AnimatedSprite *animated_sprite;
private:
/**
* @brief The animated sprite of the Coin.
*
*/
godot::AnimatedSprite *animated_sprite;
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
public:
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
/**
* @brief Construct a new GoalReached object.
*
*/
GoalReached();
/**
* @brief Construct a new GoalReached object.
*
*/
GoalReached();
/**
* @brief Destroy the GoalReached object.
*
*/
~GoalReached();
/**
* @brief Destroy the GoalReached object.
*
*/
~GoalReached();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Initialize the class from Godot.
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
void _init();
/**
* @brief Called when the collected state of the coin is entered.
*
*/
void _state_enter();
/**
* @brief Called when the collected state of the coin is entered.
*
*/
void _state_enter();
/**
* @brief Called when the collected state of the coin is exited.
*
*/
void _state_exit();
/**
* @brief Called when the collected state of the coin is exited.
*
*/
void _state_exit();
/**
* @brief Called when the animation of the collected coin has finished.
*
*/
};
/**
* @brief Called when the animation of the collected coin has finished.
*
*/
};
}
#endif