Expose get_rpc_config and get_node_rpc_config

add documentation

Update doc/classes/Node.xml

change name of get_node_rpc_config to get_rpc_config

Co-Authored-By: moondog <159832633+dog-on-moon@users.noreply.github.com>
Co-Authored-By: Micky <66727710+Mickeon@users.noreply.github.com>
This commit is contained in:
Ryan 2024-08-24 01:58:54 -04:00
parent e3550cb20f
commit 8835f326b1
12 changed files with 25 additions and 10 deletions

View File

@ -173,6 +173,8 @@ void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
ClassDB::bind_method(D_METHOD("is_abstract"), &Script::is_abstract);
ClassDB::bind_method(D_METHOD("get_rpc_config"), &Script::get_rpc_config);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_source_code", "get_source_code");
}

View File

@ -180,7 +180,7 @@ public:
virtual bool is_placeholder_fallback_enabled() const { return false; }
virtual const Variant get_rpc_config() const = 0;
virtual Variant get_rpc_config() const = 0;
Script() {}
};

View File

@ -205,7 +205,7 @@ public:
GDVIRTUAL0RC(Variant, _get_rpc_config)
virtual const Variant get_rpc_config() const override {
virtual Variant get_rpc_config() const override {
Variant ret;
GDVIRTUAL_REQUIRED_CALL(_get_rpc_config, ret);
return ret;

View File

@ -498,6 +498,12 @@
Returns the time elapsed (in seconds) since the last process callback. This value is identical to [method _process]'s [code]delta[/code] parameter, and may vary from frame to frame. See also [constant NOTIFICATION_PROCESS].
</description>
</method>
<method name="get_rpc_config" qualifiers="const">
<return type="Variant" />
<description>
Returns a [Dictionary] mapping method names to their RPC configuration defined for this node using [method rpc_config].
</description>
</method>
<method name="get_scene_instance_load_placeholder" qualifiers="const">
<return type="bool" />
<description>

View File

@ -58,6 +58,12 @@
Returns the default value of the specified property.
</description>
</method>
<method name="get_rpc_config" qualifiers="const">
<return type="Variant" />
<description>
Returns a [Dictionary] mapping method names to their RPC configuration defined by this script.
</description>
</method>
<method name="get_script_constant_map">
<return type="Dictionary" />
<description>

View File

@ -904,7 +904,7 @@ void GDScript::get_members(HashSet<StringName> *p_members) {
}
}
const Variant GDScript::get_rpc_config() const {
Variant GDScript::get_rpc_config() const {
return rpc_config;
}

View File

@ -334,7 +334,7 @@ public:
virtual void get_constants(HashMap<StringName, Variant> *p_constants) override;
virtual void get_members(HashSet<StringName> *p_members) override;
virtual const Variant get_rpc_config() const override;
virtual Variant get_rpc_config() const override;
void unload_static() const;

View File

@ -2716,7 +2716,7 @@ int CSharpScript::get_member_line(const StringName &p_member) const {
return -1;
}
const Variant CSharpScript::get_rpc_config() const {
Variant CSharpScript::get_rpc_config() const {
return rpc_config;
}

View File

@ -284,7 +284,7 @@ public:
int get_member_line(const StringName &p_member) const override;
const Variant get_rpc_config() const override;
Variant get_rpc_config() const override;
#ifdef TOOLS_ENABLED
bool is_placeholder_fallback_enabled() const override {

View File

@ -108,7 +108,7 @@ const SceneRPCInterface::RPCConfigCache &SceneRPCInterface::_get_node_config(con
return rpc_cache[oid];
}
RPCConfigCache cache;
_parse_rpc_config(p_node->get_node_rpc_config(), true, cache);
_parse_rpc_config(p_node->get_rpc_config(), true, cache);
if (p_node->get_script_instance()) {
_parse_rpc_config(p_node->get_script_instance()->get_rpc_config(), false, cache);
}

View File

@ -757,7 +757,7 @@ void Node::rpc_config(const StringName &p_method, const Variant &p_config) {
}
}
const Variant Node::get_node_rpc_config() const {
Variant Node::get_rpc_config() const {
return data.rpc_config;
}
@ -3640,6 +3640,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_multiplayer"), &Node::get_multiplayer);
ClassDB::bind_method(D_METHOD("rpc_config", "method", "config"), &Node::rpc_config);
ClassDB::bind_method(D_METHOD("get_rpc_config"), &Node::get_rpc_config);
ClassDB::bind_method(D_METHOD("set_editor_description", "editor_description"), &Node::set_editor_description);
ClassDB::bind_method(D_METHOD("get_editor_description"), &Node::get_editor_description);

View File

@ -199,7 +199,7 @@ private:
void *process_group = nullptr; // to avoid cyclic dependency
int multiplayer_authority = 1; // Server by default.
Variant rpc_config;
Variant rpc_config = Dictionary();
// Variables used to properly sort the node when processing, ignored otherwise.
int process_priority = 0;
@ -717,7 +717,7 @@ public:
bool is_multiplayer_authority() const;
void rpc_config(const StringName &p_method, const Variant &p_config); // config a local method for RPC
const Variant get_node_rpc_config() const;
Variant get_rpc_config() const;
template <typename... VarArgs>
Error rpc(const StringName &p_method, VarArgs... p_args);