Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions src/game/shared/tf/tf_weapon_jar_gas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "func_respawnroom.h"
#endif

ConVar tf_debug_gas( "tf_debug_gas", "0", FCVAR_CHEAT | FCVAR_REPLICATED, "Visualize the gas particles." );

IMPLEMENT_NETWORKCLASS_ALIASED( TFJarGas, DT_TFWeaponJarGas )

Expand Down Expand Up @@ -366,11 +367,19 @@ bool CTFGasManager::ShouldCollide( CBaseEntity *pEnt ) const
if ( pEnt->GetTeamNumber() == GetTeamNumber() )
return false;

if ( PointsCrossRespawnRoomVisualizer( GetInitialPosition(), pEnt->GetAbsOrigin() ) )
return false;
bool bIsBeforeRound = ( TFGameRules()->State_Get() == GR_STATE_PREGAME ||
TFGameRules()->State_Get() == GR_STATE_PREROUND ||
TFGameRules()->InSetup() ||
TFGameRules()->IsInWaitingForPlayers() );

if ( PointInRespawnRoom( pEnt, pEnt->GetAbsOrigin() ) )
return false;
if ( bIsBeforeRound )
{
if ( PointsCrossRespawnRoomVisualizer( GetInitialPosition(), pEnt->GetAbsOrigin() ) )
return false;

if ( PointInRespawnRoom( pEnt, pEnt->GetAbsOrigin() ) )
return false;
}

if ( TFGameRules() && TFGameRules()->IsTruceActive() )
return false;
Expand Down Expand Up @@ -398,6 +407,12 @@ void CTFGasManager::OnCollide( CBaseEntity *pEnt, int iPointIndex )
}
#endif // GAME_DLL

void DebugGas( const Vector& vStart, const Vector& vEnd, const Vector& vMin, const Vector& vMax, const Color& color )
{
NDebugOverlay::Line( vStart, vEnd, 255, 255, 0, false, 0.0f );
NDebugOverlay::SweptBox( vStart, vEnd, vMin, vMax, vec3_angle, color.r(), color.g(), color.b(), color.a(), 0.0f );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand All @@ -424,6 +439,26 @@ void CTFGasManager::Update()
{
bShouldRemove = true;
}

#ifdef GAME_DLL
// in a spawnroom while in a pre-game state?
bool bIsBeforeRound = ( TFGameRules()->State_Get() == GR_STATE_PREGAME ||
TFGameRules()->State_Get() == GR_STATE_PREROUND ||
TFGameRules()->InSetup() ||
TFGameRules()->IsInWaitingForPlayers() );
if ( bIsBeforeRound )
{
if ( PointsCrossRespawnRoomVisualizer( GetInitialPosition(), GetPointVec()[i]->m_vecPosition ) )
{
bShouldRemove = true;
}

if ( PointInRespawnRoom( NULL, GetPointVec()[i]->m_vecPosition ) )
{
bShouldRemove = true;
}
}
#endif

if ( bShouldRemove )
{
Expand Down Expand Up @@ -606,6 +641,23 @@ void CTFGasManager::Update()
}
}
#endif // CLIENT_DLL

if ( tf_debug_gas.GetBool() )
{
#ifdef GAME_DLL
Color color( 0, 0, 255, 100 );
#else
Color color( 255, 0, 0, 100 );
#endif
FOR_EACH_VEC( GetPointVec(), i )
{
float flRadius = GetRadius( GetPointVec()[i] );
Vector vMins = flRadius * Vector(-1, -1, -1);
Vector vMaxs = flRadius * Vector(1, 1, 1);

DebugGas( GetPointVec()[i]->m_vecPrevPosition, GetPointVec()[i]->m_vecPosition, vMins, vMaxs, color );
}
}
}

//-----------------------------------------------------------------------------
Expand Down