#include "rts_actions.hpp" #include "rts_states.hpp" #include "goap/actor_world_state.hpp" #include "goap/state.hpp" #include #include MoveToTarget::MoveToTarget() : Action() { this->effects.insert("is_at_target", true); } goap::State *MoveToTarget::get_apply_state(goap::ActorWorldState *context) const { gd::Node3D *target{gd::Object::cast_to(context->get_world_property("target_node"))}; if(target == nullptr) { gd::UtilityFunctions::push_warning("Failed to get target node of action ", get_static_class()); return nullptr; } else { MoveTo *state{this->create_state()}; state->target_node = target; return state; } } FireAtTarget::FireAtTarget() : Action() { this->effects.insert("is_target_dead", true); this->required.insert("can_see_target", true); } goap::State *FireAtTarget::get_apply_state(goap::ActorWorldState *context) const { Animate *state{this->create_state()}; state->animation = "fire_weapon"; return state; } FindTarget::FindTarget() : Action() { this->effects.insert("can_see_target", true); } goap::State *FindTarget::get_apply_state(goap::ActorWorldState *context) const { gd::Node3D *target{gd::Object::cast_to(context->get_world_property("target_node"))}; MoveTo *state{this->create_state()}; state->target_node = target; return state; } GetInMeleeRange::GetInMeleeRange() : Action() { this->effects.insert("is_in_melee_range", true); this->required.insert("can_see_target", true); } goap::State *GetInMeleeRange::get_apply_state(goap::ActorWorldState *context) const { gd::Node3D *target{gd::Object::cast_to(context->get_world_property("target_node"))}; MoveTo *state{this->create_state()}; state->target_node = target; return state; } MeleeAttack::MeleeAttack() : Action() { this->effects.insert("is_target_dead", true); this->required.insert("can_see_target", true); this->required.insert("is_in_melee_range", true); } goap::State *MeleeAttack::get_apply_state(goap::ActorWorldState *context) const { Animate *state{this->create_state()}; state->animation = "melee_attack"; return state; }