feat: implemented heal action and goal
This commit is contained in:
parent
a78bbfd3b5
commit
f9b3c6eb3f
18 changed files with 131 additions and 42 deletions
|
|
@ -29,6 +29,10 @@ ActionID Action::get_id() const {
|
|||
return this->id;
|
||||
}
|
||||
|
||||
bool Action::get_require_state_complete() const {
|
||||
return this->require_state_complete;
|
||||
}
|
||||
|
||||
bool Action::procedural_is_possible(ActorWorldState *context) const {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ public:
|
|||
WorldState const &get_effects() const;
|
||||
|
||||
ActionID get_id() const;
|
||||
bool get_require_state_complete() const;
|
||||
protected:
|
||||
Action() = default;
|
||||
template<class TState>
|
||||
|
|
@ -54,6 +55,7 @@ protected:
|
|||
WorldState required{};
|
||||
WorldState effects{};
|
||||
bool only_proc_is_completed{false};
|
||||
bool require_state_complete{true};
|
||||
private:
|
||||
ActionID id{-1};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ void State::_enter_tree() {
|
|||
}
|
||||
|
||||
void State::_process(double delta_time) {
|
||||
if(this->is_action_done())
|
||||
this->state_finished();
|
||||
if(this->is_action_done() && this->get_action()->get_require_state_complete())
|
||||
this->state_ended();
|
||||
}
|
||||
|
||||
Action const *State::get_action() const {
|
||||
|
|
@ -26,20 +26,19 @@ Action const *State::get_action() const {
|
|||
|
||||
void State::_end_state() {}
|
||||
|
||||
void State::state_finished() {
|
||||
void State::state_ended() {
|
||||
this->end_state();
|
||||
this->emit_signal("state_finished");
|
||||
}
|
||||
|
||||
void State::state_failed() {
|
||||
this->end_state();
|
||||
this->emit_signal("state_failed");
|
||||
this->emit_signal(this->is_action_done() ? "state_finished" : "state_failed");
|
||||
}
|
||||
|
||||
bool State::is_action_done() const {
|
||||
return this->action->is_completed(this->world_state);
|
||||
}
|
||||
|
||||
bool State::is_action_done_interrupt() const {
|
||||
return this->is_action_done() && !this->action->get_require_state_complete();
|
||||
}
|
||||
|
||||
void State::end_state() {
|
||||
this->_end_state();
|
||||
this->queue_free();
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@ public:
|
|||
virtual void _process(double delta_time) override;
|
||||
protected:
|
||||
Action const *get_action() const;
|
||||
// \returns True if the Action's requirements are complete. Without evaluating Action::require_state_complete.
|
||||
bool is_action_done() const;
|
||||
// \returns True if the Action's requirements are complete. Including Action::require_state_complete.
|
||||
bool is_action_done_interrupt() const;
|
||||
virtual void _end_state();
|
||||
void state_finished();
|
||||
void state_failed();
|
||||
void state_ended();
|
||||
private:
|
||||
void end_state();
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue