alai/src/state_machine/State.h

104 lines
3.0 KiB
C
Raw Normal View History

2022-08-26 19:27:57 -04:00
#ifndef ALAI_STATE_MACHINE_STATE_H
#define ALAI_STATE_MACHINE_STATE_H
2022-04-22 21:45:46 -04:00
#include "state_machine/StateMachine.h"
#include <Godot.hpp>
2022-08-26 19:27:57 -04:00
namespace alai
{
2022-04-13 00:59:23 -04:00
/**
* @brief This class provides a virtual template state that real states should extend from and override.
*
*/
class State : public StateMachine
{
GODOT_CLASS(State, Node)
private:
2022-04-13 00:59:23 -04:00
/**
* @brief The state's parent, this is the node 1 level above the state machine.
*
*/
2022-08-26 19:27:57 -04:00
godot::Node *parent;
2022-04-13 00:59:23 -04:00
/**
* @brief The state machine itself, used to handle all state related work.
*
*/
StateMachine *state_machine;
public:
2022-04-13 00:59:23 -04:00
/**
* @brief This method registers classes with Godot.
*
* @details This method registers methods, properties, and signals with the Godot engine.
*/
static void _register_methods();
2022-04-13 00:59:23 -04:00
/**
* @brief Construct a new State object.
*
*/
State();
2022-04-13 00:59:23 -04:00
/**
* @brief Destroy the State object.
*
*/
~State();
/**
* @brief Initialize the class from Godot.
2022-04-13 00:59:23 -04:00
*
* @details This method is called just once when the Godot engine connects to the instance of the class.
*/
virtual void _init();
2022-04-13 00:59:23 -04:00
/**
* @brief This is called when a state is entered.
*
* @param[in] state This will contain the previous state.
* @param[in] args The arguments passed to the state.
*/
2022-08-26 19:27:57 -04:00
virtual void _state_enter(const godot::String state, const godot::Array args = godot::Array());
2022-04-13 00:59:23 -04:00
/**
* @brief This is called when a state is exited.
*
* @param[in] state The state we are going to.
* @param[in] args The arguments passed to the state.
*/
2022-08-26 19:27:57 -04:00
virtual void _state_exit(const godot::String state, const godot::Array args = godot::Array());
2022-04-13 00:59:23 -04:00
/**
* @brief Set the parent object.
*
* @param[in] parent The parent of the state.
*/
2022-08-26 19:27:57 -04:00
virtual void set_parent(godot::Node *parent) final;
2022-04-13 00:59:23 -04:00
/**
* @brief Get the parent object.
*
* @return Node* The parent of the state.
*/
virtual Node *get_parent() final;
2022-04-13 00:59:23 -04:00
/**
* @brief Set the state machine object.
*
* @param[in] state_machine The state machine.
*/
2022-04-12 11:33:22 -04:00
virtual void set_state_machine(StateMachine *state_machine) final;
2022-04-13 00:59:23 -04:00
/**
* @brief Get the state machine object.
*
* @return StateMachine* The state machine.
*/
virtual StateMachine *get_state_machine() final;
};
}
#endif