#ifndef NETWORKCLIENT_HH
#define NETWORKCLIENT_HH
#include "../GameState.hh"
#include "Session.hh"
#include "Object.hh"
// forward-declare
class NetworkClientLocalPlayer;
class NetworkClientRemotePlayer;
class NetworkClient {
friend class NetworkClientPlayerHelper;
friend class NetworkClientLocalPlayer;
friend class NetworkClientRemotePlayer;
friend class NetworkClientProjectile;
protected:
GameState &state;
CL_SlotContainer slots;
NetworkSession netsession;
NetworkNode *server;
NetworkObject_ClientController netobjs;
public:
NetworkClient (GameState &state, const NetworkAddress &connect_to);
private:
void on_create (NetworkObject_Client *obj, NetworkMessageID msg_id, NetworkPacketInput &pkt);
void on_server_hello (NetworkObject_Client *obj, NetworkPacketInput &pkt);
void on_player_info (NetworkObject_Client *obj, NetworkPacketInput &pkt);
void on_player_join (NetworkObject_Client *obj, NetworkPacketInput &pkt);
void on_projectile_create (NetworkObject_Client *obj, NetworkPacketInput &pkt);
void on_terrain_array (NetworkPacketInput &pkt, NetworkNode *node);
public:
void player_quit (NetworkClientRemotePlayer *player);
};
class NetworkClientObjectHelper {
protected:
NetworkClient &client;
CL_SlotContainer slots;
NetworkObject_Client *obj;
NetworkClientObjectHelper (NetworkClient &client, NetworkObject_Client *obj);
};
class NetworkClientPlayerHelper : public NetworkClientObjectHelper, public virtual Player {
protected:
NetworkClientPlayerHelper (NetworkClient &client, Vector position, NetworkObject_Client *obj);
private:
void on_position (NetworkPacketInput &pkt);
void on_dig (NetworkPacketInput &pkt);
void on_weapon_change (NetworkPacketInput &pkt);
};
class NetworkClientLocalPlayer : public NetworkClientPlayerHelper, public LocalPlayer {
public:
NetworkClientLocalPlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
virtual void handleInput (PlayerInput input);
};
class NetworkClientRemotePlayer : public NetworkClientPlayerHelper, public RemotePlayer {
public:
NetworkClientRemotePlayer (NetworkClient &client, NetworkObject_Client *obj, Vector position);
private:
void on_quit (NetworkPacketInput &pkt);
};
class NetworkClientProjectile : public NetworkClientObjectHelper, public Projectile {
public:
NetworkClientProjectile (NetworkClient &client, NetworkObject_Client *obj, Vector position, Vector velocity,
float explosionRadius);
protected:
virtual void onDestroy (Vector position, bool removeGround);
private:
void on_destroy (NetworkPacketInput &pkt);
};
#endif