//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_FireSmoke::RemoveClientOnly(void) { ClientThinkList()->RemoveThinkable( GetClientHandle() ); // Remove from the client entity list. ClientEntityList().RemoveEntity( GetClientHandle() ); partition->Remove( PARTITION_CLIENT_SOLID_EDICTS | PARTITION_CLIENT_RESPONSIVE_EDICTS | PARTITION_CLIENT_NON_STATIC_EDICTS, CollisionProp()->GetPartitionHandle() ); RemoveFromLeafSystem(); }
// 与服务器断开连接 bool CNetProc::Close(const char* ip, const int port) { std::string key = format_key(ip, port); CBoostGuard lock(&m_clientLock); if (-1 == GetClientHandle(key)) { return true; } lt_client_disconnect(GetClientHandle(key)); RemoveClient(key); return true; }
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) { SetPosition( a_PosX, a_PosY, a_PosZ ); m_LastGroundHeight = (float)a_PosY; m_World->BroadcastTeleportEntity(*this, GetClientHandle()); m_ClientHandle->SendPlayerMoveLook(); }
void cPlayer::OpenWindow(cWindow * a_Window) { if (a_Window != m_CurrentWindow) { CloseWindow(false); } a_Window->OpenedByPlayer(*this); m_CurrentWindow = a_Window; a_Window->SendWholeWindow(*GetClientHandle()); }
void C_Hairball::Init() { ClientEntityList().AddNonNetworkableEntity( this ); ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_ALWAYS ); AddToLeafSystem( RENDER_GROUP_OPAQUE_ENTITY ); m_pMaterial = materials->FindMaterial( "cable/cable", TEXTURE_GROUP_OTHER ); m_flSitStillTime = 5; }
//----------------------------------------------------------------------------- // Purpose: // Input : updateType - //----------------------------------------------------------------------------- void CWeaponMedigun::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); if ( m_bUpdateHealingTargets ) { UpdateEffects(); m_bUpdateHealingTargets = false; } // Think? if ( m_bHealing ) { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_ALWAYS ); } else { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_NEVER ); m_bPlayingSound = false; StopHealSound( true, false ); // Are they holding the attack button but not healing anyone? Give feedback. if ( IsActiveByLocalPlayer() && GetOwner() && GetOwner()->IsAlive() && m_bAttacking && GetOwner() == C_BasePlayer::GetLocalPlayer() && CanAttack() == true ) { if ( gpGlobals->curtime >= m_flNextBuzzTime ) { CLocalPlayerFilter filter; EmitSound( filter, entindex(), "WeaponMedigun.NoTarget" ); m_flNextBuzzTime = gpGlobals->curtime + 0.5f; // only buzz every so often. } } else { StopHealSound( false, true ); // Stop the "no target" sound. } } ManageChargeEffect(); }
void C_Strider::OnDataChanged( DataUpdateType_t updateType ) { if ( updateType == DATA_UPDATE_CREATED ) { // We need to have our render bounds defined or shadow creation won't work correctly ClientThink(); ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_ALWAYS ); } BaseClass::OnDataChanged( updateType ); m_cannonFX.Update( this, m_vecHitPos ); }
int CNetProc::SendMsg(const char* ip, const int port, const char* msg, const int msg_len, char* reply_data, int& reply_len) { std::string key = format_key(ip, port); CBoostGuard lock(&m_clientLock); int nHandle = GetClientHandle(key); if (-1 == nHandle) { return -1; } return lt_client_send(nHandle, msg, msg_len, reply_data, reply_len); }
void cPlayer::CloseWindow(bool a_CanRefuse) { if (m_CurrentWindow == NULL) { m_CurrentWindow = m_InventoryWindow; return; } if (m_CurrentWindow->ClosedByPlayer(*this, a_CanRefuse) || !a_CanRefuse) { // Close accepted, go back to inventory window (the default): m_CurrentWindow = m_InventoryWindow; } else { // Re-open the window m_CurrentWindow->OpenedByPlayer(*this); m_CurrentWindow->SendWholeWindow(*GetClientHandle()); } }
// 连接服务器 bool CNetProc::Connect(const char* ip, const int port) { std::string key = format_key(ip, port); CBoostGuard lock(&m_clientLock); if (-1 != GetClientHandle(key)) { return true; } int handle = lt_client_connect(ip, port, PROTOCOL_TCP); if (-1 == handle) { return false; } CClient c(ip, port, handle); m_lsClient.push_back(c); return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponMedigun::ClientThink() { C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( !pLocalPlayer ) return; // Don't show it while the player is dead. Ideally, we'd respond to m_bHealing in OnDataChanged, // but it stops sending the weapon when it's holstered, and it gets holstered when the player dies. CTFPlayer *pFiringPlayer = ToTFPlayer( GetOwnerEntity() ); if ( !pFiringPlayer || pFiringPlayer->IsPlayerDead() || pFiringPlayer->IsDormant() ) { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_NEVER ); m_bPlayingSound = false; StopHealSound(); return; } // If the local player is the guy getting healed, let him know // who's healing him, and their charge level. if( m_hHealingTarget != NULL ) { if ( pLocalPlayer == m_hHealingTarget ) { pLocalPlayer->SetHealer( pFiringPlayer, m_flChargeLevel ); } if ( !m_bPlayingSound ) { m_bPlayingSound = true; CLocalPlayerFilter filter; EmitSound( filter, entindex(), "WeaponMedigun.Healing" ); } } if ( m_bOldChargeRelease != m_bChargeRelease ) { m_bOldChargeRelease = m_bChargeRelease; ForceHealingTargetUpdate(); } }