Exemple #1
0
void CConnClient::DoShutDownAndCallbackDerived()
{
	CConnMgrClient* pMgr=CConnMgrClient::Inst();	

	if( !IsShuttingDown() )
	{
		IConnMgrClientHandler* pConnMgrHandler = pMgr->GetHandler();
		if(m_bGlobalTimeSynced)
		{
			CCoreSceneMgrClient::Inst()->DestroyMainSceneIfNotBeingUsedByLogic();

			CTimeSystemClient::Inst()->UnRegister(this);
			if(pConnMgrHandler)
			{
				SQR_TRY	
				{
					pConnMgrHandler->OnDisconnect(this);
				}
				SQR_CATCH(exp)
				{
					LogExp(exp);
				}
				SQR_TRY_END;
			}
		}
		else
		{
			if(pConnMgrHandler)
Exemple #2
0
bool CDynaLightFX::Update(float tmFrameTime)
{
	//track our performance
	CTimedSystemBlock TimingBlock(g_tsClientFXLight);

	// Base class update first	
	BaseUpdate(tmFrameTime);

	//update our light position
	LTRigidTransform tObjTrans;
	GetCurrentTransform(GetUnitLifetime(), tObjTrans.m_vPos, tObjTrans.m_rRot);
	g_pLTClient->SetObjectTransform(m_hLight, tObjTrans);

	//if we are shutting down, clear the radius of this light
	if (IsShuttingDown())
	{
		g_pLTClient->SetLightRadius(m_hLight, 0.0f);		
		return true;
	}

	float fUnitLifetime = GetUnitLifetime();

	UpdateDynamicProperties(fUnitLifetime);
	return true;
}
Exemple #3
0
already_AddRefed<LockedFile>
FileHandle::Open(FileMode aMode, ErrorResult& aError)
{
  MOZ_ASSERT(NS_IsMainThread());

  if (IsShuttingDown()) {
    aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
    return nullptr;
  }

  nsRefPtr<LockedFile> lockedFile = LockedFile::Create(this, aMode);
  if (!lockedFile) {
    aError.Throw(NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR);
    return nullptr;
  }

  return lockedFile.forget();
}
Exemple #4
0
bool CDynaLightFX::Update(float tmFrameTime)
{
	// Base class update first
	
	if (!CBaseFX::Update(tmFrameTime)) 
		return false;

	if (IsShuttingDown())
	{
		m_pLTClient->SetLightRadius(m_hObject, 0);
		
		return true;
	}

	// If we're flickering, change some of the attributes slightly

	if (GetProps()->m_bFlicker)
	{
		float fRand = 0.3f + GetRandom(0.0f, 0.19f);
		
		m_red   *= fRand;
		m_green *= fRand;
		m_blue  *= fRand;
	}
	
	// Try to add some sort of intensity based off the alpha...

	m_red	= LTCLAMP( m_red * m_alpha, 0.0f, 1.0f );
	m_green	= LTCLAMP( m_green * m_alpha, 0.0f, 1.0f );
	m_blue	= LTCLAMP( m_blue * m_alpha, 0.0f, 1.0f );

	// Set the new light colour

	m_pLTClient->SetLightColor(m_hObject, m_red, m_green, m_blue);

	// Set the new light scale

	m_pLTClient->SetLightRadius(m_hObject, m_scale);

	// Success !!

	return true;
}
Exemple #5
0
void CConnClient::OnConnectFailed(EPipeConnFailedReason eReason)
{
	CConnMgrClient* pMgr=CConnMgrClient::Inst();

	if(pMgr->GetHandler())
	{
		EConnConnectFailedReason eConnReason;

		switch( eReason )
		{
		case ePCFR_UNREACHABLE:
			eConnReason=eCCFR_UNREACHABLE;
			break;
		case ePCFR_REFUSED:
			eConnReason=eCCFR_REFUSED;
			break;
		case ePCFR_INVALIDADDR:
			eConnReason=eCCFR_INVALIDADDR;
			break;
		case ePCFR_OSERROR:
			eConnReason=eCCFR_OSERROR;
			break;
		default:
			GenErr("ConnClient收到不合理的回调");
		}
		pMgr->GetHandler()->OnConnectFailed(this,eConnReason);
	}

	if( IsShuttingDown() )
	{
		return;
	}

	pMgr->m_listAllConn.erase(m_itListConn);
	GetPipe()->Release();
	delete this;
}
Exemple #6
0
bool CLightningFX::Update(float tmFrameTime)
{
	// Base class update first
	
	if (!CBaseFX::Update(tmFrameTime)) 
		return false;

	
	if( !IsShuttingDown() )
	{
		EmitBolts( tmFrameTime );		
	}

	// Check to see if any bolts have expired...

	CLightningBolt *pBolt = LTNULL;
	LightningBolts::iterator iter;
	for( iter = m_lstBolts.begin(); iter != m_lstBolts.end(); ++iter )
	{
		pBolt = *iter;

		//adjust our start time
		pBolt->m_tmElapsed += tmFrameTime;

		if( pBolt->m_fLifetime < pBolt->m_tmElapsed )
			pBolt->m_bActive = false;
	}

	// Setup the bolts for rendering

	PreRender( tmFrameTime );

	// Success !!

	return true;
}
Exemple #7
0
bool CCamWobbleFX::Update(float tmFrameTime)
{
	// Base class update first
	
	if (!CBaseFX::Update(tmFrameTime)) 
		return false;

	// Return out if we have shutdown

	if (IsShuttingDown()) 
		return true;

	if (!g_bAppFocus)
	{
		return true;
	}

	LTVector	vCurCamPos;
	LTVector	vObjPos;
	
	// Retrieve the current position of the camera and get the distance to it

	m_pLTClient->GetObjectPos(m_hCamera, &vCurCamPos);
	
	if( m_hParent )
	{
		m_pLTClient->GetObjectPos( m_hParent, &vObjPos );
	}
	else
	{
		vObjPos = m_vCreatePos;
	}

	LTFLOAT	fDistSqrd = vObjPos.DistSqr( vCurCamPos );
	LTFLOAT	fFallOff;

	// Figure out the fall off of the shaking based on the inner and outer radii...

	if( fDistSqrd > GetProps()->m_fOuterDistSqrd )
	{
		return LTTRUE;
	}
	else if( fDistSqrd <= GetProps()->m_fInnerDistSqrd )
	{
		fFallOff = 1.0f;
	}
	else
	{
		fFallOff = 1 - ((fDistSqrd - GetProps()->m_fInnerDistSqrd) / (GetProps()->m_fOuterDistSqrd - GetProps()->m_fInnerDistSqrd));
	}

	// Compute the FOV offsets

	float fLen = GetProps()->m_tmLifespan / GetProps()->m_fPeriod;

	float fVal = fmodf(m_tmElapsed, fLen);

	float fRadVal = (MATH_CIRCLE / fLen) * fVal;
	
	float xOff = m_xFovAnchor + ((float)sin(fRadVal) * GetProps()->m_xMultiplier * fFallOff);
	float yOff = m_yFovAnchor + ((float)cos(fRadVal) * GetProps()->m_yMultiplier * fFallOff);

	m_pLTClient->SetCameraFOV(m_hCamera, xOff, yOff);

	// Success !!

	return true;
}
Exemple #8
0
bool CPolyTubeFX::Update(float tmFrameTime)
{
	// Base class update first
	if (!CBaseFX::Update(tmFrameTime)) 
		return false;

	if ((!m_hTexture) && (!m_bLoadFailed))
	{
		m_pLTClient->GetTexInterface()->CreateTextureFromName(m_hTexture, GetProps()->m_sPath);

		if (m_hTexture)
		{
			// Retrieve texture dims
			uint32 nHeight;
			m_pLTClient->GetTexInterface()->GetTextureDims(m_hTexture, m_dwWidth, nHeight);
		}
		else
		{
			m_bLoadFailed = true;
		}
	}

	if ((m_collPathPts.GetSize() < 2) && IsShuttingDown())
	{
		m_collPathPts.RemoveAll();
		return true;
	}
	
	float tmAddPtInterval = GetProps()->m_tmAddPtInterval * 2.0f;

	LTRotation rRot;
	m_pLTClient->GetObjectRotation( m_hObject, &rRot );

	//increase the emission time elapse
	m_tmElapsedEmission += tmFrameTime;

	if (!IsShuttingDown() && 
	    (m_collPathPts.GetSize() < GetProps()->m_nMaxTrailLength) && 
		((m_tmElapsedEmission > GetProps()->m_tmAddPtInterval) || (m_collPathPts.GetSize() == 1)))
	{
		LTVector vNew = m_vPos;
		
		// Only add the new point if it's not the same as the last one....

		// Add a new trail section

		PT_TRAIL_SECTION ts;
		ts.m_vPos		= vNew;
		ts.m_tmElapsed	= 0.0f;

		switch( GetProps()->m_eAllignment )
		{
			case ePTA_Up:
				ts.m_vBisector = rRot.Up();
			break;

			case ePTA_Right:
				ts.m_vBisector = rRot.Right();
			break;

			case ePTA_Forward:
				ts.m_vBisector = rRot.Forward();
			break;

			case ePTA_Camera:
			default:
				ts.m_vBisector.Init();
			break;
		}
		
		
		// Compute u coordinate

		if (m_collPathPts.GetSize())
		{
			LTVector vPrev = m_collPathPts.GetTail()->m_Data.m_vPos;
			float fUPrev = m_collPathPts.GetTail()->m_Data.m_uVal;
			
			float fWidth = (float)m_dwWidth;
			float fScalar = fWidth / GetProps()->m_fTrailWidth;

			ts.m_uVal = fUPrev + ((((vNew - vPrev).Mag()) / fWidth) * fScalar);

		}
		else
		{
			ts.m_uVal = 0.0f;
		}

		m_collPathPts.AddTail(ts);
		
		m_tmElapsedEmission = 0.0f;
	}

	// Render the tube....

	if (m_collPathPts.GetSize() < 2) return true;

	CLinkListNode<PT_TRAIL_SECTION> *pNode = m_collPathPts.GetHead();

	// Fudge the last point to be the current one...

	if( !IsShuttingDown() )
		m_collPathPts.GetTail()->m_Data.m_vPos = m_vPos;

	// Transform the path

	LTMatrix mCam;
	if( m_bReallyClose || (GetProps()->m_eAllignment != ePTA_Camera))
	{
		mCam.Identity();
	}
	else
	{
		mCam = GetCamTransform(m_pLTClient, m_hCamera);
	}
	 
	while (pNode)
	{
		MatVMul(&pNode->m_Data.m_vTran, &mCam, &pNode->m_Data.m_vPos);
		pNode = pNode->m_pNext;
	}

	// Do some precalculations

	pNode = m_collPathPts.GetHead();

	float fCurU = 0.0f;

	while (pNode)
	{
		pNode->m_Data.m_tmElapsed += tmFrameTime;

		if( GetProps()->m_eAllignment == ePTA_Camera )
		{
			LTVector vBisector;
			vBisector.z = 0.0f;

			// Compute the midpoint vectors

			if (pNode == m_collPathPts.GetHead())
			{
				LTVector vStart = pNode->m_Data.m_vTran;
				LTVector vEnd   = pNode->m_pNext->m_Data.m_vTran;
				
				vBisector.x = vEnd.y - vStart.y;
				vBisector.y = -(vEnd.x - vStart.x);
			}
			else if (pNode == m_collPathPts.GetTail())
			{
				LTVector vEnd   = pNode->m_Data.m_vTran;
				LTVector vStart = pNode->m_pPrev->m_Data.m_vTran;
				
				vBisector.x = vEnd.y - vStart.y;
				vBisector.y = -(vEnd.x - vStart.x);
			}
			else
			{
				LTVector vPrev  = pNode->m_pPrev->m_Data.m_vTran;
				LTVector vStart = pNode->m_Data.m_vTran;
				LTVector vEnd   = pNode->m_pNext->m_Data.m_vTran;

				float x1 = vEnd.y - vStart.y;
				float y1 = -(vEnd.x - vStart.x);
				float z1 = vStart.z - vEnd.z;

				float x2 = vStart.y - vPrev.y;
				float y2 = -(vStart.x - vPrev.x);
				float z2 = vPrev.z - vEnd.z;
				
				vBisector.x = (x1 + x2) / 2.0f;
				vBisector.y = (y1 + y2) / 2.0f;
			}

			pNode->m_Data.m_vBisector = vBisector;
		}
		
		LTFLOAT fWidth = CalcCurWidth();
		pNode->m_Data.m_vBisector.Norm( fWidth );

		// Setup the colour
		
		float r, g, b, a;			
		CalcColour(pNode->m_Data.m_tmElapsed, GetProps()->m_tmSectionLifespan, &r, &g, &b, &a);			

		int ir = (int)(r * 255.0f);
		int ig = (int)(g * 255.0f);
		int ib = (int)(b * 255.0f);
		int ia = (int)(a * 255.0f);

		pNode->m_Data.m_red = Clamp( ir, 0, 255 );
		pNode->m_Data.m_green = Clamp( ig, 0, 255 );
		pNode->m_Data.m_blue = Clamp( ib, 0, 255 );
		pNode->m_Data.m_alpha = Clamp( ia, 0, 255 );
	
		pNode = pNode->m_pNext;
	}

	pNode = m_collPathPts.GetHead();

	pNode = m_collPathPts.GetHead();

	// Delete any dead nodes

	while (pNode->m_pNext)
	{
		CLinkListNode<PT_TRAIL_SECTION> *pDelNode= NULL;

		if (pNode->m_Data.m_tmElapsed >= GetProps()->m_tmSectionLifespan)
		{
			pDelNode = pNode;
		}
		
		pNode = pNode->m_pNext;

		if (pDelNode) m_collPathPts.Remove(pDelNode);
	}

	// Increment the offset
	m_uOffset += tmFrameTime * GetProps()->m_uAdd;

	// Success !!

	return true;
}
bool CFallingStuffFX::Update(float tmFrameTime)
{
    // Base class update first

    m_vLastPos = m_vPos;

    if (!CBaseFX::Update(tmFrameTime))
        return false;

    //increment our emission time by the elapsed frame time
    m_tmElapsedEmission += tmFrameTime;

    if (!IsShuttingDown() && !IsSuspended() && (m_tmElapsedEmission > GetProps()->m_tmFallingStuffFXEmission))
    {
        ObjectCreateStruct ocs;
        INIT_OBJECTCREATESTRUCT(ocs);

        LTVector vScale;
        vScale.Init(m_scale, m_scale, m_scale);

        LTVector vInterp;
        LTVector vInterpCur  = m_vPos;

        // Calculate interpolant for particle system

        if (GetProps()->m_nFallingStuffFXEmission)
        {
            vInterp = m_vPos - m_vLastPos;
            vInterp /= (float)GetProps()->m_nFallingStuffFXEmission;
        }

        for (uint32 i = 0; i < GetProps()->m_nFallingStuffFXEmission; i ++)
        {
            ocs.m_ObjectType		= OT_SPRITE;
            ocs.m_Flags				= FLAG_VISIBLE | FLAG_NOLIGHT | FLAG_ROTATABLESPRITE;

            // Compute the initial position

            float xRand = GetProps()->m_fRadius * ((-10000.0f + (rand() % 20000)) / 10000.0f);
            float zRand = GetProps()->m_fRadius * ((-10000.0f + (rand() % 20000)) / 10000.0f);

            ocs.m_Pos = m_vPos + (m_vRight * xRand) + (m_vUp * zRand);

            ocs.m_Scale				= vScale;
            strcpy(ocs.m_Filename, GetProps()->m_sSpriteName);

            // Move the start point

            vInterpCur += vInterp;

            HLOCALOBJ hNewSprite = m_pLTClient->CreateObject(&ocs);

            if (hNewSprite)
            {
                // Create a new sprite

                FALLING_THING *pNewSprite = debug_new( FALLING_THING );

                if (GetProps()->m_nImpactCreate)
                {
                    if (g_dwSplash > (uint32)GetProps()->m_nImpactCreate)
                    {
                        pNewSprite->m_bSplash = true;
                        g_dwSplash = 0;
                    }
                    else
                    {
                        pNewSprite->m_bSplash = false;
                    }
                }
                else
                {
                    pNewSprite->m_bSplash = false;
                }

                g_dwSplash ++;

                if (pNewSprite)
                {
                    LTVector v;

                    // Compute the initial velocity

                    v = m_vPlaneDir * GetProps()->m_fVel;

                    pNewSprite->m_hObject	= hNewSprite;
                    pNewSprite->m_vVel		= v;
                    pNewSprite->m_tmElapsed	= 0.0f;
                    pNewSprite->m_vPos		= ocs.m_Pos;
                    pNewSprite->m_vLastPos	= ocs.m_Pos;

                    m_collSprites.AddTail(pNewSprite);
                }
            }
        }

        m_tmElapsedEmission = 0.0f;

        // And store the last position

        m_vLastPos = m_vPos;
    }

    LTMatrix mSpin;

    if (GetProps()->m_bUseSpin)
    {
        // Setup rotation

        LTMatrix vRight;
        LTMatrix vUp;
        LTMatrix vForward;
        LTMatrix vTmp;

        Mat_SetupRot(&vRight, &m_vRight, m_xRot);
        Mat_SetupRot(&vUp, &m_vUp, m_yRot);
        Mat_SetupRot(&vForward, &m_vPlaneDir, m_zRot);

        MatMul(&vTmp, &vRight, &vUp);
        MatMul(&mSpin, &vTmp, &vForward);

        m_xRot += GetProps()->m_vRotAdd.x * tmFrameTime;
        m_yRot += GetProps()->m_vRotAdd.y * tmFrameTime;
        m_zRot += GetProps()->m_vRotAdd.z * tmFrameTime;
    }

    // Get the camera rotation

    LTRotation orient;
    m_pLTClient->GetObjectRotation(m_hCamera, &orient);

    LTRotation dRot(orient);

    LTVector vF = orient.Forward();

    float rot = (float)atan2(vF.x, vF.z);

    // Update the sprites....

    CLinkListNode<FALLING_THING *> *pNode = m_collSprites.GetHead();
    CLinkListNode<FALLING_THING *> *pDelNode;

    while (pNode)
    {
        pDelNode = NULL;

        FALLING_THING *pSprite = pNode->m_Data;

        //adjust our elapsed time
        pSprite->m_tmElapsed += tmFrameTime;

        // Check for expiration

        if (pSprite->m_tmElapsed > GetProps()->m_tmSpriteLifespan)
        {
            // Destroy this object

            m_pLTClient->RemoveObject(pSprite->m_hObject);

            pDelNode = pNode;
        }
        else
        {
            // Update !!

            pSprite->m_vLastPos = pSprite->m_vPos;

            pSprite->m_vPos += (pSprite->m_vVel * tmFrameTime);

            // Rotate if neccessary

            TVector3<float> vPos = pSprite->m_vPos;

            if (GetProps()->m_bUseSpin)
            {
                MatVMul_InPlace(&mSpin, &vPos);
            }

            // Add in wind

            vPos += (GetProps()->m_vWind * GetProps()->m_fWindAmount) * tmFrameTime;

            // Setup the new sprite position

            LTVector vPos2 = vPos;
            m_pLTClient->SetObjectPos(pSprite->m_hObject, &vPos2);


            // Setup the colour

            float r, g, b, a;

            m_pLTClient->GetObjectColor(pSprite->m_hObject, &r, &g, &b, &a);
            CalcColour(pSprite->m_tmElapsed, GetProps()->m_tmSpriteLifespan, &r, &g, &b, &a);
            m_pLTClient->SetObjectColor(pSprite->m_hObject, r, g, b, a);

            // Setup the scale

            float scale = 0.1f;

            CalcScale(pSprite->m_tmElapsed, GetProps()->m_tmSpriteLifespan, &scale);

            LTVector vScale;
            vScale.Init(scale, scale * GetProps()->m_fStretchMul, scale);
            m_pLTClient->SetObjectScale(pSprite->m_hObject, &vScale);

            // Setup the rotation

            dRot = LTRotation(0, 0, 0, 1);
            LTRotation orient(dRot);

            orient.Rotate( orient.Up(), rot );

            m_pLTClient->SetObjectRotation(pSprite->m_hObject, &orient);

            // Check to see if we need to start a splash sprite

            if (pSprite->m_bSplash)
            {
                ClientIntersectQuery ciq;
                ClientIntersectInfo  cii;

                ciq.m_From		= pSprite->m_vLastPos;
                ciq.m_To		= pSprite->m_vPos;

                if ((GetProps()->m_sImpactSpriteName[0]) && (m_pLTClient->IntersectSegment(&ciq, &cii)))
                {
                    // Create a splash sprite

                    SPLASH *pSplash = debug_new( SPLASH );

                    ObjectCreateStruct ocs;
                    INIT_OBJECTCREATESTRUCT(ocs);

                    LTVector vScale;
                    vScale.Init(0.0f, 0.0f, 0.0f);

                    ocs.m_ObjectType = OT_SPRITE;
                    ocs.m_Flags		 = FLAG_VISIBLE | FLAG_ROTATABLESPRITE | FLAG_NOLIGHT;
                    ocs.m_Pos		 = cii.m_Point + (cii.m_Plane.m_Normal * 2.0f);
                    ocs.m_Scale		 = vScale;

                    LTRotation dOrient( cii.m_Plane.m_Normal, LTVector(0.0f, 1.0f, 0.0f) );

                    strcpy(ocs.m_Filename, GetProps()->m_sImpactSpriteName);

                    pSplash->m_hObject = m_pLTClient->CreateObject(&ocs);
                    pSplash->m_scale = 0.0f;

                    LTRotation orient(dRot);
                    m_pLTClient->SetObjectRotation(pSplash->m_hObject, &orient);

                    pSplash->m_tmElapsed = 0.0f;

                    m_collSplashes.AddTail(pSplash);

                    // Destroy this object

                    m_pLTClient->RemoveObject(pSprite->m_hObject);

                    // Delete the sprite

                    pDelNode = pNode;
                }
            }
        }

        pNode = pNode->m_pNext;

        if (pDelNode) m_collSprites.Remove(pDelNode);
    }

    // Update our splashes

    CLinkListNode<SPLASH *> *pSplashNode = m_collSplashes.GetHead();

    while (pSplashNode)
    {
        CLinkListNode<SPLASH *> *pDelNode = NULL;

        SPLASH *pSplash = pSplashNode->m_Data;

        //update the elapsed time on the splash
        pSplash->m_tmElapsed += tmFrameTime;

        // Calculate the new scale

        float scale = GetProps()->m_fImpactScale1 + ((GetProps()->m_fImpactScale2 - GetProps()->m_fImpactScale1) * (pSplash->m_tmElapsed / GetProps()->m_tmImpactLifespan));

        LTVector vScale(scale, scale, scale);
        m_pLTClient->SetObjectScale(pSplash->m_hObject, &vScale);

        float r, g, b, a;

        m_pLTClient->GetObjectColor(pSplash->m_hObject, &r, &g, &b, &a);

        a = (float)(int)(pSplash->m_tmElapsed / GetProps()->m_tmImpactLifespan);
        if (a < 0.0f) a = 0.0f;
        if (a > 1.0f) a = 1.0f;

        m_pLTClient->SetObjectColor(pSplash->m_hObject, r, g, b, a);

        if (pSplash->m_tmElapsed > GetProps()->m_tmImpactLifespan)
        {
            m_pLTClient->RemoveObject(pSplash->m_hObject);
            pDelNode = pSplashNode;
        }

        pSplashNode = pSplashNode->m_pNext;

        if (pDelNode) m_collSplashes.Remove(pDelNode);
    }

    // Success !!

    return true;
}