void CBaseAnimatingOverlay::SetNumAnimOverlays( int num ) { if ( m_AnimOverlay.Count() < num ) { m_AnimOverlay.AddMultipleToTail( num - m_AnimOverlay.Count() ); NetworkStateChanged(); } else if ( m_AnimOverlay.Count() > num ) { m_AnimOverlay.RemoveMultiple( num, m_AnimOverlay.Count() - num ); NetworkStateChanged(); } }
MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model, QAction* leave_room, QAction* show_room) : QWidget(parent), game_list_model(game_list_model), leave_room(leave_room), show_room(show_room) { if (auto member = Network::GetRoomMember().lock()) { // register the network structs to use in slots and signals state_callback_handle = member->BindOnStateChanged( [this](const Network::RoomMember::State& state) { emit NetworkStateChanged(state); }); connect(this, &MultiplayerState::NetworkStateChanged, this, &MultiplayerState::OnNetworkStateChanged); } qRegisterMetaType<Network::RoomMember::State>(); qRegisterMetaType<Common::WebResult>(); announce_multiplayer_session = std::make_shared<Core::AnnounceMultiplayerSession>(); announce_multiplayer_session->BindErrorCallback( [this](const Common::WebResult& result) { emit AnnounceFailed(result); }); connect(this, &MultiplayerState::AnnounceFailed, this, &MultiplayerState::OnAnnounceFailed); status_text = new ClickableLabel(this); status_icon = new ClickableLabel(this); status_text->setToolTip(tr("Current connection status")); status_text->setText(tr("Not Connected. Click here to find a room!")); status_icon->setPixmap(QIcon::fromTheme("disconnected").pixmap(16)); connect(status_text, &ClickableLabel::clicked, this, &MultiplayerState::OnOpenNetworkRoom); connect(status_icon, &ClickableLabel::clicked, this, &MultiplayerState::OnOpenNetworkRoom); }
void CRagdollProp::FadeOutThink(void) { float dt = gpGlobals->curtime - m_flFadeOutStartTime; if ( dt < 0 ) { SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + 0.1, s_pFadeOutContext ); } else if ( dt < m_flFadeTime ) { float alpha = 1.0f - dt / m_flFadeTime; int nFade = (int)(alpha * 255.0f); m_nRenderMode = kRenderTransTexture; SetRenderColorA( nFade ); NetworkStateChanged(); SetContextThink( &CRagdollProp::FadeOutThink, gpGlobals->curtime + TICK_INTERVAL, s_pFadeOutContext ); } else { // Necessary to cause it to do the appropriate death cleanup // Yeah, the player may have nothing to do with it, but // passing NULL to TakeDamage causes bad things to happen CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); CTakeDamageInfo info( pPlayer, pPlayer, 10000.0, DMG_GENERIC ); TakeDamage( info ); UTIL_Remove( this ); } }
void CNPC_HL1Barney::SUB_LVFadeOut( void ) { if( VPhysicsGetObject() ) { if( VPhysicsGetObject()->GetGameFlags() & FVPHYSICS_PLAYER_HELD || GetEFlags() & EFL_IS_BEING_LIFTED_BY_BARNACLE ) { // Try again in a few seconds. SetNextThink( gpGlobals->curtime + 5 ); SetRenderColorA( 255 ); return; } } float dt = gpGlobals->frametime; if ( dt > 0.1f ) { dt = 0.1f; } m_nRenderMode = kRenderTransTexture; int speed = max(3,256*dt); // fade out over 3 seconds SetRenderColorA( UTIL_Approach( 0, m_clrRender->a, speed ) ); NetworkStateChanged(); if ( m_clrRender->a == 0 ) { UTIL_Remove(this); } else { SetNextThink( gpGlobals->curtime ); } }
//----------------------------------------------------------------------------- // Purpose: Attach the player to the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::AttachPlayer( CBaseTFPlayer *pPlayer ) { // Player shouldn't already be attached. Assert( !IsPlayerAttached( pPlayer ) ); // Check to see if the player is alive and on the correct team. if ( !pPlayer->IsAlive() || !pPlayer->InSameTeam( this ) ) return; // Check attachment availability. if ( m_nPlayerCount == BUFF_STATION_MAX_PLAYERS ) { // Unless the player is the owner he cannot connect. if ( pPlayer != GetOwner() ) return; // Kick a non-owning player off. DetachPlayerByIndex( BUFF_STATION_MAX_PLAYERS - 1 ); } // This will disconnect the player from other Buff Stations, and keep track of important player events. g_pNotify->ReportNamedEvent( pPlayer, "PlayerAttachedToGenerator" ); g_pNotify->AddEntity( this, pPlayer ); // Connect player. // Find the nearest empty slot int iNearest = BUFF_STATION_MAX_PLAYERS; float flNearestDist = 9999*9999; for ( int iPlayer = 0; iPlayer < BUFF_STATION_MAX_PLAYERS; iPlayer++ ) { if ( !m_hPlayers[iPlayer] ) { Vector vecPoint; QAngle angPoint; GetAttachment( m_aPlayerAttachInfo[iPlayer].m_iAttachPoint, vecPoint, angPoint ); float flDistance = ( vecPoint - pPlayer->GetAbsOrigin() ).LengthSqr(); if ( flDistance < flNearestDist ) { flNearestDist = flDistance; iNearest = iPlayer; } } } Assert( iNearest != BUFF_STATION_MAX_PLAYERS ); m_hPlayers.Set( iNearest, pPlayer ); m_aPlayerAttachInfo[iNearest].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() ); m_aPlayerAttachInfo[iNearest].m_hRope = CreateRope( pPlayer, m_aPlayerAttachInfo[iNearest].m_iAttachPoint ); m_nPlayerCount++; // Tell the player to constrain his movement. pPlayer->ActivateMovementConstraint( this, GetAbsOrigin(), obj_buff_station_range.GetFloat(), 75.0f, 0.15f ); // Update think. if ( GetNextThink(BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL ) SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_PLAYER_THINK_INTERVAL, BUFF_STATION_BOOST_PLAYER_THINK_CONTEXT ); // Update network state. NetworkStateChanged(); }
void CSun::InputTurnOn( inputdata_t &inputdata ) { if( !m_bOn ) { m_bOn = true; NetworkStateChanged(); } }
void CSun::InputTurnOff( inputdata_t &inputdata ) { if( m_bOn ) { m_bOn = false; NetworkStateChanged(); } }
void CFunc_Dust::InputTurnOff( inputdata_t &inputdata ) { if( m_DustFlags & DUSTFLAGS_ON ) { m_DustFlags &= ~DUSTFLAGS_ON; NetworkStateChanged(); } }
void CFunc_Dust::Spawn() { // Bind to our bmodel. SetModel( STRING( GetModelName() ) ); // Use manual mode. NetworkStateManualMode( true ); NetworkStateChanged(); BaseClass::Spawn(); }
//----------------------------------------------------------------------------- // Purpose: Return to our original facing after a while //----------------------------------------------------------------------------- void CObjectBaseMannedGun::BaseMannedGunThink( void ) { // If someone's got in the gun, stop moving if ( GetDriverPlayer() ) return; // Otherwise, move back towards the initial state if ( m_flGunPitch ) { float flPitch = anglemod( m_flGunPitch ); if (( flPitch <= 180 ) && ( flPitch >= 0 )) { m_flGunPitch = max( 0, flPitch - (gpGlobals->frametime * MANNEDGUN_RESTORE_TURN_RATE) ); } else { m_flGunPitch = flPitch + (gpGlobals->frametime * MANNEDGUN_RESTORE_TURN_RATE); if ( m_flGunPitch >= 360 ) { m_flGunPitch = 0; } } } else if ( m_flGunYaw ) { if ( m_flGunYaw > 180 ) { m_flGunYaw = m_flGunYaw + (gpGlobals->frametime * MANNEDGUN_RESTORE_TURN_RATE); if ( m_flGunYaw >= 360 ) { m_flGunYaw = 0; } } else { m_flGunYaw = max( 0, m_flGunYaw - (gpGlobals->frametime * MANNEDGUN_RESTORE_TURN_RATE) ); } } else { // We're done return; } // Keep thinking SetContextThink( BaseMannedGunThink, gpGlobals->curtime + 0.1, OBJ_BASE_MANNEDGUN_THINK_CONTEXT ); NetworkStateChanged(); }
void CSun::Activate() { BaseClass::Activate(); // Find our target. CBaseEntity *pEnt = gEntList.FindEntityByName( 0, m_target, NULL ); if( pEnt ) { Vector vDirection = GetAbsOrigin() - pEnt->GetAbsOrigin(); VectorNormalize( vDirection ); m_vDirection = vDirection; } NetworkStateChanged(); }
// Update the visible representation of the physic system's representation of this object void CPhysBox::VPhysicsUpdate( IPhysicsObject *pPhysics ) { NetworkStateChanged(); BaseClass::VPhysicsUpdate( pPhysics ); // if this is the first time we have moved, fire our target if ( HasSpawnFlags( SF_PHYSBOX_ASLEEP ) ) { if ( !pPhysics->IsAsleep() ) { m_OnAwakened.FireOutput(this, this); FireTargets( STRING(m_target), this, this, USE_TOGGLE, 0 ); m_spawnflags &= ~SF_PHYSBOX_ASLEEP; } } }
//----------------------------------------------------------------------------- // Purpose: Get and set the current driver. //----------------------------------------------------------------------------- void CBaseTFVehicle::SetPassenger( int nRole, CBasePlayer *pEnt ) { Assert( !pEnt || pEnt->IsPlayer() ); Assert( nRole >= 0 && nRole < m_nMaxPassengers ); Assert( !m_hPassengers[nRole].Get() || !pEnt ); m_hPassengers.Set( nRole, dynamic_cast<CBaseTFPlayer*>(pEnt) ); NetworkStateChanged( ); // If the vehicle's deteriorating, I get to own it now if ( IsDeteriorating() ) { StopDeteriorating(); SetBuilder( (CBaseTFPlayer*)pEnt, true ); } ResetDeteriorationTime(); }
void C_WeaponPortalgun::ClientThink( void ) { CPortal_Player *pPlayer = ToPortalPlayer( GetOwner() ); if ( pPlayer && dynamic_cast<C_WeaponPortalgun*>( pPlayer->GetActiveWeapon() ) ) { if ( m_EffectState == EFFECT_NONE ) { //DoEffect( ( GetPlayerHeldEntity( pPlayer ) ) ? ( EFFECT_HOLDING ) : ( EFFECT_READY ) ); } if ( m_EffectState != EFFECT_NONE ) { // Showing a special color for holding is confusing... just use the last fired color -Jeep //if ( m_bOpenProngs ) //{ // //Turn on the grav light // m_Parameters[PORTALGUN_GRAVLIGHT].SetVisibleViewModel(); // m_Parameters[PORTALGUN_GRAVLIGHT_WORLD].SetVisible3rdPerson(); // m_Parameters[PORTALGUN_PORTAL1LIGHT].SetVisibleViewModel( false ); // m_Parameters[PORTALGUN_PORTAL1LIGHT_WORLD].SetVisible3rdPerson( false ); // m_Parameters[PORTALGUN_PORTAL2LIGHT].SetVisibleViewModel( false ); // m_Parameters[PORTALGUN_PORTAL2LIGHT_WORLD].SetVisible3rdPerson( false ); //} //else { m_Parameters[PORTALGUN_GRAVLIGHT].SetVisibleViewModel( false ); m_Parameters[PORTALGUN_GRAVLIGHT_WORLD].SetVisible3rdPerson( false ); //Turn on and off the correct fired last lights m_Parameters[PORTALGUN_PORTAL1LIGHT].SetVisibleViewModel( m_iLastFiredPortal == 1 ); m_Parameters[PORTALGUN_PORTAL1LIGHT_WORLD].SetVisible3rdPerson( m_iLastFiredPortal == 1 ); m_Parameters[PORTALGUN_PORTAL2LIGHT].SetVisibleViewModel( m_iLastFiredPortal == 2 ); m_Parameters[PORTALGUN_PORTAL2LIGHT_WORLD].SetVisible3rdPerson( m_iLastFiredPortal == 2 ); } } } // Update our effects DoEffectIdle(); NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: Attach the object to the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::AttachObject( CBaseObject *pObject, bool bPlacing ) { // Check to see if the object is already attached. if ( IsObjectAttached( pObject ) ) return; // Check to see if the object is on the correct team. if ( !pObject->InSameTeam( this ) ) return; // Check to see if the object is already being buffed by another station. if ( pObject->IsHookedAndBuffed() ) return; // Check attachment availability. if ( m_nObjectCount == BUFF_STATION_MAX_OBJECTS ) return; // Attach cable to object - get the attachment point. int nObjectAttachPoint = pObject->LookupAttachment( "boostpoint" ); if ( nObjectAttachPoint <= 0 ) nObjectAttachPoint = 1; // Connect object. m_hObjects.Set( m_nObjectCount, pObject ); m_aObjectAttachInfo[m_nObjectCount].m_DamageModifier.SetModifier( obj_buff_station_damage_modifier.GetFloat() ); m_aObjectAttachInfo[m_nObjectCount].m_hRope = CreateRope( pObject, m_aObjectAttachInfo[m_nObjectCount].m_iAttachPoint, nObjectAttachPoint ); m_nObjectCount += 1; // If we're placing, we're pretending to buff objects, but not really powering them pObject->SetBuffStation( this, bPlacing ); // Update think. if ( GetNextThink(BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT) > gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL ) SetNextThink( gpGlobals->curtime + BUFF_STATION_BOOST_OBJECT_THINK_INTERVAL, BUFF_STATION_BOOST_OBJECT_THINK_CONTEXT ); // Update network state. NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CObjectBaseMannedGun::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) { BaseClass::FinishMove( player, ucmd, move ); CTFMoveData *pMoveData = (CTFMoveData*)move; Assert( sizeof(MannedPlasmagunData_t) <= pMoveData->VehicleDataMaxSize() ); MannedPlasmagunData_t *pVehicleData = (MannedPlasmagunData_t*)pMoveData->VehicleData(); m_flGunYaw = pVehicleData->m_flGunYaw; m_flGunPitch = pVehicleData->m_flGunPitch; m_flBarrelPitch = pVehicleData->m_flBarrelPitch; // Set the bone state.. SetBoneController( 0, m_flGunYaw ); SetBoneController( 1, m_flGunPitch ); if ( m_nMoveStyle == MOVEMENT_STYLE_BARREL_PIVOT ) { SetBoneController( 2, m_flBarrelPitch ); } NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnvLaserDesignation::SetActive( bool bActive ) { if ( bActive == m_bActive ) return; if ( !bActive ) { m_fEffects |= EF_NODRAW; } else { m_fEffects |= EF_NOINTERP; m_fEffects &= ~EF_NODRAW; } NetworkStateChanged(); #if defined( CLIENT_DLL ) ENTITY_PANEL_ACTIVATE( "laserdesignation", bActive ); #endif m_bActive = bActive; }
void CRagdollProp::VPhysicsUpdate( IPhysicsObject *pPhysics ) { if ( m_lastUpdateTickCount == (unsigned int)gpGlobals->tickcount ) return; m_lastUpdateTickCount = gpGlobals->tickcount; NetworkStateChanged(); matrix3x4_t boneToWorld[MAXSTUDIOBONES]; QAngle angles; for ( int i = 0; i < m_ragdoll.listCount; i++ ) { RagdollGetBoneMatrix( m_ragdoll, boneToWorld, i ); Vector vNewPos; MatrixAngles( boneToWorld[m_ragdoll.boneIndex[i]], angles, vNewPos ); m_ragPos.Set( i, vNewPos ); m_ragAngles.Set( i, angles ); } m_allAsleep = RagdollIsAsleep( m_ragdoll ); SetAbsOrigin( m_ragPos[0] ); engine->RelinkEntity( pev, true ); }
//----------------------------------------------------------------------------- // Purpose: Detach the object from the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::DetachObjectByIndex( int nIndex ) { // Valid index? Assert( nIndex >= 0 ); Assert( nIndex < m_nObjectCount ); // Get the object. CBaseObject *pObject = m_hObjects[nIndex].Get(); if ( !pObject ) return; // Remove the damage modifier. m_aObjectAttachInfo[nIndex].m_DamageModifier.RemoveModifier(); // Remove the rope (cable). if ( m_aObjectAttachInfo[nIndex].m_hRope.Get() ) { m_aObjectAttachInfo[nIndex].m_hRope->DetachPoint( 1 ); m_aObjectAttachInfo[nIndex].m_hRope->DieAtNextRest(); } // Reduce object count. m_nObjectCount -= 1; // Set the object as unbuffed. pObject->SetBuffStation( NULL, false ); // If the detached object wasn't the last object in the list, swap placement. if ( nIndex != m_nObjectCount ) { SwapObjectAttachment( nIndex ); } // Update network state. NetworkStateChanged( ); }
//----------------------------------------------------------------------------- // Purpose: Detach the player from the "Buff Station." //----------------------------------------------------------------------------- void CObjectBuffStation::DetachPlayerByIndex( int nIndex ) { // Valid index? Assert( nIndex < BUFF_STATION_MAX_PLAYERS ); // Get the player. CBaseTFPlayer *pPlayer = m_hPlayers[nIndex].Get(); if ( !pPlayer ) { m_hPlayers.Set( nIndex, NULL ); return; } // Remove the damage modifier. m_aPlayerAttachInfo[nIndex].m_DamageModifier.RemoveModifier(); // Remove the rope (cable). if ( m_aPlayerAttachInfo[nIndex].m_hRope.Get() ) { m_aPlayerAttachInfo[nIndex].m_hRope->DetachPoint( 1 ); m_aPlayerAttachInfo[nIndex].m_hRope->DieAtNextRest(); } // Unconstrain the player movement. pPlayer->DeactivateMovementConstraint(); // Keep track of player events. g_pNotify->RemoveEntity( this, pPlayer ); // Reduce player count. m_nPlayerCount--; m_hPlayers.Set( nIndex, NULL ); // Update network state. NetworkStateChanged( ); }
//----------------------------------------------------------------------------- // Purpose: Remove this player from the team //----------------------------------------------------------------------------- void CTeam::RemovePlayer( CBasePlayer *pPlayer ) { m_aPlayers.FindAndRemove( pPlayer ); NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: Add the specified player to this team. Remove them from their current team, if any. //----------------------------------------------------------------------------- void CTeam::AddPlayer( CBasePlayer *pPlayer ) { m_aPlayers.AddToTail( pPlayer ); NetworkStateChanged(); }
void VPhysicsUpdate( IPhysicsObject *pPhysics ) { NetworkStateChanged(); BaseClass::VPhysicsUpdate( pPhysics ); }
void CLightGlow::Activate() { BaseClass::Activate(); NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: Handle movement of the turret //----------------------------------------------------------------------------- bool C_ObjectSentrygun::MoveTurret(void) { bool bMoved = 0; float turnrate = (float)(m_iBaseTurnRate) * 10.0f; turnrate *= gpGlobals->frametime; // any x movement? if ( m_vecCurAngles.x != m_vecGoalAngles.x ) { float flDir = m_vecGoalAngles.x > m_vecCurAngles.x ? 1 : -1 ; m_vecCurAngles.x += 0.1 * (turnrate * 5) * flDir; // if we started below the goal, and now we're past, peg to goal if (flDir == 1) { if (m_vecCurAngles.x > m_vecGoalAngles.x) m_vecCurAngles.x = m_vecGoalAngles.x; } else { if (m_vecCurAngles.x < m_vecGoalAngles.x) m_vecCurAngles.x = m_vecGoalAngles.x; } m_fBoneYRotator = m_vecCurAngles.x; bMoved = 1; } if ( m_vecCurAngles.y != m_vecGoalAngles.y ) { float flDir = m_vecGoalAngles.y > m_vecCurAngles.y ? 1 : -1 ; float flDist = fabs(m_vecGoalAngles.y - m_vecCurAngles.y); bool bReversed = false; if (flDist > 180) { flDist = 360 - flDist; flDir = -flDir; bReversed = true; } if (m_hEnemy == NULL ) { if (flDist > 30) { if (m_fTurnRate < turnrate * 20) { m_fTurnRate += turnrate; } } else { // Slow down if ( m_fTurnRate > (turnrate * 5) ) m_fTurnRate -= turnrate; } } else { // When tracking enemies, move faster and don't slow if (flDist > 30) { if (m_fTurnRate < turnrate * 30) { m_fTurnRate += turnrate * 3; } } } m_vecCurAngles.y += 0.1 * m_fTurnRate * flDir; // if we passed over the goal, peg right to it now if (flDir == -1) { if ( (bReversed == false && m_vecGoalAngles.y > m_vecCurAngles.y) || (bReversed == true && m_vecGoalAngles.y < m_vecCurAngles.y) ) m_vecCurAngles.y = m_vecGoalAngles.y; } else { if ( (bReversed == false && m_vecGoalAngles.y < m_vecCurAngles.y) || (bReversed == true && m_vecGoalAngles.y > m_vecCurAngles.y) ) m_vecCurAngles.y = m_vecGoalAngles.y; } if (m_vecCurAngles.y < 0) m_vecCurAngles.y += 360; else if (m_vecCurAngles.y >= 360) m_vecCurAngles.y -= 360; if (flDist < (0.05 * turnrate)) m_vecCurAngles.y = m_vecGoalAngles.y; m_fBoneXRotator = m_vecCurAngles.y - UTIL_AngleMod( GetAbsAngles().y ); bMoved = 1; } if ( !bMoved || !m_fTurnRate ) m_fTurnRate = turnrate; if ( bMoved ) { NetworkStateChanged(); } return bMoved; }
void CSun::InputSetColor( inputdata_t &inputdata ) { m_clrRender = inputdata.value.Color32(); NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseObjectDriverGun::SetTargetAngles( const QAngle &vecAngles ) { m_vecGunAngles = vecAngles; NetworkStateChanged(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseTFVehicle::FinishMove( CBasePlayer *player, CUserCmd *ucmd, CMoveData *move ) { VehicleDriverGunThink(); NetworkStateChanged(); }