Bunch of implementations
This commit is contained in:
parent
a0c9677123
commit
12623d1b16
|
@ -99,9 +99,6 @@ namespace DanBias
|
||||||
data.timer.reset();
|
data.timer.reset();
|
||||||
|
|
||||||
Graphics::API::Update( dt );
|
Graphics::API::Update( dt );
|
||||||
|
|
||||||
if(data.networkClient.IsConnected())
|
|
||||||
data.networkClient.Update();
|
|
||||||
|
|
||||||
data.capFrame += dt;
|
data.capFrame += dt;
|
||||||
if(data.capFrame > 0.03)
|
if(data.capFrame > 0.03)
|
||||||
|
@ -118,6 +115,9 @@ namespace DanBias
|
||||||
data.capFrame = 0;
|
data.capFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data.networkClient.IsConnected())
|
||||||
|
data.networkClient.Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
return DanBiasClientReturn_Success;
|
return DanBiasClientReturn_Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;GameClient_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;GameClient_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;GameClient_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;GameClient_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "C_obj/C_Player.h"
|
#include "C_obj/C_Player.h"
|
||||||
#include "C_obj/C_DynamicObj.h"
|
#include "C_obj/C_DynamicObj.h"
|
||||||
#include "C_obj/C_StaticObj.h"
|
#include "C_obj/C_StaticObj.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
|
@ -15,6 +16,7 @@ using namespace ::Oyster::Network;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
||||||
using namespace ::GameLogic;
|
using namespace ::GameLogic;
|
||||||
using namespace ::Utility::DynamicMemory;
|
using namespace ::Utility::DynamicMemory;
|
||||||
|
using namespace ::Utility::String;
|
||||||
|
|
||||||
struct GameState::MyData
|
struct GameState::MyData
|
||||||
{
|
{
|
||||||
|
@ -40,6 +42,11 @@ struct GameState::MyData
|
||||||
|
|
||||||
} privData;
|
} privData;
|
||||||
|
|
||||||
|
inline Quaternion ArrayToQuaternion( const float source[4] )
|
||||||
|
{
|
||||||
|
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
|
||||||
|
}
|
||||||
|
|
||||||
GameState::GameState()
|
GameState::GameState()
|
||||||
{
|
{
|
||||||
this->privData = nullptr;
|
this->privData = nullptr;
|
||||||
|
@ -75,21 +82,33 @@ bool GameState::Init( SharedStateContent &shared )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::InitiatePlayer( int id, std::wstring modelName, Float4x4 world )
|
void GameState::InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3], bool isMyPlayer )
|
||||||
{
|
{
|
||||||
this->privData->myId = id;
|
|
||||||
|
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.position = Float3(world[12], world[13], world[14]);
|
modelData.position = position;
|
||||||
modelData.rotation = Quaternion(Float3(0,0,0), 1);
|
modelData.rotation = ArrayToQuaternion( rotation );
|
||||||
modelData.scale = Float3(1,1,1);
|
modelData.scale = scale;
|
||||||
modelData.modelPath = modelName;
|
StringToWstring( modelName, modelData.modelPath );
|
||||||
modelData.id = this->privData->myId;
|
modelData.id = id;
|
||||||
this->privData->player.Init( modelData );
|
|
||||||
|
|
||||||
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
if( isMyPlayer )
|
||||||
this->privData->camera.UpdateOrientation();
|
{
|
||||||
|
if( this->privData->player.Init(modelData) )
|
||||||
|
{
|
||||||
|
this->privData->myId = id;
|
||||||
|
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
||||||
|
this->privData->camera.UpdateOrientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
C_DynamicObj *p = new C_DynamicObj();
|
||||||
|
if( p->Init(modelData) )
|
||||||
|
{
|
||||||
|
(*this->privData->dynamicObjects)[id] = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState GameState::Update( float deltaTime )
|
GameClientState::ClientState GameState::Update( float deltaTime )
|
||||||
|
@ -359,7 +378,12 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case protocol_Gameplay_ObjectCreatePlayer: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectCreatePlayer:
|
||||||
|
{
|
||||||
|
Protocol_ObjectCreatePlayer decoded(data);
|
||||||
|
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotation, decoded.scale, decoded.owner );
|
||||||
|
}
|
||||||
|
break;
|
||||||
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
||||||
|
|
|
@ -20,9 +20,8 @@ namespace DanBias { namespace Client
|
||||||
~GameState(void);
|
~GameState(void);
|
||||||
bool Init( SharedStateContent &shared );
|
bool Init( SharedStateContent &shared );
|
||||||
GameClientState::ClientState Update( float deltaTime ) override;
|
GameClientState::ClientState Update( float deltaTime ) override;
|
||||||
void InitiatePlayer( int id, std::wstring modelName, Oyster::Math::Float4x4 world );
|
void InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3] );
|
||||||
void ReadKeyInput();
|
void ReadKeyInput();
|
||||||
|
|
||||||
bool Render()override;
|
bool Render()override;
|
||||||
bool Release()override;
|
bool Release()override;
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct NetLoadState::MyData
|
||||||
bool loading;
|
bool loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Quaternion ArrayToQuaternion( float source[4] )
|
inline Quaternion ArrayToQuaternion( const float source[4] )
|
||||||
{
|
{
|
||||||
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
|
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientE
|
||||||
{
|
{
|
||||||
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
|
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
|
||||||
this->ChangeState( ClientState_Game );
|
this->ChangeState( ClientState_Game );
|
||||||
|
this->privData->loading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,18 +110,20 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
LevelLoader loader;
|
LevelLoader loader;
|
||||||
auto objects = loader.LoadLevel( fileName );
|
auto objects = loader.LoadLevel( fileName );
|
||||||
auto object = objects.begin();
|
auto object = objects.begin();
|
||||||
ObjectHeader *oh;
|
ObjectTypeHeader *oth;
|
||||||
|
|
||||||
int objectID = 100; // first 100 is reserved for players. This is how the server does it.
|
int objectID = 100; // first 100 is reserved for players. This is how the server does it.
|
||||||
|
|
||||||
for( ; object != objects.end(); ++object )
|
for( ; object != objects.end(); ++object )
|
||||||
{
|
{
|
||||||
++objectID;
|
++objectID;
|
||||||
oh = (ObjectHeader*)&*object;
|
oth = (ObjectTypeHeader*)(*object._Ptr);
|
||||||
switch( oh->typeID )
|
switch( oth->typeID )
|
||||||
{
|
{
|
||||||
case ObjectType::ObjectType_Static:
|
case ObjectType::ObjectType_Static:
|
||||||
{
|
{
|
||||||
|
ObjectHeader *oh = (ObjectHeader*)oth;
|
||||||
|
|
||||||
ModelInitData desc;
|
ModelInitData desc;
|
||||||
desc.id = objectID;
|
desc.id = objectID;
|
||||||
StringToWstring( oh->ModelFile, desc.modelPath );
|
StringToWstring( oh->ModelFile, desc.modelPath );
|
||||||
|
@ -142,6 +145,8 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
break;
|
break;
|
||||||
case ObjectType::ObjectType_Dynamic:
|
case ObjectType::ObjectType_Dynamic:
|
||||||
{
|
{
|
||||||
|
ObjectHeader *oh = (ObjectHeader*)oth;
|
||||||
|
|
||||||
ModelInitData desc;
|
ModelInitData desc;
|
||||||
desc.id = objectID;
|
desc.id = objectID;
|
||||||
StringToWstring( oh->ModelFile, desc.modelPath );
|
StringToWstring( oh->ModelFile, desc.modelPath );
|
||||||
|
|
Loading…
Reference in New Issue