2013-12-12 09:33:59 +01:00
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
// Created 2013 //
|
|
|
|
// Dennis Andersen, Linda Andersson //
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
2013-12-09 11:57:34 +01:00
|
|
|
#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H
|
|
|
|
#define GAMELOGIC_PLAYER_PROTOCOLS_H
|
|
|
|
|
2013-12-12 09:33:59 +01:00
|
|
|
#include <CustomNetProtocol.h>
|
2013-12-09 11:57:34 +01:00
|
|
|
#include "ProtocolIdentificationID.h"
|
2014-01-22 15:22:52 +01:00
|
|
|
#include <bitset>
|
2013-12-09 11:57:34 +01:00
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
//protocol_Gameplay_PlayerMovement 300
|
|
|
|
//protocol_Gameplay_PlayerMouseMovement 301
|
|
|
|
//protocol_Gameplay_PlayerChangeWeapon 302
|
2013-12-09 11:57:34 +01:00
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
{
|
2013-12-12 10:36:55 +01:00
|
|
|
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject
|
2013-12-09 11:57:34 +01:00
|
|
|
{
|
|
|
|
bool bForward;
|
|
|
|
bool bBackward;
|
2014-01-21 09:52:48 +01:00
|
|
|
bool bLeft;
|
|
|
|
bool bRight;
|
2013-12-09 11:57:34 +01:00
|
|
|
|
|
|
|
Protocol_PlayerMovement()
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_PlayerMovement;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-12 09:33:59 +01:00
|
|
|
|
2013-12-12 10:36:55 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
|
|
|
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
|
|
|
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_PlayerMovement(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2013-12-09 11:57:34 +01:00
|
|
|
}
|
2013-12-20 09:42:02 +01:00
|
|
|
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
|
|
|
|
{
|
|
|
|
bForward = val[1].value.netBool;
|
|
|
|
bBackward = val[2].value.netBool;
|
2014-01-21 09:52:48 +01:00
|
|
|
bLeft = val[3].value.netBool;
|
|
|
|
bRight = val[4].value.netBool;
|
2013-12-20 09:42:02 +01:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2013-12-12 10:36:55 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
2013-12-09 11:57:34 +01:00
|
|
|
{
|
2013-12-12 09:33:59 +01:00
|
|
|
this->protocol[1].value = bForward;
|
|
|
|
this->protocol[2].value = bBackward;
|
2014-01-21 09:52:48 +01:00
|
|
|
this->protocol[3].value = bLeft;
|
|
|
|
this->protocol[4].value = bRight;
|
2013-12-09 11:57:34 +01:00
|
|
|
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-12-12 10:36:55 +01:00
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
2013-12-09 11:57:34 +01:00
|
|
|
};
|
2013-12-11 12:14:00 +01:00
|
|
|
|
2014-01-23 09:24:55 +01:00
|
|
|
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
|
2013-12-18 12:18:01 +01:00
|
|
|
{
|
|
|
|
|
2014-01-23 09:24:55 +01:00
|
|
|
float lookDirX;
|
|
|
|
float lookDirY;
|
|
|
|
float lookDirZ;
|
2013-12-18 12:18:01 +01:00
|
|
|
|
2014-01-23 09:24:55 +01:00
|
|
|
Protocol_PlayerLook()
|
2013-12-18 12:18:01 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-18 12:18:01 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
2014-01-23 09:24:55 +01:00
|
|
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
2013-12-18 12:18:01 +01:00
|
|
|
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2013-12-18 12:18:01 +01:00
|
|
|
}
|
2014-01-23 09:24:55 +01:00
|
|
|
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
|
2013-12-20 09:42:02 +01:00
|
|
|
{
|
2014-01-23 09:24:55 +01:00
|
|
|
lookDirX = val[1].value.netFloat;
|
|
|
|
lookDirY = val[2].value.netFloat;
|
|
|
|
lookDirZ = val[3].value.netFloat;
|
2013-12-20 09:42:02 +01:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2013-12-18 12:18:01 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
2014-01-23 09:24:55 +01:00
|
|
|
this->protocol[1].value = lookDirX;
|
|
|
|
this->protocol[2].value = lookDirY;
|
|
|
|
this->protocol[3].value = lookDirZ;
|
2013-12-18 12:18:01 +01:00
|
|
|
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
struct Protocol_PlayerChangeWeapon :public Oyster::Network::CustomProtocolObject
|
2013-12-11 12:14:00 +01:00
|
|
|
{
|
2013-12-17 10:07:46 +01:00
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
int ID;
|
2013-12-11 12:14:00 +01:00
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_PlayerChangeWeapon()
|
2013-12-11 12:14:00 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_PlayerChangeWeapon;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-11 12:14:00 +01:00
|
|
|
|
2013-12-12 20:32:54 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
2013-12-11 12:14:00 +01:00
|
|
|
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_PlayerChangeWeapon(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2013-12-11 12:14:00 +01:00
|
|
|
}
|
2014-01-21 09:52:48 +01:00
|
|
|
const Protocol_PlayerChangeWeapon& operator=(Oyster::Network::CustomNetProtocol& val)
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-27 13:56:31 +01:00
|
|
|
struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
|
|
|
bool hasShot;
|
|
|
|
|
|
|
|
Protocol_PlayerShot()
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_PlayerShot;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-27 13:56:31 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2014-01-27 13:56:31 +01:00
|
|
|
}
|
|
|
|
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
|
|
|
|
{
|
|
|
|
hasShot = val[1].value.netBool;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = hasShot;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-30 09:07:56 +01:00
|
|
|
struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
|
|
|
bool hasJumped;
|
|
|
|
|
|
|
|
Protocol_PlayerJump()
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_PlayerJump;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-30 09:07:56 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
2014-01-30 09:40:58 +01:00
|
|
|
}
|
|
|
|
Protocol_PlayerJump(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2014-01-30 09:07:56 +01:00
|
|
|
}
|
|
|
|
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
|
|
|
|
{
|
|
|
|
hasJumped = val[1].value.netBool;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = hasJumped;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
2013-12-09 11:57:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|