Fix LimboHSM::add_transition signature
This commit is contained in:
parent
c81c1ec872
commit
2612ec0855
|
@ -11,8 +11,8 @@
|
||||||
<methods>
|
<methods>
|
||||||
<method name="add_transition">
|
<method name="add_transition">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="p_from_state" type="Node" />
|
<param index="0" name="p_from_state" type="LimboState" />
|
||||||
<param index="1" name="p_to_state" type="Node" />
|
<param index="1" name="p_to_state" type="LimboState" />
|
||||||
<param index="2" name="p_event" type="String" />
|
<param index="2" name="p_event" type="String" />
|
||||||
<description>
|
<description>
|
||||||
Establishes a transition from one state to another when [param p_event] is dispatched. Both [param p_from_state] and [param p_to_state] must be immediate children of this state.
|
Establishes a transition from one state to another when [param p_event] is dispatched. Both [param p_from_state] and [param p_to_state] must be immediate children of this state.
|
||||||
|
|
|
@ -97,13 +97,11 @@ void LimboHSM::update(double p_delta) {
|
||||||
_update(p_delta);
|
_update(p_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimboHSM::add_transition(Node *p_from_state, Node *p_to_state, const String &p_event) {
|
void LimboHSM::add_transition(LimboState *p_from_state, LimboState *p_to_state, const String &p_event) {
|
||||||
ERR_FAIL_COND(p_from_state != nullptr && p_from_state->get_parent() != this);
|
ERR_FAIL_COND_MSG(p_from_state != nullptr && p_from_state->get_parent() != this, "LimboHSM: Unable to add a transition from a state that is not an immediate child of mine.");
|
||||||
ERR_FAIL_COND(p_from_state != nullptr && !p_from_state->is_class("LimboState"));
|
ERR_FAIL_COND_MSG(p_to_state == nullptr, "LimboHSM: Unable to add a transition to a null state.");
|
||||||
ERR_FAIL_COND(p_to_state == nullptr);
|
ERR_FAIL_COND_MSG(p_to_state->get_parent() != this, "LimboHSM: Unable to add a transition to a state that is not an immediate child of mine.");
|
||||||
ERR_FAIL_COND(p_to_state->get_parent() != this);
|
ERR_FAIL_COND_MSG(p_event.is_empty(), "LimboHSM: Failed to add transition due to empty event string.");
|
||||||
ERR_FAIL_COND(!p_to_state->is_class("LimboState"));
|
|
||||||
ERR_FAIL_COND(p_event.is_empty());
|
|
||||||
|
|
||||||
uint64_t key = _get_transition_key(p_from_state, p_event);
|
uint64_t key = _get_transition_key(p_from_state, p_event);
|
||||||
transitions[key] = Object::cast_to<LimboState>(p_to_state);
|
transitions[key] = Object::cast_to<LimboState>(p_to_state);
|
||||||
|
|
|
@ -30,7 +30,7 @@ private:
|
||||||
LimboState *active_state;
|
LimboState *active_state;
|
||||||
HashMap<uint64_t, LimboState *> transitions;
|
HashMap<uint64_t, LimboState *> transitions;
|
||||||
|
|
||||||
_FORCE_INLINE_ uint64_t _get_transition_key(Node *p_from_state, const String &p_event) {
|
_FORCE_INLINE_ uint64_t _get_transition_key(LimboState *p_from_state, const String &p_event) {
|
||||||
uint64_t key = hash_djb2_one_64(Variant::OBJECT);
|
uint64_t key = hash_djb2_one_64(Variant::OBJECT);
|
||||||
key = hash_djb2_one_64(Variant(p_from_state).hash(), key);
|
key = hash_djb2_one_64(Variant(p_from_state).hash(), key);
|
||||||
key = hash_djb2_one_64(p_event.hash(), key);
|
key = hash_djb2_one_64(p_event.hash(), key);
|
||||||
|
@ -65,8 +65,7 @@ public:
|
||||||
virtual bool dispatch(const String &p_event, const Variant &p_cargo = Variant()) override;
|
virtual bool dispatch(const String &p_event, const Variant &p_cargo = Variant()) override;
|
||||||
|
|
||||||
void update(double p_delta);
|
void update(double p_delta);
|
||||||
void add_transition(Node *p_from_state, Node *p_to_state, const String &p_event);
|
void add_transition(LimboState *p_from_state, LimboState *p_to_state, const String &p_event);
|
||||||
// void add_transition_from_any_state(Node *p_to_state, const String &p_event);
|
|
||||||
LimboState *anystate() const { return nullptr; }
|
LimboState *anystate() const { return nullptr; }
|
||||||
|
|
||||||
LimboHSM();
|
LimboHSM();
|
||||||
|
|
Loading…
Reference in New Issue