3 #include "Component.hpp"
4 #include "NetworkIdentity.hpp"
5 #include "KapMirror/NetworkClient.hpp"
6 #include "KapMirror/NetworkServer.hpp"
14 NetworkComponent(std::shared_ptr<KapEngine::GameObject> go,
const std::string& name);
17 std::shared_ptr<NetworkServer> getServer()
const;
19 std::shared_ptr<NetworkClient> getClient()
const;
49 if (networkIdentity ==
nullptr) {
50 throw std::runtime_error(
"NetworkComponent: NetworkIdentity is not set");
91 void _setNetworkIdentity(
NetworkIdentity* identity) { networkIdentity = identity; }
virtual void onObjectUpdate()
Called when the object is spawned or updated.
Definition: NetworkComponent.hpp:78
bool isLocal() const
True if this object is not spawned by the server or the client. (is local object)
Definition: NetworkComponent.cpp:41
unsigned int getNetworkId() const
The unique network Id of this object (unique at runtime).
Definition: NetworkComponent.hpp:48
virtual void onStopServer()
Stop event, only called on server.
Definition: NetworkComponent.hpp:63
virtual void onStopClient()
Stop event, only called on client.
Definition: NetworkComponent.hpp:73
bool hasAuthority() const
True on client if that component has been assigned to the client.
Definition: NetworkComponent.cpp:48
Definition: NetworkIdentity.hpp:6
bool isServer() const
True if this object is on the server and has been spawned.
Definition: NetworkComponent.cpp:27
virtual void serialize(KapMirror::NetworkWriter &writer)
Serialize all the data from this component into payload.
Definition: NetworkComponent.hpp:83
Definition: NetworkReader.hpp:10
virtual void deserialize(KapMirror::NetworkReader &reader)
Deserialize all the data from payload into this component.
Definition: NetworkComponent.hpp:88
virtual void onStartClient()
Like start(), but only called on client.
Definition: NetworkComponent.hpp:68
virtual void onStartServer()
Like start(), but only called on server.
Definition: NetworkComponent.hpp:58
Definition: Component.hpp:38
Definition: NetworkWriter.hpp:12
void onAwake() override
call component awake
Definition: NetworkComponent.cpp:14
void onDestroy() override
call when component destroyed
Definition: NetworkComponent.cpp:21
unsigned int getNetworkId() const
The unique network Id of this object (unique at runtime).
Definition: NetworkIdentity.hpp:24
bool isClient() const
True if this object is on the client and has been spawned by the server.
Definition: NetworkComponent.cpp:34
Definition: NetworkComponent.hpp:9