//----------------------------------------------------------------------------- // Purpose: Records that a player has entered the zone, and updates it's state // according, maybe starting to change team. // Input : *pOther - the entity that left the zone //----------------------------------------------------------------------------- void CControlZone::StartTouch( CBaseEntity *pOther ) { CBaseTFPlayer *pl = ToBaseTFPlayer( pOther ); if ( !pl ) return; CHandle< CBaseTFPlayer > hHandle; hHandle = pl; m_ZonePlayerList.AddToTail( hHandle ); ReevaluateControllingTeam(); // Set this player's current zone to this zone pl->SetCurrentZone( this ); }
//----------------------------------------------------------------------------- // Purpose: Records that a player has left the zone, and updates it's state // according, maybe starting to change team. // Input : *pOther - the entity that left the zone //----------------------------------------------------------------------------- void CControlZone::EndTouch( CBaseEntity *pOther ) { CBaseTFPlayer *pl = ToBaseTFPlayer( pOther ); if ( !pl ) return; CHandle< CBaseTFPlayer > hHandle; hHandle = pl; m_ZonePlayerList.FindAndRemove( hHandle ); ReevaluateControllingTeam(); // Unset this player's current zone if it's this one if ( pl->GetCurrentZone() == this ) pl->SetCurrentZone( NULL ); }