void CPickup::SetPosition(const CVector& vecPosition) { m_vecPosition = vecPosition; if (m_pCollision) m_pCollision->SetPosition(vecPosition); UpdateSpatialData(); }
CObject::CObject ( const CObject& Copy ) : CElement ( Copy.m_pParent, Copy.m_pXMLNode ) , m_bIsLowLod ( Copy.m_bIsLowLod ) , m_pLowLodObject ( Copy.m_pLowLodObject ) { // Init m_szName [0] = 0; m_szName [MAX_ELEMENT_NAME_LENGTH] = 0; m_pObjectManager = Copy.m_pObjectManager; m_usModel = Copy.m_usModel; m_vecPosition = Copy.m_vecPosition; m_vecRotation = Copy.m_vecRotation; m_pMoveAnimation = NULL; if ( Copy.m_pMoveAnimation != NULL ) { m_pMoveAnimation = new CPositionRotationAnimation ( *Copy.m_pMoveAnimation ); } m_bCollisionsEnabled = Copy.m_bCollisionsEnabled; // Add us to the manager's list m_pObjectManager->AddToList ( this ); UpdateSpatialData (); }
void CClientSound::SetPosition ( const CVector& vecPosition ) { m_vecPosition = vecPosition; UpdateSpatialData (); if ( m_pAudio ) m_pAudio->SetPosition ( m_vecPosition ); }
CPickup::CPickup ( CElement* pParent, CXMLNode* pNode, CPickupManager* pPickupManager, CColManager* pColManager ) : CElement ( pParent, pNode ) { // Init m_pPickupManager = pPickupManager; m_pCollision = new CColSphere ( pColManager, NULL, m_vecPosition, 2.0f, NULL, true ); m_pCollision->SetCallback ( this ); m_pCollision->SetAutoCallEvent ( false ); // Add us to the pickup manager's list and grab an unique id pPickupManager->AddToList ( this ); // Initialize our stuff to defaults m_iType = CElement::PICKUP; SetTypeName ( "pickup" ); m_ucType = CPickup::WEAPON; m_ucWeaponType = CPickup::WEAPON_BRASSKNUCKLE; m_usAmmo = 0; m_fAmount = 0; m_ulRespawnIntervals = 30000; m_ulLastUsedTime = 0; m_usModel = CPickupManager::GetWeaponModel ( m_ucWeaponType ); m_bVisible = true; m_bSpawned = true; m_bIsTypeRandom = false; m_bIsWeaponTypeRandom = false; m_bIsHealthRandom = false; UpdateSpatialData (); }
CColTube::CColTube ( CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight, CXMLNode* pNode ) : CColShape ( pManager, pParent, pNode ) { m_vecPosition = vecPosition; m_fRadius = fRadius; m_fHeight = fHeight; UpdateSpatialData (); }
void CMarker::SetPosition ( const CVector& vecPosition ) { // Different from our current position? if ( m_vecPosition != vecPosition ) { // Set the new position m_vecPosition = vecPosition; if ( m_pCollision ) m_pCollision->SetPosition ( vecPosition ); UpdateSpatialData (); // If attached, client should handle the position correctly if ( m_pAttachedTo ) return; // We need to make sure the time context is replaced // before that so old packets don't arrive after this. GenerateSyncTimeContext (); // Tell all the players that know about us CBitStream BitStream; BitStream.pBitStream->Write ( vecPosition.fX ); BitStream.pBitStream->Write ( vecPosition.fY ); BitStream.pBitStream->Write ( vecPosition.fZ ); BitStream.pBitStream->Write ( GetSyncTimeContext () ); BroadcastOnlyVisible ( CElementRPCPacket ( this, SET_ELEMENT_POSITION, *BitStream.pBitStream ) ); } }
CClientColRectangle::CClientColRectangle ( CClientManager* pManager, ElementID ID, const CVector& vecPosition, const CVector2D& vecSize ) : ClassInit ( this ), CClientColShape ( pManager, ID ) { m_pManager = pManager; m_vecPosition = vecPosition; m_vecSize = vecSize; UpdateSpatialData (); }
CColRectangle::CColRectangle ( CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize, CXMLNode* pNode ) : CColShape ( pManager, pParent, pNode ) { m_vecPosition.fX = vecPosition.fX; m_vecPosition.fY = vecPosition.fY; m_vecPosition.fZ = SPATIAL_2D_Z; m_vecSize = vecSize; UpdateSpatialData (); }
void CClientPickup::SetModel ( unsigned short usModel ) { // Different from our current id? if ( m_usModel != usModel ) { // Set the model and recreate the pickup m_usModel = usModel; UpdateSpatialData (); ReCreate (); } }
void CClientSound::SetMaxDistance ( float fDistance ) { bool bChanged = m_fMaxDistance != fDistance; m_fMaxDistance = fDistance; if ( m_pAudio ) m_pAudio->SetMaxDistance ( m_fMaxDistance ); if ( bChanged ) UpdateSpatialData (); }
void CVehicle::SetPosition ( const CVector & vecPosition ) { // If we're attached to something, dont allow any change if ( m_pAttachedTo ) return; // Different to where we are now? if ( m_vecPosition != vecPosition ) { // Update our stored vectors m_vecPosition = vecPosition; UpdateSpatialData (); } }
void CClientColPolygon::SetPosition ( const CVector& vecPosition ) { CVector vecDifference = m_vecPosition - vecPosition; for ( unsigned int i = 0; i < m_Points.size(); i++ ) { m_Points[i].fX -= vecDifference.fX; m_Points[i].fY -= vecDifference.fY; } m_vecPosition = vecPosition; UpdateSpatialData (); // Add queued collider refresh for v1.1 }
void CObject::SetPosition ( const CVector& vecPosition ) { // If we're attached to something, dont change anything (attachment takes priority over moving here) if ( m_pAttachedTo ) return; // If we're moving, dont change anything if ( IsMoving () ) return; // Different position? if ( m_vecPosition != vecPosition ) { // Update our vectors m_vecPosition = vecPosition; UpdateSpatialData (); } }
void CObject::StopMoving ( void ) { // Were we moving in the first place if ( m_pMoveAnimation != NULL ) { SPositionRotation positionRotation; m_pMoveAnimation->GetValue ( positionRotation ); m_vecPosition = positionRotation.m_vecPosition; m_vecRotation = positionRotation.m_vecRotation; delete m_pMoveAnimation; m_pMoveAnimation = NULL; UpdateSpatialData (); } }
void CVehicle::SpawnAt ( const CVector& vecPosition, const CVector& vecRotation ) { SetHealth ( GetRespawnHealth () ); SetIsBlown ( false ); StopIdleTimer (); ResetDoorsWheelsPanelsLights (); SetLandingGearDown ( true ); SetAdjustableProperty ( 0 ); SetTowedByVehicle ( NULL ); AttachTo ( NULL ); m_vecTurnSpeed = CVector (); m_vecVelocity = CVector (); m_vecPosition = vecPosition; m_vecRotationDegrees = vecRotation; UpdateSpatialData (); }
CClientMarker::CClientMarker ( CClientManager* pManager, ElementID ID, int iMarkerType ) : ClassInit ( this ), CClientStreamElement ( pManager->GetMarkerStreamer (), ID ) { // Init m_pManager = pManager; m_pMarkerManager = pManager->GetMarkerManager (); m_pCollision = NULL; m_pMarker = NULL; // Typename SetTypeName ( "marker" ); // Create the marker CreateOfType ( iMarkerType ); // Add us to marker manager list m_pMarkerManager->AddToList ( this ); UpdateSpatialData (); }
void CClientObject::SetModel ( unsigned short usModel ) { // Valid model ID? if ( CClientObjectManager::IsValidModel ( usModel ) ) { // Destroy current model Destroy (); // Set the new model ID and recreate the model m_usModel = usModel; m_pModelInfo = g_pGame->GetModelInfo ( usModel ); UpdateSpatialData (); // Request the new model so we can recreate when it's done if ( m_pModelRequester->Request ( usModel, this ) ) { Create (); } } }
void CVehicle::SpawnAt ( const CVector& vecPosition, const CVector& vecRotation ) { SetHealth ( GetRespawnHealth () ); SetBlowTime ( 0 ); SetIdleTime ( 0 ); GetInitialDoorStates ( m_ucDoorStates ); memset ( m_ucWheelStates, 0, sizeof ( m_ucWheelStates ) ); memset ( m_ucPanelStates, 0, sizeof ( m_ucPanelStates ) ); memset ( m_ucLightStates, 0, sizeof ( m_ucLightStates ) ); SetLandingGearDown ( true ); SetAdjustableProperty ( 0 ); CVector vecNull; m_vecTurnSpeed = vecNull; m_vecVelocity = vecNull; m_vecPosition = vecPosition; m_vecRotationDegrees = vecRotation; UpdateSpatialData (); }
CMarker::CMarker ( CMarkerManager* pMarkerManager, CColManager* pColManager, CElement* pParent, CXMLNode* pNode ) : CPerPlayerEntity ( pParent, pNode ) { // Init m_pMarkerManager = pMarkerManager; m_pColManager = pColManager; m_iType = CElement::MARKER; SetTypeName ( "marker" ); m_ucType = TYPE_CHECKPOINT; m_fSize = 4.0f; m_Color = SColorRGBA ( 255, 255, 255, 255 ); m_bHasTarget = false; m_ucIcon = ICON_NONE; // Create our collision object m_pCollision = new CColCircle ( pColManager, NULL, m_vecPosition, m_fSize, NULL, true ); m_pCollision->SetCallback ( this ); m_pCollision->SetAutoCallEvent ( false ); // Add us to the marker manager pMarkerManager->AddToList ( this ); UpdateSpatialData (); }
const CVector& CObject::GetPosition ( void ) { CVector vecOldPosition = m_vecPosition; // Are we attached to something? if ( m_pAttachedTo ) GetAttachedPosition ( m_vecPosition ); // Are we moving? else if ( IsMoving () ) { SPositionRotation positionRotation; bool bStillRunning = m_pMoveAnimation->GetValue ( positionRotation ); m_vecPosition = positionRotation.m_vecPosition; if ( !bStillRunning ) { StopMoving (); } } if ( vecOldPosition != m_vecPosition ) UpdateSpatialData (); // This is necessary because 'GetAttachedPosition ( m_vecPosition )' can change alter this objects position // Finally, return it return m_vecPosition; }
//////////////////////////////////////////////////////////// // // CClientSound::Process3D // // Update position and velocity and pass on the BASS for processing. // m_pAudio->DoPulse needs to be called for non-3D sounds also. // //////////////////////////////////////////////////////////// void CClientSound::Process3D ( const CVector& vecPlayerPosition, const CVector& vecCameraPosition, const CVector& vecLookAt ) { // Update 3D things if required if ( m_b3D ) { // Update our position and velocity if we're attached CClientEntity* pAttachedToEntity = GetAttachedTo (); if ( pAttachedToEntity ) { GetPosition( m_vecPosition ); DoAttaching (); CVector vecVelocity; if ( CStaticFunctionDefinitions::GetElementVelocity ( *pAttachedToEntity, vecVelocity ) ) SetVelocity ( vecVelocity ); // Update our spatial data position UpdateSpatialData (); } } // If the sound isn't active, we don't need to process it // Moved after 3D updating as the streamer didn't know the position changed if a sound isn't streamed in when attached. if ( !m_pAudio ) return; m_pAudio->DoPulse ( vecPlayerPosition, vecCameraPosition, vecLookAt ); // Trigger script events for things SSoundEventInfo eventInfo; while ( m_pAudio->GetQueuedEvent ( eventInfo ) ) { if ( eventInfo.type == SOUND_EVENT_FINISHED_DOWNLOAD ) { CLuaArguments Arguments; Arguments.PushNumber ( eventInfo.dNumber ); CallEvent ( "onClientSoundFinishedDownload", Arguments, true ); OutputDebugLine ( SString ( "[ClientSound] onClientSoundFinishedDownload %f", eventInfo.dNumber ) ); } else if ( eventInfo.type == SOUND_EVENT_CHANGED_META ) { CLuaArguments Arguments; Arguments.PushString ( eventInfo.strString ); CallEvent ( "onClientSoundChangedMeta", Arguments, true ); OutputDebugLine ( SString ( "[ClientSound] onClientSoundChangedMeta %s", *eventInfo.strString ) ); } else if ( eventInfo.type == SOUND_EVENT_STREAM_RESULT ) { // Call onClientSoundStream LUA event CLuaArguments Arguments; Arguments.PushBoolean ( eventInfo.bBool ); Arguments.PushNumber ( eventInfo.dNumber ); if ( !eventInfo.strString.empty () ) Arguments.PushString ( eventInfo.strString ); CallEvent ( "onClientSoundStream", Arguments, true ); OutputDebugLine ( SString ( "[ClientSound] onClientSoundStream %d %f %s", eventInfo.bBool, eventInfo.dNumber, *eventInfo.strString ) ); } else if ( eventInfo.type == SOUND_EVENT_BEAT ) { CLuaArguments Arguments; Arguments.PushNumber ( eventInfo.dNumber ); CallEvent ( "onClientSoundBeat", Arguments, true ); } } }
void CElement::SetPosition ( const CVector& vecPosition ) { m_vecPosition = vecPosition; UpdateSpatialData (); };
CClientColSphere::CClientColSphere ( CClientManager* pManager, ElementID ID, const CVector& vecPosition, float fRadius ) : CClientColShape ( pManager, ID ) { m_vecPosition = vecPosition; m_fRadius = fRadius; UpdateSpatialData (); }