alai/src/goal/GoalNotReached.cpp

47 lines
1.0 KiB
C++
Raw Normal View History

#include "goal/GoalNotReached.h"
2022-08-28 01:08:04 -04:00
#include <Area2D.hpp>
2022-08-28 01:08:04 -04:00
void alai::GoalNotReached::_register_methods()
{
godot::register_method("_state_enter", &GoalNotReached::_state_enter);
godot::register_method("_state_exit", &GoalNotReached::_state_exit);
godot::register_method("_on_Goal_body_entered", &GoalNotReached::_on_Goal_body_entered);
}
2022-08-28 01:08:04 -04:00
alai::GoalNotReached::GoalNotReached()
{
}
2022-08-28 01:08:04 -04:00
alai::GoalNotReached::~GoalNotReached()
{
}
2022-08-28 01:08:04 -04:00
void alai::GoalNotReached::_init()
{
}
2022-08-28 01:08:04 -04:00
void alai::GoalNotReached::_state_enter()
{
2022-08-28 01:08:04 -04:00
animated_sprite = get_parent()->get_node<godot::AnimatedSprite>("AnimatedSprite");
animated_sprite->set_animation("flagmove");
animated_sprite->play();
}
2022-08-28 01:08:04 -04:00
void alai::GoalNotReached::_state_exit()
{
}
2022-08-28 01:08:04 -04:00
void alai::GoalNotReached::_on_Goal_body_entered(Node *node)
{
2022-08-01 15:05:09 -04:00
auto parent_node = get_parent();
if (parent_node != nullptr)
{
2022-08-28 01:08:04 -04:00
auto goal = Object::cast_to<godot::Area2D>(parent_node);
2022-08-01 15:05:09 -04:00
goal->set_collision_mask_bit(0, false);
}
2022-08-28 01:08:04 -04:00
2022-08-01 14:10:00 -04:00
get_state_machine()->change("GoalReached");
}