[ad_1]
I am engaged on constructing an extension to MultiplayerPeer for Godot, utilizing GDExtension. As is my customized, even when I do not find yourself pushing it to the ultimate product, I at all times begin with a Nullary Sample implementation—that’s, an implementation that does not really do something, however suits the mildew—simply to guarantee that I am getting the category recognition that I want within the editor. Then, I fill it out with correct habits and switch it into my objective class.
Now, I’ve gone via MultiplayerPeer.hpp, and located numerous strategies that finish in = 0;
, which makes them pure virtuals. I’ve carried out a nullary model of all of them, so far as I can inform. Nonetheless, Godot, whereas recognizing that my class exists, continues to be telling me that it is summary.
It has been a short while since I actually sharpened my C++ abilities, so I could be lacking one thing else. Sadly I can not simply set off a compiler error with it and browse the objection, as I am constructing a library via Scons. nm
has not been terribly useful.
This is my code:
nullary_multiplayer_peer.h:
#ifndef NULLARY_MULTIPLAYER_PEER
#outline NULLARY_MULTIPLAYER_PEER
#embrace <godot_cpp/lessons/multiplayer_peer.hpp>
#embrace <godot_cpp/lessons/crypto.hpp>
namespace godot {
class NullaryMultiplayerPeer : public MultiplayerPeer {
GDCLASS(NullaryMultiplayerPeer, MultiplayerPeer);
personal:
protected:
static void _bind_methods();
public:
NullaryMultiplayerPeer();
~NullaryMultiplayerPeer();
void set_transfer_channel(int p_channel);
int get_transfer_channel() const;
void set_transfer_mode(TransferMode p_mode);
TransferMode get_transfer_mode() const;
void set_refuse_new_connections(bool p_enable);
bool is_refusing_new_connections() const;
bool is_server_relay_supported() const;
void set_target_peer(int p_peer_id);
int get_packet_peer() const;
TransferMode get_packet_mode() const;
int get_packet_channel() const;
void disconnect_peer(int p_peer, bool p_force = false);
bool is_server() const;
void ballot();
void shut();
int get_unique_id() const;
ConnectionStatus get_connection_status() const;
};
}
#endif
nullary_multiplayer_peer.cpp:
#embrace "nullary_multiplayer_peer.h"
#embrace <godot_cpp/core/class_db.hpp>
utilizing namespace godot;
void NullaryMultiplayerPeer::_bind_methods() {
}
NullaryMultiplayerPeer::NullaryMultiplayerPeer() {
}
NullaryMultiplayerPeer::~NullaryMultiplayerPeer() {
}
void NullaryMultiplayerPeer::set_transfer_channel(int p_channel) {}
int NullaryMultiplayerPeer::get_transfer_channel() const { return 0; }
void NullaryMultiplayerPeer::set_transfer_mode(TransferMode p_mode) {}
MultiplayerPeer::TransferMode NullaryMultiplayerPeer::get_transfer_mode() const { return MultiplayerPeer::TransferMode::TRANSFER_MODE_UNRELIABLE; }
void NullaryMultiplayerPeer::set_refuse_new_connections(bool p_enable) {}
bool NullaryMultiplayerPeer::is_refusing_new_connections() const { return true; }
bool NullaryMultiplayerPeer::is_server_relay_supported() const { return false; }
void NullaryMultiplayerPeer::set_target_peer(int p_peer_id) { }
int NullaryMultiplayerPeer::get_packet_peer() const { return 0; }
MultiplayerPeer::TransferMode NullaryMultiplayerPeer::get_packet_mode() const { return MultiplayerPeer::TransferMode::TRANSFER_MODE_UNRELIABLE; }
int NullaryMultiplayerPeer::get_packet_channel() const { return 0; }
void NullaryMultiplayerPeer::disconnect_peer(int p_peer, bool p_force) { }
bool NullaryMultiplayerPeer::is_server() const { return false; }
void NullaryMultiplayerPeer::ballot() {}
void NullaryMultiplayerPeer::shut() {}
int NullaryMultiplayerPeer::get_unique_id() const { return 0; }
MultiplayerPeer::ConnectionStatus NullaryMultiplayerPeer::get_connection_status() const { return MultiplayerPeer::ConnectionStatus::CONNECTION_DISCONNECTED; }
Lastly, right here is the code with the error, in GDScript:
func _ready():
# var peer = ENetMultiplayerPeer.new()
# NullaryMultiplayerPeer.new()
var peer = NullaryMultiplayerPeer.new()
peer.create_server(9999)
self.multiplayer.multiplayer_peer = peer
The particular error, and all that I have been in a position to get out of it, is “Native class ‘NullaryMultiplayerPeer’ can’t be instantiated as it’s summary.”
Can anybody see what I am lacking, and why Godot sees it as an summary class?
[ad_2]