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