mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-20 12:36:05 +08:00
Added most recent version of unmodified HL2 SDK for Episode 1 engine
This commit is contained in:
118
dlls/toolframework_server.cpp
Normal file
118
dlls/toolframework_server.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
#include "igamesystem.h"
|
||||
#include "toolframework/iserverenginetools.h"
|
||||
#include "init_factory.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: This is an autogame system which is used to call back into the engine at appropriate points
|
||||
// so that IToolSystems can get these hooks at the correct time
|
||||
//-----------------------------------------------------------------------------
|
||||
class CToolFrameworkServer : public CAutoGameSystemPerFrame
|
||||
{
|
||||
public:
|
||||
virtual bool Init();
|
||||
// Level init, shutdown
|
||||
virtual void LevelInitPreEntity();
|
||||
// entities are created / spawned / precached here
|
||||
virtual void LevelInitPostEntity();
|
||||
virtual void LevelShutdownPreEntity();
|
||||
// Entities are deleted / released here...
|
||||
virtual void LevelShutdownPostEntity();
|
||||
// Called each frame before entities think
|
||||
virtual void FrameUpdatePreEntityThink();
|
||||
// called after entities think
|
||||
virtual void FrameUpdatePostEntityThink();
|
||||
virtual void PreClientUpdate();
|
||||
private:
|
||||
|
||||
IServerEngineTools *m_pTools;
|
||||
};
|
||||
|
||||
// Singleton
|
||||
static CToolFrameworkServer g_ToolFrameworkServer;
|
||||
|
||||
bool CToolFrameworkServer::Init()
|
||||
{
|
||||
factorylist_t list;
|
||||
FactoryList_Retrieve( list );
|
||||
|
||||
// Latch onto internal interface
|
||||
m_pTools = ( IServerEngineTools * )list.engineFactory( VSERVERENGINETOOLS_INTERFACE_VERSION, NULL );
|
||||
|
||||
if ( !m_pTools && !engine->IsDedicatedServer() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::LevelInitPreEntity()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->LevelInitPreEntityAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::LevelInitPostEntity()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->LevelInitPostEntityAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::LevelShutdownPreEntity()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->LevelShutdownPreEntityAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::LevelShutdownPostEntity()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->LevelShutdownPostEntityAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::FrameUpdatePreEntityThink()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->FrameUpdatePreEntityThinkAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::FrameUpdatePostEntityThink()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->FrameUpdatePostEntityThinkAllTools();
|
||||
}
|
||||
|
||||
void CToolFrameworkServer::PreClientUpdate()
|
||||
{
|
||||
if ( !m_pTools )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_pTools->PreClientUpdateAllTools();
|
||||
}
|
Reference in New Issue
Block a user