2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* blackboard.h
|
|
|
|
* =============================================================================
|
|
|
|
* Copyright 2021-2023 Serhii Snitsaruk
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2022-09-08 13:56:51 +00:00
|
|
|
|
|
|
|
#ifndef BLACKBOARD_H
|
|
|
|
#define BLACKBOARD_H
|
|
|
|
|
2022-12-15 07:26:52 +00:00
|
|
|
#include "core/object/object.h"
|
|
|
|
#include "core/object/ref_counted.h"
|
|
|
|
#include "core/variant/dictionary.h"
|
|
|
|
#include "core/variant/variant.h"
|
|
|
|
#include "scene/main/node.h"
|
|
|
|
|
|
|
|
class Blackboard : public RefCounted {
|
|
|
|
GDCLASS(Blackboard, RefCounted);
|
2022-09-08 13:56:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Dictionary data;
|
|
|
|
Ref<Blackboard> parent;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_data(const Dictionary &p_value) { data = p_value; }
|
|
|
|
Dictionary get_data() const { return data; }
|
|
|
|
|
|
|
|
void set_parent_scope(const Ref<Blackboard> &p_blackboard) { parent = p_blackboard; }
|
|
|
|
Ref<Blackboard> get_parent_scope() const { return parent; }
|
|
|
|
|
2022-11-23 17:02:46 +00:00
|
|
|
Ref<Blackboard> top() const;
|
|
|
|
|
2022-09-08 13:56:51 +00:00
|
|
|
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;
|
2022-12-16 11:13:03 +00:00
|
|
|
void erase_var(const Variant &p_key);
|
|
|
|
|
2022-10-19 14:01:16 +00:00
|
|
|
void prefetch_nodepath_vars(Node *p_node);
|
2022-09-08 13:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BLACKBOARD_H
|