added keybind
This commit is contained in:
0
game/client/baseanimating.cpp
Normal file
0
game/client/baseanimating.cpp
Normal file
0
game/client/baseanimating.h
Normal file
0
game/client/baseanimating.h
Normal file
@@ -16,6 +16,7 @@ DECLARE_BUILD_STAGE(Client)
|
||||
compileProject.m_szName = "client";
|
||||
compileProject.files = {
|
||||
"../shared/game.cpp",
|
||||
"../shared/boneanimation.cpp",
|
||||
|
||||
"game.cpp",
|
||||
"userinput.cpp",
|
||||
@@ -50,16 +51,23 @@ DECLARE_BUILD_STAGE(Client)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
|
||||
ldProject.libraryDirectories.AppendTail(EXTERNAL"steamworks/redistributable_bin/linux64");
|
||||
ldProject.libraries.AppendTail("steam_api");
|
||||
}
|
||||
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
|
||||
ldProject.libraryObjects = {
|
||||
GET_PROJECT_LIBRARY(tier0, "tier0"),
|
||||
};
|
||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
|
||||
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
|
||||
|
||||
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
|
||||
ldProject.libraryObjects.AppendTail(GET_PROJECT_OBJECT(config, "steam_lib"));
|
||||
}
|
||||
|
||||
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)
|
||||
{
|
||||
ldProject.libraryDirectories.AppendTail(EXTERNAL"windows");
|
||||
ldProject.libraries.AppendTail("winpthread-1");
|
||||
ldProject.libraries.AppendTail("ws2_32");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -185,9 +185,6 @@ void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
{
|
||||
case MESSAGE_ENTITY_CLASS_SYNC:
|
||||
|
||||
V_printf("MESSAGE_ENTITY_CLASS_SYNC: %u = %s\n",
|
||||
(uint32_t)pPlayerPacket->m_entityClass.m_uIndex,
|
||||
pPlayerPacket->m_entityClass.m_szEntityName);
|
||||
pEntity = CreateByClassnameWithIndex(
|
||||
(char*)pPlayerPacket->m_entityClass.m_szEntityName,
|
||||
pPlayerPacket->m_entityClass.m_uIndex
|
||||
@@ -226,7 +223,6 @@ void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
}
|
||||
break;
|
||||
case k_EMessage_PlayerSetLocalEntity:
|
||||
V_printf("k_EMessage_PlayerSetLocalEntity: %u\n",(uint32_t)pPlayerPacket->m_setLocalEntity.m_uIndex);
|
||||
if (pPlayerPacket->m_setLocalEntity.m_uIndex > MAX_EDICTS)
|
||||
break;
|
||||
s_pLocalEntity = m_pEntities[pPlayerPacket->m_setLocalEntity.m_uIndex];
|
||||
@@ -235,9 +231,74 @@ void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
}
|
||||
}
|
||||
|
||||
void CEntitySystem::NetSendThink()
|
||||
void CEntitySystem::NetSendThink( INetworkBase *pBase )
|
||||
{
|
||||
C_BaseEntity *pEntity;
|
||||
int i;
|
||||
uint32_t u;
|
||||
uint32_t x;
|
||||
uint32_t uSize;
|
||||
netmap_t *pNetMap;
|
||||
void *pData;
|
||||
union {
|
||||
void *pCurrentData;
|
||||
char *pcCurrentData;
|
||||
EntityDataSync_t *pSync;
|
||||
EntityDataSyncValue_t *pValue;
|
||||
};
|
||||
pEntity = UTIL_GetLocalPlayer();
|
||||
if ( pEntity == NULL )
|
||||
return;
|
||||
|
||||
pNetMap = pEntity->GetSendMap();
|
||||
uSize = sizeof(EntityDataSyncValue_t);
|
||||
x = 0;
|
||||
while ( pNetMap )
|
||||
{
|
||||
for ( u = 0; u < pNetMap->m_uFieldCount; u++ )
|
||||
{
|
||||
x++;
|
||||
uSize += (pNetMap->m_pFields[u].m_uSize+7) & ~7;
|
||||
uSize += sizeof(EntityDataSyncValue_t);
|
||||
}
|
||||
pNetMap = pNetMap->m_pBase;
|
||||
}
|
||||
pData = V_malloc(uSize);
|
||||
V_memset(pData, 0, uSize);
|
||||
pCurrentData = pData;
|
||||
pSync->m_eType = MESSAGE_ENTITY_DATA_SYNC;
|
||||
|
||||
for ( i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
if ( m_pEntities[i] != pEntity )
|
||||
continue;
|
||||
pSync->m_uIndex = i;
|
||||
break;
|
||||
}
|
||||
pSync->m_uCount = x;
|
||||
|
||||
pcCurrentData += sizeof(EntityDataSync_t);
|
||||
pNetMap = pEntity->GetSendMap();
|
||||
x = 0;
|
||||
while ( pNetMap )
|
||||
{
|
||||
for ( u = 0; u < pNetMap->m_uFieldCount; u++ )
|
||||
{
|
||||
pValue->m_uVariableSize = pNetMap->m_pFields[u].m_uSize;
|
||||
pValue->m_uVariableIndex = x;
|
||||
uint32_t uVariableSize;
|
||||
pcCurrentData += sizeof(EntityDataSyncValue_t);
|
||||
V_memcpy(pcCurrentData,
|
||||
pNetMap->m_pFields[u].m_uOffset+(char*)pEntity,
|
||||
pNetMap->m_pFields[u].m_uSize);
|
||||
pcCurrentData += (pNetMap->m_pFields[u].m_uSize+7) & ~7;
|
||||
x++;
|
||||
}
|
||||
pNetMap = pNetMap->m_pBase;
|
||||
}
|
||||
if (pBase)
|
||||
pBase->SendPacket({pData, uSize});
|
||||
V_free(pData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual void Think();
|
||||
|
||||
virtual void NetRecvPacket( NetPacket_t *pPacket );
|
||||
virtual void NetSendThink();
|
||||
virtual void NetSendThink( INetworkBase *pBase );
|
||||
|
||||
virtual C_BaseEntity **GetEntities();
|
||||
private:
|
||||
|
||||
@@ -25,6 +25,7 @@ class CFunnyGameBridge: public IEngineBridge
|
||||
bool m_bIsConnectedToSteamRelay;
|
||||
bool m_bIsConnectedToServer;
|
||||
|
||||
float m_fNetUpdateTimer;
|
||||
};
|
||||
|
||||
|
||||
@@ -151,6 +152,15 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
}
|
||||
|
||||
EntitySystem()->Think();
|
||||
|
||||
float fTickRate = 1.0/60.0;
|
||||
m_fNetUpdateTimer += fDelta;
|
||||
while (m_fNetUpdateTimer >= fTickRate)
|
||||
{
|
||||
m_fNetUpdateTimer-=fTickRate;
|
||||
if (pCurrentServer)
|
||||
EntitySystem()->NetSendThink(pCurrentServer);
|
||||
}
|
||||
g_pWorldRenderer->Frame(fDelta);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,18 +14,20 @@ void C_MOBAPlayer::Spawn()
|
||||
BaseClass::Spawn();
|
||||
SetThink(Think);
|
||||
SetScale(1);
|
||||
vCameraPos = {0,0,-20};
|
||||
};
|
||||
|
||||
void C_MOBAPlayer::Think( float fDelta )
|
||||
{
|
||||
|
||||
C_MOBAPlayer *pEntity = (C_MOBAPlayer*)UTIL_GetLocalPlayer();
|
||||
|
||||
|
||||
m_vMovementVector.x = m_bIsForward - m_bIsBack;
|
||||
|
||||
if (pEntity == this)
|
||||
{
|
||||
Vector vCameraPos = GetAbsOrigin();
|
||||
vCameraPos.z += -20;
|
||||
g_pWorldRenderer->SetCameraPosition(vCameraPos);
|
||||
|
||||
}
|
||||
BaseClass::Think(fDelta);
|
||||
};
|
||||
@@ -37,16 +39,48 @@ END_DATADESC()
|
||||
|
||||
IMPLEMENT_RECV_DT(C_MOBAPlayer)
|
||||
END_RECV_DT()
|
||||
IMPLEMENT_EMPTY_SEND_DT(C_MOBAPlayer)
|
||||
|
||||
IMPLEMENT_SEND_DT(C_MOBAPlayer)
|
||||
NetPropFloat3(m_vMovementVector),
|
||||
END_SEND_DT()
|
||||
|
||||
|
||||
static void IN_ForwardDown( int c, char **v ) {
|
||||
V_printf("+forward\n");
|
||||
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
((C_MOBAPlayer*)pPlayer)->m_bIsForward = true;
|
||||
}
|
||||
static ConCommand startforward("+forward", IN_ForwardDown);
|
||||
|
||||
static void IN_ForwardUp( int c, char **v ) {
|
||||
V_printf("-forward\n");
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
((C_MOBAPlayer*)pPlayer)->m_bIsForward = false;
|
||||
}
|
||||
static ConCommand endforward("-forward", IN_ForwardUp);
|
||||
|
||||
static void IN_BackDown( int c, char **v ) {
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
((C_MOBAPlayer*)pPlayer)->m_bIsBack = true;
|
||||
}
|
||||
static ConCommand startback("+back", IN_BackDown);
|
||||
|
||||
static void IN_BackUp( int c, char **v ) {
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
((C_MOBAPlayer*)pPlayer)->m_bIsBack = false;
|
||||
}
|
||||
static ConCommand endback("-back", IN_BackUp);
|
||||
|
||||
@@ -15,9 +15,18 @@ public:
|
||||
virtual void Spawn( void ) override;
|
||||
void Think( float fDelta );
|
||||
|
||||
bool m_bIsForward = 0;
|
||||
bool m_bIsBack = 0;
|
||||
bool m_bIsLeft = 0;
|
||||
bool m_bIsRight = 0;
|
||||
|
||||
int m_bIsShooting;
|
||||
float m_fFBWalkingDirection;
|
||||
float m_fLRWalkingDirection;
|
||||
|
||||
Vector m_vMovementVector;
|
||||
Vector m_vLocalMovementVector;
|
||||
Vector vCameraPos;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user