From fa098fec09a2f192d39038349d78fe13118e7079 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 16 Dec 2022 12:13:03 +0100 Subject: [PATCH] Blackboard: Add erase_var() --- blackboard.cpp | 5 +++++ blackboard.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/blackboard.cpp b/blackboard.cpp index faac7ef..0eea85c 100644 --- a/blackboard.cpp +++ b/blackboard.cpp @@ -31,6 +31,10 @@ bool Blackboard::has_var(const Variant &p_key) const { return data.has(p_key) || (parent.is_valid() && parent->has_var(p_key)); } +void Blackboard::erase_var(const Variant &p_key) { + data.erase(p_key); +} + void Blackboard::prefetch_nodepath_vars(Node *p_node) { ERR_FAIL_COND(p_node == nullptr); for (int i = 0; i < data.size(); i++) { @@ -52,6 +56,7 @@ void Blackboard::_bind_methods() { ClassDB::bind_method(D_METHOD("has_var", "p_key"), &Blackboard::has_var); ClassDB::bind_method(D_METHOD("set_parent_scope", "p_blackboard"), &Blackboard::set_parent_scope); ClassDB::bind_method(D_METHOD("get_parent_scope"), &Blackboard::get_parent_scope); + ClassDB::bind_method(D_METHOD("erase_var"), &Blackboard::erase_var); ClassDB::bind_method(D_METHOD("prefetch_nodepath_vars", "p_node"), &Blackboard::prefetch_nodepath_vars); ClassDB::bind_method(D_METHOD("top"), &Blackboard::top); } \ No newline at end of file diff --git a/blackboard.h b/blackboard.h index 322dd15..b6134ee 100644 --- a/blackboard.h +++ b/blackboard.h @@ -31,6 +31,8 @@ public: Variant get_var(const Variant &p_key, const Variant &p_default) const; void set_var(const Variant &p_key, const Variant &p_value); bool has_var(const Variant &p_key) const; + void erase_var(const Variant &p_key); + void prefetch_nodepath_vars(Node *p_node); };