feat: animation/activate actions use scene unique names now

This commit is contained in:
Sara 2024-09-02 21:29:26 +02:00
parent d8a3000b13
commit c1b676f335
2 changed files with 19 additions and 2 deletions

View file

@ -72,13 +72,26 @@ double MoveTo::get_repath_interval() const {
void Activate::_bind_methods() {}
void Activate::_ready() {
this->anim = this->get_parent()->get_node<gd::AnimationPlayer>("%AnimationPlayer");
if(!this->anim->has_animation(this->animation))
this->end_state();
else this->anim->play(this->animation);
}
void Activate::_process(double) {
bool const animation_finished{!this->anim->is_playing() || this->anim->get_current_animation() != this->animation};
if(this->is_action_done_interrupt() || animation_finished)
this->end_state();
}
void Animate::_bind_methods() {}
void Animate::_ready() {
this->anim = this->get_node<gd::AnimationPlayer>("../AnimationPlayer");
this->anim->play(this->animation);
this->anim = this->get_parent()->get_node<gd::AnimationPlayer>("%AnimationPlayer");
if(!this->anim->has_animation(this->animation))
this->end_state();
else this->anim->play(this->animation);
}
void Animate::_process(double) {

View file

@ -34,8 +34,12 @@ class Activate : public goap::State {
GDCLASS(Activate, goap::State);
static void _bind_methods();
public:
virtual void _ready() override;
virtual void _process(double) override;
gd::Node3D *target_node{nullptr};
gd::String animation{};
private:
gd::AnimationPlayer *anim{nullptr};
};
class Animate : public goap::State {