GL - added setCollisionfunc to object
This commit is contained in:
parent
446bdd412b
commit
44ba45bcc2
|
@ -14,29 +14,11 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
|
|
||||||
// receiver function for server messages
|
// receiver function for server messages
|
||||||
// parsing protocols and sending it to the gameState
|
// parsing protocols and sending it to the gameState
|
||||||
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
void ParseGamePlayEvent(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if( IsGameplayProtocol(p[protocol_INDEX_ID].value.netShort) )
|
|
||||||
//ParseGameplayEvent(e.protocol, e.gameClient);
|
|
||||||
|
|
||||||
//if( IsGeneralProtocol(p[protocol_INDEX_ID].value.netShort) )
|
|
||||||
//ParseGeneralEvent(e.protocol, e.gameClient);
|
|
||||||
|
|
||||||
int pType = p[0].value.netInt;
|
int pType = p[0].value.netInt;
|
||||||
switch (pType)
|
switch (pType)
|
||||||
{
|
{
|
||||||
case protocol_General_Status:
|
|
||||||
{
|
|
||||||
GameLogic::Protocol_General_Status::States state;
|
|
||||||
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
|
|
||||||
if( state == GameLogic::Protocol_General_Status::States_disconected)
|
|
||||||
{
|
|
||||||
// server disconnected
|
|
||||||
DanBiasGame::Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case protocol_Gameplay_PlayerMovement:
|
case protocol_Gameplay_PlayerMovement:
|
||||||
{
|
{
|
||||||
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
|
||||||
|
@ -51,19 +33,6 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
protocolData = NULL;
|
protocolData = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//case protocol_Gameplay_PlayerPosition:
|
|
||||||
// {
|
|
||||||
// Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
|
|
||||||
// for(int i = 0; i< 3; i++)
|
|
||||||
// {
|
|
||||||
// protocolData->playerPos[i] = p[i].value.netFloat;
|
|
||||||
// }
|
|
||||||
// if(dynamic_cast<Client::GameState*>(gameClientState))
|
|
||||||
// ((Client::GameState*)gameClientState)->Protocol(protocolData);
|
|
||||||
// delete protocolData;
|
|
||||||
// protocolData = NULL;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
{
|
{
|
||||||
|
@ -116,9 +85,34 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void ParseGeneralEvent(Oyster::Network::CustomNetProtocol& p)
|
||||||
|
{
|
||||||
|
int pType = p[0].value.netInt;
|
||||||
|
switch (pType)
|
||||||
|
{
|
||||||
|
|
||||||
|
case protocol_General_Status:
|
||||||
|
{
|
||||||
|
GameLogic::Protocol_General_Status::States state;
|
||||||
|
state = (GameLogic::Protocol_General_Status::States)p[1].value.netShort;
|
||||||
|
if( state == GameLogic::Protocol_General_Status::States_disconected)
|
||||||
|
{
|
||||||
|
// server disconnected
|
||||||
|
DanBiasGame::Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||||
|
{
|
||||||
|
|
||||||
|
if( IsGameplayProtocol(p[protocol_INDEX_ID].value.netShort) )
|
||||||
|
ParseGamePlayEvent(p);
|
||||||
|
|
||||||
|
if( IsGeneralProtocol(p[protocol_INDEX_ID].value.netShort) )
|
||||||
|
ParseGeneralEvent(p);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,40 @@ bool Game::NewFrame()
|
||||||
{
|
{
|
||||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
}
|
}
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
API::Instance().Update();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
API::Instance().Update();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
API::Instance().Update();
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
|
}
|
||||||
|
|
||||||
//gameInstance.onMoveFnc(this->level);
|
//gameInstance.onMoveFnc(this->level);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,16 @@ void Object::EndFrame()
|
||||||
this->getState = this->rigidBody->GetState();
|
this->getState = this->rigidBody->GetState();
|
||||||
this->setState = this->getState;
|
this->setState = this->getState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
|
||||||
|
{
|
||||||
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(collisionFuncBefore));
|
||||||
|
}
|
||||||
|
void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss))
|
||||||
|
{
|
||||||
|
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||||
|
}
|
||||||
|
|
||||||
Oyster::Math::Float3 Object::GetPosition()
|
Oyster::Math::Float3 Object::GetPosition()
|
||||||
{
|
{
|
||||||
Oyster::Physics::ICustomBody::State state;
|
Oyster::Physics::ICustomBody::State state;
|
||||||
|
|
|
@ -37,6 +37,10 @@ namespace GameLogic
|
||||||
|
|
||||||
void BeginFrame();
|
void BeginFrame();
|
||||||
void EndFrame();
|
void EndFrame();
|
||||||
|
|
||||||
|
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
||||||
|
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
||||||
|
|
||||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
|
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
|
||||||
private:
|
private:
|
||||||
OBJECT_TYPE type;
|
OBJECT_TYPE type;
|
||||||
|
|
Loading…
Reference in New Issue