Danbias/Code/Game/GameProtocols/PlayerProtocols.h

83 lines
2.3 KiB
C
Raw Normal View History

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"
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;
bool bTurnLeft;
bool bTurnRight;
bool bStrafeRight;
bool bStrafeLeft;
Protocol_PlayerMovement()
{
2013-12-17 10:25:34 +01:00
this->protocol[0].value = protocol_Gamplay_PlayerNavigation;
2013-12-12 09:33:59 +01:00
2013-12-17 10:25:34 +01:00
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
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;
this->protocol[5].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[6].type = Oyster::Network::NetAttributeType_Bool;
2013-12-09 11:57:34 +01:00
}
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;
this->protocol[3].value = bTurnLeft;
this->protocol[4].value = bTurnRight;
this->protocol[5].value = bStrafeRight;
this->protocol[6].value = bStrafeRight;
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
};
struct Protocol_PlayerPosition :public Oyster::Network::CustomProtocolObject
{
float position[3];
// look at dir
Protocol_PlayerPosition()
{
2013-12-16 10:02:30 +01:00
this->protocol[0].value = protocol_Gamplay_PlayerPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
}
Oyster::Network::CustomNetProtocol* GetProtocol() override
{
this->protocol[1].value = position[0];
this->protocol[2].value = position[1];
this->protocol[3].value = position[2];
return &protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
2013-12-09 11:57:34 +01:00
}
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H