added main menus, improved shading

This commit is contained in:
2025-07-18 20:37:52 +03:00
parent dddf1b5881
commit 070c3ff309
45 changed files with 859 additions and 271 deletions

View File

@@ -24,7 +24,8 @@ public:
virtual void Destroy( void ) override;
virtual void ReadParameter( const char *szName, const char *szValue ) override;
virtual void Think( float fDelta ) override;
virtual void Sync( void *pData, uint32_t nDataSize ) override;
virtual void SendToServer() override;
virtual void RecieveFromServer( void *pData, uint32_t nDataSize ) override;
void Accelerate( void );
void AirAccelerate( void );
@@ -156,6 +157,16 @@ void CMOBAPlayer::PlayerMove( void )
CategorizePosition();
}
struct PlayerMovement_t: public PacketPlayer_t
{
bool bIsForward;
bool bIsBack;
bool bIsLeft;
bool bIsRight;
float fPitch;
float fYaw;
};
void CMOBAPlayer::Think( float fDelta )
{
if (INetworking::IsClient())
@@ -173,50 +184,39 @@ void CMOBAPlayer::Think( float fDelta )
PlayerMove();
};
void CMOBAPlayer::Sync( void *pData, uint32_t nDataSize )
void CMOBAPlayer::SendToServer()
{
struct PlayerMovement_t: public PacketPlayer_t
{
bool bIsForward;
bool bIsBack;
bool bIsLeft;
bool bIsRight;
float fPitch;
float fYaw;
PlayerMovement_t movement = {
.bIsForward = bIsForward,
.bIsBack = bIsBack,
.bIsLeft = bIsLeft,
.bIsRight = bIsRight,
.fPitch = fPitch,
.fYaw = fYaw,
};
// Send data
if ( pData == NULL )
movement.type = PACKET_TYPE_PLAYER_MOVEMENT;
if (INetworking::IsClient())
{
PlayerMovement_t movement = {
.bIsForward = bIsForward,
.bIsBack = bIsBack,
.bIsLeft = bIsLeft,
.bIsRight = bIsRight,
.fPitch = fPitch,
.fYaw = fYaw,
};
movement.type = PACKET_TYPE_PLAYER_MOVEMENT;
if (INetworking::IsClient())
if (g_localClient->pBasePlayer != this)
return;
INetworking::SendData(&movement, sizeof(PlayerMovement_t), 0, MESSAGE_MODE_RELIABLE);
} else {
for (auto &client: g_clients)
{
if (g_localClient->pBasePlayer != this)
return;
INetworking::SendData(&movement, sizeof(PlayerMovement_t), 0, MESSAGE_MODE_RELIABLE);
} else {
for (auto &client: g_clients)
if (client->pBasePlayer == this)
{
if (client->pBasePlayer == this)
{
movement.playerHandle = client->playerHandle;
break;
}
movement.playerHandle = client->playerHandle;
break;
}
INetworking::SendDataEverybodyExcept(&movement, sizeof(PlayerMovement_t), this, MESSAGE_MODE_RELIABLE);
}
return;
INetworking::SendDataEverybodyExcept(&movement, sizeof(PlayerMovement_t), this, MESSAGE_MODE_RELIABLE);
}
return;
}
void CMOBAPlayer::RecieveFromServer( void *pData, uint32_t nDataSize )
{
Packet_t *pPacket = (Packet_t*)pData;
if (pPacket->type == PACKET_TYPE_PLAYER_MOVEMENT)
{