2013-12-19 10:22:32 +01:00
|
|
|
#ifndef GAMELOGIC_OBJECT_PROTOCOLS_H
|
|
|
|
#define GAMELOGIC_OBJECT_PROTOCOLS_H
|
2013-12-11 12:14:00 +01:00
|
|
|
|
|
|
|
#include <CustomNetProtocol.h>
|
|
|
|
#include "ProtocolIdentificationID.h"
|
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
{
|
2014-01-21 14:32:42 +01:00
|
|
|
struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
2014-01-31 08:41:08 +01:00
|
|
|
short object_ID;
|
2014-01-21 14:32:42 +01:00
|
|
|
short pickup_ID;
|
|
|
|
|
|
|
|
Protocol_ObjectPickup()
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectPickup;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
|
2014-01-31 08:41:08 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
|
|
|
|
object_ID = -1;
|
|
|
|
pickup_ID = -1;
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectPickup(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
2014-01-31 08:41:08 +01:00
|
|
|
object_ID = p[1].value.netShort;
|
|
|
|
pickup_ID = p[2].value.netShort;
|
2014-01-21 14:32:42 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectPickup(int objectID, short pickupID)
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
|
2014-01-31 08:41:08 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Short;
|
|
|
|
|
|
|
|
object_ID = objectID;
|
|
|
|
pickup_ID = pickupID;
|
|
|
|
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = object_ID;
|
|
|
|
this->protocol[2].value = pickup_ID;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject
|
|
|
|
{
|
|
|
|
int object_ID;
|
|
|
|
float health; //Precentage%
|
|
|
|
|
|
|
|
Protocol_ObjectDamage()
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
|
|
|
|
object_ID = -1;
|
|
|
|
health = 0.0f;
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectDamage(int id, float hp)
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectDamage;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
|
|
|
|
object_ID = id;
|
|
|
|
health = hp;
|
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = object_ID;
|
|
|
|
this->protocol[2].value = health;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
|
2013-12-18 12:18:01 +01:00
|
|
|
{
|
|
|
|
int object_ID;
|
|
|
|
float worldMatrix[16];
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_ObjectPosition()
|
2013-12-18 12:18:01 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 09:52:48 +01:00
|
|
|
|
2013-12-18 12:18:01 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
for (int i = 2; i <= 17; i++)
|
2014-01-07 10:26:09 +01:00
|
|
|
{
|
|
|
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
}
|
2014-01-21 09:52:48 +01:00
|
|
|
object_ID = -1;
|
|
|
|
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2013-12-18 12:18:01 +01:00
|
|
|
}
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_ObjectPosition(float m[16], int id)
|
2014-01-13 12:11:45 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectPosition;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-13 12:11:45 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
for (int i = 2; i <= 17; i++)
|
2014-01-13 12:11:45 +01:00
|
|
|
{
|
|
|
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ID = id;
|
|
|
|
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
|
|
|
|
}
|
2013-12-18 12:18:01 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = object_ID;
|
2014-01-21 09:52:48 +01:00
|
|
|
for (int i = 2; i <= 17; i++)
|
|
|
|
{
|
|
|
|
this->protocol[i].value = worldMatrix[i-2];
|
|
|
|
}
|
2013-12-18 12:18:01 +01:00
|
|
|
return &protocol;
|
2014-01-21 09:52:48 +01:00
|
|
|
}
|
2013-12-18 12:18:01 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject
|
2013-12-11 12:14:00 +01:00
|
|
|
{
|
2013-12-17 10:07:46 +01:00
|
|
|
int object_ID;
|
2013-12-11 12:14:00 +01:00
|
|
|
float worldMatrix[16];
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_ObjectEnable()
|
2013-12-11 12:14:00 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-13 12:02:49 +01:00
|
|
|
|
2013-12-17 10:07:46 +01:00
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
2014-01-07 10:26:09 +01:00
|
|
|
|
|
|
|
for (int i = 2; i <= 17; i++)
|
|
|
|
{
|
|
|
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
}
|
|
|
|
object_ID = -1;
|
|
|
|
memset(&worldMatrix[0], 0, sizeof(float) * 16);
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2013-12-11 12:14:00 +01:00
|
|
|
}
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_ObjectEnable(float m[16], int id)
|
2013-12-19 15:35:49 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-07 10:26:09 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
|
|
|
|
for (int i = 2; i <= 17; i++)
|
2014-01-21 09:52:48 +01:00
|
|
|
{ this->protocol[i].type = Oyster::Network::NetAttributeType_Float; }
|
2014-01-07 10:26:09 +01:00
|
|
|
|
|
|
|
object_ID = id;
|
2013-12-19 15:35:49 +01:00
|
|
|
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
|
|
|
|
}
|
2013-12-13 12:02:49 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
2013-12-11 12:14:00 +01:00
|
|
|
{
|
2013-12-17 10:07:46 +01:00
|
|
|
this->protocol[1].value = object_ID;
|
2014-01-07 10:26:09 +01:00
|
|
|
for (int i = 2; i <= 17; i++)
|
|
|
|
{
|
|
|
|
this->protocol[i].value = worldMatrix[i-2];
|
|
|
|
}
|
2013-12-11 12:14:00 +01:00
|
|
|
return &protocol;
|
2013-12-19 15:35:49 +01:00
|
|
|
}
|
2013-12-11 12:14:00 +01:00
|
|
|
|
|
|
|
private:
|
2013-12-13 12:02:49 +01:00
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
2013-12-11 12:14:00 +01:00
|
|
|
};
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
|
2013-12-18 15:28:47 +01:00
|
|
|
{
|
|
|
|
int object_ID;
|
2014-01-21 09:52:48 +01:00
|
|
|
float timer;
|
2013-12-18 15:28:47 +01:00
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
Protocol_ObjectDisable()
|
2013-12-18 15:28:47 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2013-12-18 15:28:47 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
2014-01-21 09:52:48 +01:00
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
}
|
2014-01-21 14:32:42 +01:00
|
|
|
Protocol_ObjectDisable(int id, float time)
|
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 14:32:42 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
|
|
|
|
object_ID = id;
|
|
|
|
timer = time;
|
|
|
|
}
|
2014-01-21 09:52:48 +01:00
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
this->protocol[1].value = object_ID;
|
|
|
|
this->protocol[2].value = timer;
|
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
|
2014-01-21 09:52:48 +01:00
|
|
|
{
|
|
|
|
int object_ID;
|
2014-01-21 14:32:42 +01:00
|
|
|
char *name;
|
2014-01-21 09:52:48 +01:00
|
|
|
float worldMatrix[16];
|
|
|
|
|
2014-01-21 14:32:42 +01:00
|
|
|
Protocol_ObjectCreate()
|
2014-01-21 09:52:48 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectCreate;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
|
|
|
|
|
|
|
|
for (int i = 3; i <= 18; i++)
|
|
|
|
{
|
|
|
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
}
|
2014-01-29 15:01:14 +01:00
|
|
|
}
|
|
|
|
Protocol_ObjectCreate(Oyster::Network::CustomNetProtocol& p)
|
|
|
|
{
|
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
}
|
2014-01-21 14:32:42 +01:00
|
|
|
Protocol_ObjectCreate(float m[16], int id, char *path)
|
2014-01-21 09:52:48 +01:00
|
|
|
{
|
2014-01-30 14:15:25 +01:00
|
|
|
this->protocol[0].value = protocol_Gameplay_ObjectCreate;
|
|
|
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
|
|
|
this->protocol[2].type = Oyster::Network::NetAttributeType_CharArray;
|
|
|
|
|
|
|
|
for (int i = 3; i <= 18; i++)
|
|
|
|
{
|
|
|
|
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_ID = id;
|
2014-01-21 14:32:42 +01:00
|
|
|
this->name = path;
|
2014-01-21 09:52:48 +01:00
|
|
|
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
|
2013-12-18 15:28:47 +01:00
|
|
|
}
|
|
|
|
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
|
|
|
{
|
|
|
|
|
|
|
|
this->protocol[1].value = object_ID;
|
2014-01-21 14:32:42 +01:00
|
|
|
this->protocol[2].value = name;
|
2014-01-21 09:52:48 +01:00
|
|
|
this->protocol[3].value = worldMatrix[0];
|
|
|
|
this->protocol[4].value = worldMatrix[1];
|
|
|
|
this->protocol[5].value = worldMatrix[2];
|
|
|
|
this->protocol[6].value = worldMatrix[3];
|
|
|
|
this->protocol[7].value = worldMatrix[4];
|
|
|
|
this->protocol[8].value = worldMatrix[5];
|
|
|
|
this->protocol[9].value = worldMatrix[6];
|
|
|
|
this->protocol[10].value = worldMatrix[7];
|
|
|
|
this->protocol[11].value = worldMatrix[8];
|
|
|
|
this->protocol[12].value = worldMatrix[9];
|
|
|
|
this->protocol[13].value = worldMatrix[10];
|
|
|
|
this->protocol[14].value = worldMatrix[11];
|
|
|
|
this->protocol[15].value = worldMatrix[12];
|
|
|
|
this->protocol[16].value = worldMatrix[13];
|
|
|
|
this->protocol[17].value = worldMatrix[14];
|
|
|
|
this->protocol[18].value = worldMatrix[15];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-18 15:28:47 +01:00
|
|
|
return &protocol;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Oyster::Network::CustomNetProtocol protocol;
|
|
|
|
};
|
2013-12-11 12:14:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H
|