android port
This commit is contained in:
+28
-28
@@ -13,7 +13,7 @@
|
||||
#define MAX_FONT_COUNT 128
|
||||
|
||||
template<typename T, uint32_t nCount>
|
||||
class CAssetArc
|
||||
class C_AssetArc
|
||||
{
|
||||
struct ObjectHandle_t
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CAssetManager: public IAssetManager
|
||||
class C_AssetManager: public IAssetManager
|
||||
{
|
||||
public:
|
||||
virtual HFunnyModel LoadModel( const char *szName ) override;
|
||||
@@ -105,37 +105,37 @@ public:
|
||||
|
||||
void LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj );
|
||||
|
||||
CAssetArc<FunnyModel_t, MAX_MODEL_COUNT> m_models = {};
|
||||
CAssetArc<FunnyMesh_t, MAX_MESH_COUNT> m_meshes = {};
|
||||
CAssetArc<FunnyMaterial_t, MAX_MATERIAL_COUNT> m_materials = {};
|
||||
CAssetArc<FunnyTexture_t, MAX_TEXTURE_COUNT> m_textures = {};
|
||||
CAssetArc<IShader*, MAX_SHADER_COUNT> m_shaders = {};
|
||||
CAssetArc<FunnyPhysics_t, MAX_PHYSICS_COUNT> m_physics = {};
|
||||
C_AssetArc<FunnyModel_t, MAX_MODEL_COUNT> m_models = {};
|
||||
C_AssetArc<FunnyMesh_t, MAX_MESH_COUNT> m_meshes = {};
|
||||
C_AssetArc<FunnyMaterial_t, MAX_MATERIAL_COUNT> m_materials = {};
|
||||
C_AssetArc<FunnyTexture_t, MAX_TEXTURE_COUNT> m_textures = {};
|
||||
C_AssetArc<IShader*, MAX_SHADER_COUNT> m_shaders = {};
|
||||
C_AssetArc<FunnyPhysics_t, MAX_PHYSICS_COUNT> m_physics = {};
|
||||
|
||||
};
|
||||
|
||||
FunnyModel_t *CAssetManager::GetModelByIndex( uint32_t uIndex )
|
||||
FunnyModel_t *C_AssetManager::GetModelByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_models.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
FunnyMaterial_t *CAssetManager::GetMaterialByIndex( uint32_t uIndex )
|
||||
FunnyMaterial_t *C_AssetManager::GetMaterialByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_materials.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
IShader **CAssetManager::GetShaderByIndex( uint32_t uIndex )
|
||||
IShader **C_AssetManager::GetShaderByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_shaders.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
FunnyMesh_t *CAssetManager::GetMeshByIndex( uint32_t uIndex )
|
||||
FunnyMesh_t *C_AssetManager::GetMeshByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_meshes.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
|
||||
uint32_t CAssetManager::LoadModel( const char *szName )
|
||||
uint32_t C_AssetManager::LoadModel( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyModel hModel = m_models.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -189,12 +189,12 @@ uint32_t CAssetManager::LoadModel( const char *szName )
|
||||
}
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefModel( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefModel( uint32_t uIndex )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj )
|
||||
void C_AssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj )
|
||||
{
|
||||
for ( int i = 0; i < pMaterial->GetDataMap()->m_iNumFields; i++ )
|
||||
{
|
||||
@@ -236,7 +236,7 @@ void CAssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pOb
|
||||
|
||||
}
|
||||
|
||||
uint32_t CAssetManager::LoadMaterial( const char *szName )
|
||||
uint32_t C_AssetManager::LoadMaterial( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyMaterial hMaterial = m_materials.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -288,12 +288,12 @@ uint32_t CAssetManager::LoadMaterial( const char *szName )
|
||||
return hMaterial;
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefMaterial( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefMaterial( uint32_t uIndex )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HFunnyMesh CAssetManager::LoadMesh( const char *szName )
|
||||
HFunnyMesh C_AssetManager::LoadMesh( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyMesh hAsset = m_meshes.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -322,12 +322,12 @@ HFunnyMesh CAssetManager::LoadMesh( const char *szName )
|
||||
return hAsset;
|
||||
|
||||
}
|
||||
void CAssetManager::UnrefMesh( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefMesh( uint32_t uIndex )
|
||||
{
|
||||
m_meshes.UnrefObject(uIndex);
|
||||
}
|
||||
|
||||
uint32_t CAssetManager::LoadShader( const char *szName )
|
||||
uint32_t C_AssetManager::LoadShader( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
uint32_t hShader = m_shaders.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -347,12 +347,12 @@ uint32_t CAssetManager::LoadShader( const char *szName )
|
||||
return hShader;
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefShader( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefShader( uint32_t uIndex )
|
||||
{
|
||||
m_shaders.UnrefObject(uIndex);
|
||||
}
|
||||
|
||||
HFunnyTexture CAssetManager::LoadTexture( const char *szName )
|
||||
HFunnyTexture C_AssetManager::LoadTexture( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
uint32_t hTexture = m_textures.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -372,18 +372,18 @@ HFunnyTexture CAssetManager::LoadTexture( const char *szName )
|
||||
return hTexture;
|
||||
}
|
||||
|
||||
FunnyTexture_t *CAssetManager::GetTextureByIndex( HFunnyTexture hTexture )
|
||||
FunnyTexture_t *C_AssetManager::GetTextureByIndex( HFunnyTexture hTexture )
|
||||
{
|
||||
return m_textures.GetObjectPtr(hTexture);
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefTexture( uint32_t hTexture )
|
||||
void C_AssetManager::UnrefTexture( uint32_t hTexture )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
HFunnyPhysics C_AssetManager::LoadPhysics( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyPhysics hPhysics = m_physics.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -436,12 +436,12 @@ HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
}
|
||||
|
||||
|
||||
FunnyPhysics_t *CAssetManager::GetPhysicsByIndex( HFunnyPhysics hPhysics )
|
||||
FunnyPhysics_t *C_AssetManager::GetPhysicsByIndex( HFunnyPhysics hPhysics )
|
||||
{
|
||||
return m_physics.GetObjectPtr(hPhysics);
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
void C_AssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
{
|
||||
m_physics.UnrefObject(hPhysics);
|
||||
}
|
||||
@@ -449,5 +449,5 @@ void CAssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
|
||||
|
||||
|
||||
static CAssetManager s_assetmgr;
|
||||
static C_AssetManager s_assetmgr;
|
||||
IAssetManager *g_pAssetManager = &s_assetmgr;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
typedef className ThisClass;
|
||||
|
||||
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
||||
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||
static C_EntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||
|
||||
class C_BaseEntity;
|
||||
|
||||
@@ -32,12 +32,12 @@ public:
|
||||
|
||||
|
||||
template<class T>
|
||||
class CEntityFactory : public IEntityFactory
|
||||
class C_EntityFactory : public IEntityFactory
|
||||
{
|
||||
public:
|
||||
CEntityFactory( const char *szClassName )
|
||||
C_EntityFactory( const char *szClassName )
|
||||
{
|
||||
EntitySystem()->RegisterEntityClass(this, szClassName);
|
||||
ClientEntitySystem()->RegisterEntityClass(this, szClassName);
|
||||
};
|
||||
virtual C_BaseEntity *Create() {
|
||||
return new T;
|
||||
|
||||
@@ -25,7 +25,7 @@ void C_BaseModelEntity::Think( float fDelta )
|
||||
void C_BaseModelEntity::SetModel( const char *szName )
|
||||
{
|
||||
V_memset(m_szModel, 0, 256);
|
||||
V_strncpy(m_szModel, szName, 255);
|
||||
V_memcpy(m_szModel, szName, 256);
|
||||
}
|
||||
|
||||
void C_BaseModelEntity::UpdateModel()
|
||||
@@ -33,8 +33,7 @@ void C_BaseModelEntity::UpdateModel()
|
||||
if (!V_strncmp(m_szModel, m_szCurrentModel, 256))
|
||||
return;
|
||||
|
||||
V_memset(m_szCurrentModel, 0, 256);
|
||||
V_strncpy(m_szCurrentModel, m_szModel, 255);
|
||||
V_memcpy(m_szCurrentModel, m_szModel, 256);
|
||||
|
||||
if (m_hModelHandle)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
static C_BaseEntity *s_pLocalEntity;
|
||||
|
||||
C_EntitySystem *EntitySystem()
|
||||
C_EntitySystem *ClientEntitySystem()
|
||||
{
|
||||
static C_EntitySystem s_entitySystem;
|
||||
return &s_entitySystem;
|
||||
@@ -25,7 +25,7 @@ static struct EntityRegistry_t
|
||||
IEntityFactory *m_pFactory;
|
||||
const char *m_szClassName;
|
||||
struct EntityRegistry_t *m_pNext;
|
||||
} *s_pEntitiesRegistry = NULL;
|
||||
} *s_pClientEntitiesRegistry = NULL;
|
||||
|
||||
C_EntitySystem::C_EntitySystem()
|
||||
{
|
||||
@@ -52,9 +52,9 @@ void C_EntitySystem::RegisterEntityClass( IEntityFactory *pEntityFactory, const
|
||||
|
||||
pRegistry = new EntityRegistry_t;
|
||||
pRegistry->m_pFactory = pEntityFactory;
|
||||
pRegistry->m_pNext = s_pEntitiesRegistry;
|
||||
pRegistry->m_pNext = s_pClientEntitiesRegistry;
|
||||
pRegistry->m_szClassName = szClassName;
|
||||
s_pEntitiesRegistry = pRegistry;
|
||||
s_pClientEntitiesRegistry = pRegistry;
|
||||
}
|
||||
|
||||
C_BaseEntity *C_EntitySystem::CreateByClassname( const char *szName )
|
||||
@@ -113,7 +113,7 @@ IEntityFactory *C_EntitySystem::GetFactoryByClassname( const char *szName )
|
||||
{
|
||||
EntityRegistry_t *pEntity;
|
||||
|
||||
for ( pEntity = s_pEntitiesRegistry; pEntity; pEntity = pEntity->m_pNext )
|
||||
for ( pEntity = s_pClientEntitiesRegistry; pEntity; pEntity = pEntity->m_pNext )
|
||||
{
|
||||
if (!strcmp(szName, pEntity->m_szClassName))
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
int m_nEntityCount;
|
||||
};
|
||||
|
||||
C_EntitySystem *EntitySystem();
|
||||
C_EntitySystem *ClientEntitySystem();
|
||||
|
||||
C_BaseEntity *UTIL_GetLocalPlayer();
|
||||
|
||||
|
||||
+15
-16
@@ -15,7 +15,7 @@
|
||||
#include "steam/steam_gameserver.h"
|
||||
#endif
|
||||
|
||||
class CFunnyGameBridge: public IEngineBridge
|
||||
class CClientGameBridge: public IEngineBridge
|
||||
{
|
||||
virtual void Init() override;
|
||||
virtual void Tick( float fDelta ) override;
|
||||
@@ -33,18 +33,18 @@ class CFunnyGameBridge: public IEngineBridge
|
||||
};
|
||||
|
||||
|
||||
IEngineBridge *EngineBridge()
|
||||
IEngineBridge *ClientEngineBridge()
|
||||
{
|
||||
static CFunnyGameBridge s_bridge;
|
||||
static CClientGameBridge s_bridge;
|
||||
return &s_bridge;
|
||||
}
|
||||
|
||||
void XRInputCallback( IXRController *pController, EXRInputType_t eType, const char *szType, EXRInputActionType_t action, EXRInputValue_t value );
|
||||
|
||||
|
||||
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
EXPOSE_INTERFACE_FN(ClientEngineBridge, IClientEngineBridge, CLIENT_ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
|
||||
void CFunnyGameBridge::Init()
|
||||
void CClientGameBridge::Init()
|
||||
{
|
||||
Console()->AddCommand("exec game/core/default.cfg\n");
|
||||
Console()->Execute();
|
||||
@@ -121,12 +121,12 @@ void CFunnyGameBridge::Init()
|
||||
*/
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Tick( float fDelta )
|
||||
void CClientGameBridge::Tick( float fDelta )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CFunnyGameBridge::TryToConnectToServer()
|
||||
void CClientGameBridge::TryToConnectToServer()
|
||||
{
|
||||
#ifdef STEAM
|
||||
if (g_pEngineConstants->m_bIsSteam)
|
||||
@@ -145,10 +145,10 @@ void CFunnyGameBridge::TryToConnectToServer()
|
||||
if (g_pServerConnection)
|
||||
{
|
||||
m_bIsConnectedToServer = true;
|
||||
C_BaseEntity **ppEntities = EntitySystem()->GetEntities();
|
||||
C_BaseEntity **ppEntities = ClientEntitySystem()->GetEntities();
|
||||
for ( int i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
EntitySystem()->DestroyEntityByIndex(i);
|
||||
ClientEntitySystem()->DestroyEntityByIndex(i);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -156,9 +156,8 @@ void CFunnyGameBridge::TryToConnectToServer()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Frame( float fDelta )
|
||||
void CClientGameBridge::Frame( float fDelta )
|
||||
{
|
||||
|
||||
if (g_pMainWindow->GetRenderWidth() != m_pMainViewport->GetWidth())
|
||||
if (g_pMainWindow->GetRenderHeight() != m_pMainViewport->GetHeight())
|
||||
m_pMainViewport->UpdateResolution(g_pMainWindow->GetRenderWidth(), g_pMainWindow->GetRenderHeight());
|
||||
@@ -198,7 +197,7 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
case MESSAGE_ENTITY_CLASS_SYNC:
|
||||
case MESSAGE_ENTITY_DATA_SYNC:
|
||||
case k_EMessage_PlayerSetLocalEntity:
|
||||
EntitySystem()->NetRecvPacket(&packet);
|
||||
ClientEntitySystem()->NetRecvPacket(&packet);
|
||||
pCurrentServer->RecievePacket();
|
||||
break;
|
||||
default:
|
||||
@@ -209,7 +208,7 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
}
|
||||
}
|
||||
|
||||
EntitySystem()->Think();
|
||||
ClientEntitySystem()->Think();
|
||||
|
||||
float fTickRate = 1.0/60.0;
|
||||
m_fNetUpdateTimer += fDelta;
|
||||
@@ -220,19 +219,19 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
m_fNetUpdateTimer-=fTickRate;
|
||||
m_fNetUpdateTimer = fmod(m_fNetUpdateTimer, fTickRate);
|
||||
if (pCurrentServer)
|
||||
EntitySystem()->NetSendThink(pCurrentServer);
|
||||
ClientEntitySystem()->NetSendThink(pCurrentServer);
|
||||
}
|
||||
g_pWorldRenderer->Frame(fDelta);
|
||||
g_pMainWindow->SetOutputImage(m_pMainViewport->GetRenderImage());
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Shutdown()
|
||||
void CClientGameBridge::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
||||
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
void CClientGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
{
|
||||
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
||||
|
||||
@@ -26,8 +26,8 @@ void C_MOBAPlayer::Think( float fDelta )
|
||||
if (pPlayerEntity == this)
|
||||
{
|
||||
}
|
||||
m_pLeftHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntityByIndex(m_leftHandId);
|
||||
m_pRightHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntityByIndex(m_rightHandId);
|
||||
m_pLeftHand = (C_MOBAPlayerHandController*)ClientEntitySystem()->GetEntityByIndex(m_leftHandId);
|
||||
m_pRightHand = (C_MOBAPlayerHandController*)ClientEntitySystem()->GetEntityByIndex(m_rightHandId);
|
||||
BaseClass::Think(fDelta);
|
||||
};
|
||||
|
||||
@@ -157,10 +157,8 @@ void Game_OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fVal
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void C_MOBAPlayerHandController::Precache()
|
||||
{
|
||||
|
||||
m_hNormal = g_pAssetManager->LoadModel("game/core/models/hand.fmdl");
|
||||
m_pNormalModel = g_pAssetManager->GetModelByIndex(m_hNormal);
|
||||
m_hSqueezed = g_pAssetManager->LoadModel("game/core/models/sphere.fmdl");
|
||||
|
||||
@@ -367,7 +367,7 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
||||
v->m_pDepth,
|
||||
LOAD_MODE_CLEAR,
|
||||
STORE_MODE_STORE,
|
||||
{.depth = 0},
|
||||
{.depth = 1},
|
||||
};
|
||||
BeginInfo begin = {};
|
||||
begin.uWidth = uWidth;
|
||||
|
||||
Reference in New Issue
Block a user