mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Added original SDK code for Alien Swarm.
This commit is contained in:
95
game/server/scratchpad_gamedll_helpers.cpp
Normal file
95
game/server/scratchpad_gamedll_helpers.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
#include "scratchpad_gamedll_helpers.h"
|
||||
#include "iscratchpad3d.h"
|
||||
#include "player.h"
|
||||
#include "collisionproperty.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
void ScratchPad_DrawWorldToScratchPad(
|
||||
IScratchPad3D *pPad,
|
||||
unsigned long flags )
|
||||
{
|
||||
pPad->SetRenderState( IScratchPad3D::RS_FillMode, IScratchPad3D::FillMode_Wireframe );
|
||||
|
||||
if ( flags & SPDRAWWORLD_DRAW_WORLD )
|
||||
{
|
||||
engine->DrawMapToScratchPad( pPad, 0 );
|
||||
}
|
||||
|
||||
if ( flags & (SPDRAWWORLD_DRAW_PLAYERS | SPDRAWWORLD_DRAW_ENTITIES) )
|
||||
{
|
||||
CBaseEntity *pCur = gEntList.FirstEnt();
|
||||
while ( pCur )
|
||||
{
|
||||
bool bPlayer = ( dynamic_cast< CBasePlayer* >( pCur ) != 0 );
|
||||
if ( (bPlayer && !( flags & SPDRAWWORLD_DRAW_PLAYERS )) ||
|
||||
(!bPlayer && !( flags & SPDRAWWORLD_DRAW_ENTITIES )) )
|
||||
{
|
||||
pCur = gEntList.NextEnt( pCur );
|
||||
continue;
|
||||
}
|
||||
|
||||
ScratchPad_DrawEntityToScratchPad(
|
||||
pPad,
|
||||
flags,
|
||||
pCur,
|
||||
bPlayer ? Vector( 1.0, 0.5, 0 ) : Vector( 0.3, 0.3, 1.0 )
|
||||
);
|
||||
|
||||
pCur = gEntList.NextEnt( pCur );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ScratchPad_DrawEntityToScratchPad(
|
||||
IScratchPad3D *pPad,
|
||||
unsigned long flags,
|
||||
CBaseEntity *pEnt,
|
||||
const Vector &vColor )
|
||||
{
|
||||
// Draw the entity's bbox [todo: draw OBBs here too].
|
||||
Vector mins, maxs;
|
||||
pEnt->CollisionProp()->WorldSpaceAABB( &mins, &maxs );
|
||||
|
||||
pPad->DrawWireframeBox( mins, maxs, vColor );
|
||||
|
||||
// Draw the edict's index or class?
|
||||
char str[512];
|
||||
str[0] = 0;
|
||||
if ( flags & SPDRAWWORLD_DRAW_EDICT_INDICES )
|
||||
{
|
||||
char tempStr[512];
|
||||
Q_snprintf( tempStr, sizeof( tempStr ), "edict: %d", pEnt->entindex() );
|
||||
Q_strncat( str, tempStr, sizeof( str ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
|
||||
if ( flags & SPDRAWWORLD_DRAW_ENTITY_CLASSNAMES )
|
||||
{
|
||||
if ( str[0] != 0 )
|
||||
Q_strncat( str, ", ", sizeof( str ), COPY_ALL_CHARACTERS );
|
||||
|
||||
char tempStr[512];
|
||||
Q_snprintf( tempStr, sizeof( tempStr ), "class: %s", pEnt->GetClassname() );
|
||||
Q_strncat( str, tempStr, sizeof( str ), COPY_ALL_CHARACTERS );
|
||||
}
|
||||
|
||||
if ( str[0] != 0 )
|
||||
{
|
||||
CTextParams params;
|
||||
params.m_vPos = (mins + maxs) * 0.5f;
|
||||
params.m_bCentered = true;
|
||||
params.m_flLetterWidth = 2;
|
||||
pPad->DrawText( str, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user