예제 #1
0
	void EffectController::Update( float dt )
	{
		if(!m_anim)
			return;

		//更新动画
		float fLastTimePos = m_anim->getTimePosition();
		m_anim->addTime(dt);

		if(m_anim->hasEnded())
		{
			StopAnimation();
			m_anim = nullptr;
		}
		else
		{
			bool bLooped = false;
			float fCurTimePos = m_anim->getTimePosition();
			//hack a little..
			//说明动画已经循环了一次
			if(fCurTimePos < fLastTimePos)
				bLooped = true;

			//更新特效
			auto iter = m_effects.find(m_anim->getAnimationName());
			if(iter != m_effects.end())
			{
				EffectSlots& slots = iter->second;
				for (auto itEffect=slots.begin(); itEffect!=slots.end(); ++itEffect)
				{
					AttachEffectBase* effect = *itEffect;
					if(bLooped)
						effect->Start();
					else
						effect->Update(dt);
				}
			}
		}
	}
예제 #2
0
LRESULT CSystemTray::OnTimer(UINT nIDEvent) 
{
    if (nIDEvent != m_uIDTimer)
    {
        ASSERT(FALSE);
        return 0L;
    }

    time_t CurrentTime;
    time(&CurrentTime);
    
    time_t period = CurrentTime - m_StartTime;
    if (m_nAnimationPeriod > 0 && m_nAnimationPeriod < period)
    {
        StopAnimation();
        return 0L;
    }

    StepAnimation();

    return 0L;
}
예제 #3
0
// Indempotent error flagging routine. If a decoder is open, shuts it down.
void
RasterImage::DoError()
{
  // If we've flagged an error before, we have nothing to do
  if (mError) {
    return;
  }

  // We can't safely handle errors off-main-thread, so dispatch a worker to
  // do it.
  if (!NS_IsMainThread()) {
    HandleErrorWorker::DispatchIfNeeded(this);
    return;
  }

  // Put the container in an error state.
  mError = true;

  // Stop animation and release our FrameAnimator.
  if (mAnimating) {
    StopAnimation();
  }
  mAnimationState = Nothing();
  mFrameAnimator = nullptr;

  // Release all locks.
  mLockCount = 0;
  SurfaceCache::UnlockImage(ImageKey(this));

  // Release all frames from the surface cache.
  SurfaceCache::RemoveImage(ImageKey(this));

  // Invalidate to get rid of any partially-drawn image content.
  NotifyProgress(NoProgress, IntRect(0, 0, mSize.width, mSize.height));

  MOZ_LOG(gImgLog, LogLevel::Error,
          ("RasterImage: [this=%p] Error detected for image\n", this));
}
예제 #4
0
/* attribute unsigned short animationMode; */
NS_IMETHODIMP imgContainer::SetAnimationMode(PRUint16 aAnimationMode)
{
  NS_ASSERTION(aAnimationMode == imgIContainer::kNormalAnimMode ||
               aAnimationMode == imgIContainer::kDontAnimMode ||
               aAnimationMode == imgIContainer::kLoopOnceAnimMode,
               "Wrong Animation Mode is being set!");
  
  switch (mAnimationMode = aAnimationMode) {
    case kDontAnimMode:
      StopAnimation();
      break;
    case kNormalAnimMode:
      if (mLoopCount != 0 || 
          (mAnim && (mAnim->currentAnimationFrameIndex + 1 < mNumFrames)))
        StartAnimation();
      break;
    case kLoopOnceAnimMode:
      if (mAnim && (mAnim->currentAnimationFrameIndex + 1 < mNumFrames))
        StartAnimation();
      break;
  }
  
  return NS_OK;
}
예제 #5
0
BOOL WINPROC EXPORT DlgRoomMazes (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
    BOOL bHandled = TRUE;
    char szTemp[MAX_PATH];
    HWND hCtl;

    switch (wMsg)
    {
    case WM_COMMAND:
        switch (wParam)
        {
        case HS_COVER:
			StopAnimation();
			ShowCoverAnimatedButtons(hWnd, TRUE);
            hCtl = GetDlgItem (hWnd,IDC_HIDDEN_IMAGE);
            ShowWindow (hCtl,SW_HIDE);
            if (idCurrentRoom == RM_MAILMAZE)
            {
                hCtl = GetDlgItem (hWnd,HS_LOGO_MAILMAZE);
                ShowWindow (hCtl,SW_SHOW);
                hCtl = GetDlgItem (hWnd,HS_XTRA_MAILMAZE);
                ShowWindow (hCtl,SW_HIDE);
                hCtl = GetDlgItem (hWnd,HS_RESTART);
                ShowWindow (hCtl,SW_HIDE);
            }
            else if (idCurrentRoom == RM_MAZES)
            {
                hCtl = GetDlgItem (hWnd,HS_LOGO_MAZES);
                ShowWindow (hCtl,SW_SHOW);
                hCtl = GetDlgItem (hWnd,HS_XTRA_MAZES);
                ShowWindow (hCtl,SW_HIDE);
                hCtl = GetDlgItem (hWnd,HS_RESTART);
                ShowWindow (hCtl,SW_HIDE);
            }
            bHandled = FALSE;
            break;
        case HS_TAB1:
        case HS_TAB2:
        case HS_TAB3:
        case HS_TAB4:
        case HS_TAB5:
        case HS_TAB6:
        case HS_TAB7:
        case HS_TAB8:
			StopAnimation();
			ShowCoverAnimatedButtons(hWnd, FALSE);
            bTrack = FALSE;
            if (idCurrentRoom == RM_MAILMAZE)
                wsprintf (szTemp,GetString (IDS_MAILMAZE,NULL),wParam - HS_TAB1 + 1);
            else if (idCurrentRoom == RM_MAZES)
                wsprintf (szTemp,GetString (IDS_MAZES,NULL),wParam - HS_TAB1 + 1);
            PathCat (szPreview,Control.PouchPath,szTemp);
            AstralImageLoad (IDN_ART,szPreview,MAYBE,NO);
            if (lpImage)
            {
                bShowSolution = bSolved = FALSE;
                ImgSetPixelProc (MazePixelProc);
                hCtl = GetDlgItem (hWnd,IDC_HIDDEN_IMAGE);
                SetWindowLong (hCtl,GWL_IMAGE,(long) ImgGetBase (lpImage));
                SetWindowLong (hCtl,GWL_IMAGE_TOOLPROC,(long)MazeToolProc);
                ShowWindow (hCtl,SW_SHOW);
                InvalidateRect (hCtl,NULL,FALSE);
                if (idCurrentRoom == RM_MAILMAZE)
                {
                    hCtl = GetDlgItem (hWnd,HS_LOGO_MAILMAZE);
                    ShowWindow (hCtl,SW_HIDE);
                    hCtl = GetDlgItem (hWnd,HS_XTRA_MAILMAZE);
                    ShowWindow (hCtl,SW_SHOW);
                    hCtl = GetDlgItem (hWnd,HS_RESTART);
                    ShowWindow (hCtl,SW_SHOW);
                }
                else if (idCurrentRoom == RM_MAZES)
                {
                    hCtl = GetDlgItem (hWnd,HS_LOGO_MAZES);
                    ShowWindow (hCtl,SW_HIDE);
                    hCtl = GetDlgItem (hWnd,HS_XTRA_MAZES);
                    ShowWindow (hCtl,SW_SHOW);
                    hCtl = GetDlgItem (hWnd,HS_RESTART);
                    ShowWindow (hCtl,SW_SHOW);
                }
                bHandled = FALSE;
            }
#ifdef STUDIO			
				SoundStartID(HS_XTRA_MAILMAZE, FALSE, 0);
#else
				SoundStartID(HS_XTRA_MAZES, FALSE, 0);
#endif			
            break;
        case HS_COLORME:
			StopAnimation();
            GoPaintApp (hWnd,szPreview);
            break;
        case HS_SHOWME:
        case HS_RESTART:
            bTrack = FALSE;
            bShowSolution = (wParam == HS_SHOWME);
            hCtl = GetDlgItem (hWnd,IDC_HIDDEN_IMAGE);
			StopAnimation();
            InvalidateRect (hCtl,NULL,FALSE);
            UpdateWindow (hCtl);
			if (wParam == HS_SHOWME)
				StartAnimation(hCtl);
            break;
        default:
            bHandled = FALSE;
        }
        break;
    case WM_INITDIALOG:
        hMazePen = CreatePen (PS_SOLID,3,RGB (0,0,255));
        bHandled = FALSE;
        break;
    case WM_DESTROY:
		StopAnimation();
        ImgSetPixelProc (NULL);
        if (hMazePen)
        {
            DeleteObject (hMazePen);
            hMazePen = 0;
        }
        bHandled = FALSE;
        break;
    default:
        bHandled = FALSE;
    }
    if (!bHandled)
        bHandled = DefRoomProc (hWnd,wMsg,wParam,lParam);
    return bHandled;
}
예제 #6
0
void Unit::SetWeaponState(WeaponState newWeaponState)
{
	if (!IsAlive())
		return;

	switch (gWeaponState)
	{
	case Hold:

		switch (newWeaponState)
		{
		case Hold:
			if ( gMoveState == Walk || gMoveState == Stand )
			{
				LoopAnimation(GetAnimation("UpperWalk"));
			}
			else if ( gMoveState == Run )
			{
				LoopAnimation(GetAnimation("UpperRun"));
			}
			break;
		case Aim:
			float progress = 1.0f - GetAnimationProgress(GetAnimation("PutAway"));

			StopAnimation(GetAnimation("UpperWalk"));
			StopAnimation(GetAnimation("PutAway"));

			if (PlayingAnimation(GetAnimation("DrawReloadPutAway")))
				PlayAnimationAfter(GetAnimation("DrawReloadPutAway"), GetAnimation("Draw"));

			else if (PlayingAnimation(GetAnimation("Reload")))
				PlayAnimationAfter(GetAnimation("Reload"), GetAnimation("Draw"));

			else
			{
				PlayAnimation(GetAnimation("Draw"));
				SetAnimationProgress(GetAnimation("Draw"), progress);
			}
			PlayAnimationAfter(GetAnimation("Draw"), GetAnimation("Aim"));
			break;
		}

		break;
	case Aim:

		switch (newWeaponState)
		{
		case Aim:
			PlayAnimation(GetAnimation("Aim"));
			break;
		case Hold:

			float progress = 1.0f - GetAnimationProgress(GetAnimation("Draw"));

			StopAnimation(GetAnimation("Aim"));
			StopAnimation(GetAnimation("Draw"));

			if (PlayingAnimation(GetAnimation("Reload")))
				PlayAnimationAfter(GetAnimation("Reload"), GetAnimation("PutAway"));

			//else if (PlayingAnimation(GetAnimation("DrawReloadPutAway")))
			//	PlayAnimationAfter(GetAnimation("DrawReloadPutAway"), GetAnimation("PutAway"));

			else
			{
				PlayAnimation(GetAnimation("PutAway"));
				SetAnimationProgress(GetAnimation("PutAway"), progress);
			}

			switch (gMoveState)
			{
			case Stand:
			case Crouch:
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperStand"));
				break;
			case Walk:
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperWalk"));
			case Run:
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperRun"));
			}

			break;
		}
		break;
	}

	gWeaponState = newWeaponState;
}
예제 #7
0
void Unit::SetMoveState(MoveState newMoveState)
{
	if (!IsAlive())
		return;

	switch (newMoveState)
	{
	case Stand:
		if (gMoveState == Crouch)
		{
			float progress = 1.0f - GetAnimationProgress("Crouching");
			PlayAnimation("StandUp");
			LoopAnimationAfter("StandUp", "Pose");
			SetAnimationProgress("StandUp", progress);

			if (PlayingAnimation(GetAnimation("PutAway")))
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperStand"));
		}

		if (gMoveState != Stand)
		{
			if (!PlayingAnimation("StandUp"))
				LoopAnimation("Pose");	

			if (PlayingAnimation(GetAnimation("UpperWalk")) || PlayingAnimation(GetAnimation("UpperRun")))
			{
				StopAnimation(GetAnimation("UpperWalk"));
				StopAnimation(GetAnimation("UpperRun"));
				LoopAnimation(GetAnimation("UpperStand"));
			}

			if (PlayingAnimation(GetAnimation("PutAway")))
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperStand"));
		}
		break;
	case Walk:

		switch (gMoveDirection)
		{
		case Forward:
			LoopAnimation("Walk");
			break;
		case Back:
			LoopAnimation("Back");
			break;
		case Right:
			LoopAnimation("SideStepRight");
			break;
		case Left:
			LoopAnimation("SideStepLeft");
			break;		
		}

		if (PlayingAnimation(GetAnimation("UpperStand")) || PlayingAnimation(GetAnimation("UpperRun")))
		{
			StopAnimation(GetAnimation("UpperStand"));
			StopAnimation(GetAnimation("UpperRun"));
			LoopAnimation(GetAnimation("UpperWalk"));
		}

		if (PlayingAnimation(GetAnimation("PutAway")))
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperWalk"));

		break;
	
	case Run:

		if (gMoveState != Run)
			BodyInSync = false;

		LoopAnimation("Run");

		if (PlayingAnimation("Run"))
		{			
			if (PlayingAnimation(GetAnimation("DrawReloadPutAway")))
			LoopAnimationAfter(GetAnimation("DrawReloadPutAway"), GetAnimation("UpperRun"));

			else if (PlayingAnimation(GetAnimation("Reload")))
			{
				PlayAnimationAfter(GetAnimation("Reload"), GetAnimation("PutAway"));
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperRun"));
			}

			else if (PlayingAnimation(GetAnimation("PutAway")))			
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperRun"));

			else
			{
				LoopAnimation(GetAnimation("UpperRun"));

				if (!BodyInSync)
				{
					float progress = GetAnimationProgress(GetAnimation("UpperRun")) + 0.5f;
					progress -= (int)progress;
					if (SetAnimationProgress(GetAnimation("UpperRun"), progress))
						BodyInSync = true;
				}
			}

			if (PlayingAnimation(GetAnimation("PutAway")))
				LoopAnimationAfter(GetAnimation("PutAway"), GetAnimation("UpperRun"));
		}

		else
			LoopAnimation("Walk");		

		break;

	case Crouch:
		SetVelocity(XMFLOAT3(0, 0, 0));
		if (!PlayingAnimation("Crouch"))
		{
			float progress = 1.0f - GetAnimationProgress("StandUp");
			PlayAnimation("Crouching");
			PlayAnimationAfter("Crouching", "Crouch");
			SetAnimationProgress("Crouching", progress);
		}
				
		if (PlayingAnimation(GetAnimation("UpperWalk")) || PlayingAnimation(GetAnimation("UpperRun")))
		{
			StopAnimation(GetAnimation("UpperWalk"));
			StopAnimation(GetAnimation("UpperRun"));
			LoopAnimation(GetAnimation("UpperStand"));
		}
		break;
	}

	gMoveState = newMoveState;
}
/* Destructeur */
Scene_Inca_Mainscreen::~Scene_Inca_Mainscreen()
{
   StopAnimation("bg2_anim");
   XDELETE(_lpBgGraphic);
   XDELETE(_lpAnimDoor);
}
예제 #9
0
/////////////////////////////////////////////////////////////////////
/// Timed Func
bool COGLWin::TimedFunc()
{	
	CCodeVar Var;
	bool bCodeChanged = m_bCodeChanged;

	if (m_bExecCode)
	{
		CCodeVar &rVarDTime = m_Parse.GetVar("dTime");
		if (rVarDTime.Type() == PDT_DOUBLE)
		{
			*((double *) rVarDTime.Val()) = (double) m_fTimeStep;
		}

		CCodeVar &rVarTime = m_Parse.GetVar("Time");
		if (rVarTime.Type() == PDT_DOUBLE)
		{
			*((double *) rVarTime.Val()) = (double) m_fTotalTime;
		}

		// Set this true to rerun code
		m_bCodeChanged = true;
	}

	if (m_iAnimRotType == ANIMROT_MOUSE)
	{	 
		if (HasMouseRotHistChanged())
		{
			m_vRot = GetMouseRotHistSum();
			//ResetMouseRotHist();
		}
	 
		float fVal = 2e-2f * float(sqrt(m_vRot.Mag2()));
		float fAngle = m_fTimeStep * fVal;

		if (fAngle != 0.0f && m_vRot != m_E3Base.vZero)
		{
			if (!m_bUseLocalRot)
				m_vRMain = m_E3Base.Rotor(m_vRot, fAngle, false) & m_vRMain;
			else
				m_vRMain = m_vRMain & m_E3Base.Rotor(m_vRot, fAngle, false);
		
			m_mTransform[0].SetRotChanged(0);
			m_mTransform[0].SetRotChanged(1);
			m_mTransform[0].SetRotChanged(2);
		}
	}

	if (m_bCodeChangedForAnim)
	{
		SetExecModeVar(EXEC_MODE_CHANGE);
		m_bCodeChangedForAnim = false;
	}
	else
		AddExecModeVar(EXEC_MODE_ANIM);

	Display();

	if (bCodeChanged || m_bExecCode)
	{
		TCVScalar dVal;

		if (m_Parse.GetVar("_DoAnimate", Var))
		{
			if (Var.CastToScalar(dVal) && dVal != 0)
			{
				if (m_bAnimPauseChanged)
				{
					m_bAnimPauseChanged = false; // Set by SetAnimationTimeStep
					/*
					SetAnimCode(false);
					StopAnimation();
					StartAnimation(m_iAnimPause);
					*/
					SetAnimCode(true);
					m_bExecCode = true;
				}
				else
				{
					m_bExecCode = true;
					SetAnimCode(true);
				}
			}
			else
			{
				m_bExecCode = false;
				SetAnimCode(false);
				StopAnimation();
			}
		}
		else 
		{
			m_bExecCode = false;
			SetAnimCode(false);
			StopAnimation();
		}
	}

	return true;
}
예제 #10
0
//=========================================================
// RunTask
//=========================================================
void CGargantua::RunTask( Task_t *pTask )
{
	switch ( pTask->iTask )
	{
	case TASK_DIE:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			pev->renderfx = kRenderFxExplode;
			pev->rendercolor.x = 255;
			pev->rendercolor.y = 0;
			pev->rendercolor.z = 0;
			StopAnimation();
			pev->nextthink = gpGlobals->time + 0.15;
			SetThink( SUB_Remove );
			int i;
			int parts = MODEL_FRAMES( gGargGibModel );
			for ( i = 0; i < 10; i++ )
			{
				CGib *pGib = GetClassPtr( (CGib *)NULL );

				pGib->Spawn( GARG_GIB_MODEL );
				
				int bodyPart = 0;
				if ( parts > 1 )
					bodyPart = RANDOM_LONG( 0, pev->body-1 );

				pGib->pev->body = bodyPart;
				pGib->m_bloodColor = BLOOD_COLOR_YELLOW;
				pGib->m_material = matNone;
				pGib->SetAbsOrigin( GetAbsOrigin() );
				pGib->SetAbsVelocity( UTIL_RandomBloodVector() * RANDOM_FLOAT( 300, 500 ));
				pGib->SetNextThink( 1.25 );
				pGib->SetThink( SUB_FadeOut );
			}

			Vector vecOrigin = GetAbsOrigin();

			MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin );
				WRITE_BYTE( TE_BREAKMODEL);

				// position
				WRITE_COORD( vecOrigin.x );
				WRITE_COORD( vecOrigin.y );
				WRITE_COORD( vecOrigin.z );

				// size
				WRITE_COORD( 200 );
				WRITE_COORD( 200 );
				WRITE_COORD( 128 );

				// velocity
				WRITE_COORD( 0 ); 
				WRITE_COORD( 0 );
				WRITE_COORD( 0 );

				// randomization
				WRITE_BYTE( 200 ); 

				// Model
				WRITE_SHORT( gGargGibModel );	//model id#

				// # of shards
				WRITE_BYTE( 50 );

				// duration
				WRITE_BYTE( 20 );// 3.0 seconds

				// flags

				WRITE_BYTE( BREAK_FLESH );
			MESSAGE_END();

			return;
		}
		else
			CBaseMonster::RunTask(pTask);
		break;

	case TASK_FLAME_SWEEP:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			FlameDestroy();
			TaskComplete();
			FlameControls( 0, 0 );
			SetBoneController( 0, 0 );
			SetBoneController( 1, 0 );
		}
		else
		{
			BOOL cancel = FALSE;

			Vector angles = g_vecZero;

			FlameUpdate();
			CBaseEntity *pEnemy = m_hEnemy;
			if ( pEnemy )
			{
				Vector org = GetAbsOrigin();
				org.z += 64;
				Vector dir = pEnemy->BodyTarget(org) - org;
				angles = UTIL_VecToAngles( dir );
				angles.y -= GetAbsAngles().y;
				if ( dir.Length() > 400 )
					cancel = TRUE;
			}
			if ( fabs(angles.y) > 60 )
				cancel = TRUE;
			
			if ( cancel )
			{
				m_flWaitFinished -= 0.5;
				m_flameTime -= 0.5;
			}
			// FlameControls( angles.x + 2 * sin(gpGlobals->time*8), angles.y + 28 * sin(gpGlobals->time*8.5) );
			FlameControls( angles.x, angles.y );
		}
		break;

	default:
		CBaseMonster::RunTask( pTask );
		break;
	}
}
//***********************************************************************************************
CBCGPRibbonStatusBarPane::~CBCGPRibbonStatusBarPane()
{
	StopAnimation ();
}
예제 #12
0
/* void notify(in nsITimer timer); */
NS_IMETHODIMP imgContainer::Notify(nsITimer *timer)
{
  // Note that as long as the image is animated, it will not be discarded, 
  // so this should never happen...
  nsresult rv = RestoreDiscardedData();
  NS_ENSURE_SUCCESS(rv, rv);

  // This should never happen since the timer is only set up in StartAnimation()
  // after mAnim is checked to exist.
  NS_ENSURE_TRUE(mAnim, NS_ERROR_UNEXPECTED);
  NS_ASSERTION(mAnim->timer == timer,
               "imgContainer::Notify() called with incorrect timer");

  if (!mAnim->animating || !mAnim->timer)
    return NS_OK;

  nsCOMPtr<imgIContainerObserver> observer(do_QueryReferent(mObserver));
  if (!observer) {
    // the imgRequest that owns us is dead, we should die now too.
    StopAnimation();
    return NS_OK;
  }

  if (mNumFrames == 0)
    return NS_OK;
  
  gfxIImageFrame *nextFrame = nsnull;
  PRInt32 previousFrameIndex = mAnim->currentAnimationFrameIndex;
  PRInt32 nextFrameIndex = mAnim->currentAnimationFrameIndex + 1;
  PRInt32 timeout = 0;

  // If we're done decoding the next frame, go ahead and display it now and
  // reinit the timer with the next frame's delay time.
  // currentDecodingFrameIndex is not set until the second frame has
  // finished decoding (see EndFrameDecode)
  if (mAnim->doneDecoding || 
      (nextFrameIndex < mAnim->currentDecodingFrameIndex)) {
    if (mNumFrames == nextFrameIndex) {
      // End of Animation

      // If animation mode is "loop once", it's time to stop animating
      if (mAnimationMode == kLoopOnceAnimMode || mLoopCount == 0) {
        StopAnimation();
        return NS_OK;
      } else {
        // We may have used compositingFrame to build a frame, and then copied
        // it back into mFrames[..].  If so, delete composite to save memory
        if (mAnim->compositingFrame && mAnim->lastCompositedFrameIndex == -1)
          mAnim->compositingFrame = nsnull;
      }

      nextFrameIndex = 0;
      if (mLoopCount > 0)
        mLoopCount--;
    }

    if (!(nextFrame = mFrames[nextFrameIndex])) {
      // something wrong with the next frame, skip it
      mAnim->currentAnimationFrameIndex = nextFrameIndex;
      mAnim->timer->SetDelay(100);
      return NS_OK;
    }
    nextFrame->GetTimeout(&timeout);

  } else if (nextFrameIndex == mAnim->currentDecodingFrameIndex) {
    // Uh oh, the frame we want to show is currently being decoded (partial)
    // Wait a bit and try again
    mAnim->timer->SetDelay(100);
    return NS_OK;
  } else { //  (nextFrameIndex > currentDecodingFrameIndex)
    // We shouldn't get here. However, if we are requesting a frame
    // that hasn't been decoded yet, go back to the last frame decoded
    NS_WARNING("imgContainer::Notify()  Frame is passed decoded frame");
    nextFrameIndex = mAnim->currentDecodingFrameIndex;
    if (!(nextFrame = mFrames[nextFrameIndex])) {
      // something wrong with the next frame, skip it
      mAnim->currentAnimationFrameIndex = nextFrameIndex;
      mAnim->timer->SetDelay(100);
      return NS_OK;
    }
    nextFrame->GetTimeout(&timeout);
  }

  if (timeout > 0)
    mAnim->timer->SetDelay(timeout);
  else
    StopAnimation();

  nsIntRect dirtyRect;
  gfxIImageFrame *frameToUse = nsnull;

  if (nextFrameIndex == 0) {
    frameToUse = nextFrame;
    dirtyRect = mAnim->firstFrameRefreshArea;
  } else {
    gfxIImageFrame *prevFrame = mFrames[previousFrameIndex];
    if (!prevFrame)
      return NS_OK;

    // Change frame and announce it
    if (NS_FAILED(DoComposite(&frameToUse, &dirtyRect, prevFrame,
                              nextFrame, nextFrameIndex))) {
      // something went wrong, move on to next
      NS_WARNING("imgContainer::Notify(): Composing Frame Failed\n");
      mAnim->currentAnimationFrameIndex = nextFrameIndex;
      return NS_OK;
    }
  }
  // Set currentAnimationFrameIndex at the last possible moment
  mAnim->currentAnimationFrameIndex = nextFrameIndex;
  // Refreshes the screen
  observer->FrameChanged(this, frameToUse, &dirtyRect);
  
  return NS_OK;
}
예제 #13
0
	CFadeButtonUI::~CFadeButtonUI()
	{
		StopAnimation();
		CControlUI::~CControlUI();
	}
예제 #14
0
	CFadeAnimation::~CFadeAnimation()
	{
		StopAnimation();
	}
예제 #15
0
//=========================================================
// RunTask
//=========================================================
void CNPC_Gargantua::RunTask( const Task_t *pTask )
{
	switch ( pTask->iTask )
	{
	case TASK_DIE:

		if ( gpGlobals->curtime > m_flWaitFinished )
		{
			//TEMP TEMP
			m_nRenderFX = kRenderFxExplode;
			SetRenderColor( 255, 0, 0 , 255 );
			StopAnimation();
			SetNextThink( gpGlobals->curtime + 0.15 );
			SetThink( &CBaseEntity::SUB_Remove );

			int i;
		
			int parts = modelinfo->GetModelFrameCount( modelinfo->GetModel( gGargGibModel ) );

			for ( i = 0; i < 10; i++ )
			{
				CGib *pGib = CREATE_ENTITY( CGib, "gib" );

				pGib->Spawn( GARG_GIB_MODEL);
				
				int bodyPart = 0;

				if ( parts > 1 )
					 bodyPart = random->RandomInt( 0, parts-1 );

				pGib->SetBodygroup( 0, bodyPart );
				pGib->SetBloodColor( BLOOD_COLOR_YELLOW );
				pGib->m_material = matNone;
				pGib->SetAbsOrigin( GetAbsOrigin() );
				pGib->SetAbsVelocity( UTIL_RandomBloodVector() * random->RandomFloat( 300, 500 ) );
	
				pGib->SetNextThink( gpGlobals->curtime + 1.25 );
				pGib->SetThink( &CBaseEntity::SUB_FadeOut );
			}
	
			Vector vecSize = Vector( 200, 200, 128 );
			CPVSFilter filter( GetAbsOrigin() );
			te->BreakModel( filter, 0.0, GetAbsOrigin(), vec3_angle, vecSize, vec3_origin, 
				gGargGibModel, 200, 50, 3.0, BREAK_FLESH );
	
			return;
		}
		else
			BaseClass::RunTask( pTask );
		break;

	case TASK_FLAME_SWEEP:
		if ( gpGlobals->curtime > m_flWaitFinished )
		{
			//TEMP TEMP
			FlameDestroy();
			TaskComplete();
			FlameControls( 0, 0 );
			SetBoneController( 0, 0 );
			SetBoneController( 1, 0 );
		}
		else
		{
			bool cancel = false;

			QAngle angles = QAngle( 0, 0, 0 );

			//TEMP TEMP
			FlameUpdate();
			CBaseEntity *pEnemy = GetEnemy();

			if ( pEnemy )
			{
				Vector org = GetAbsOrigin();
				org.z += 64;
				Vector dir = pEnemy->BodyTarget(org) - org;

				VectorAngles( dir, angles );
				angles.x = -angles.x;
				angles.y -= GetAbsAngles().y;

				if ( dir.Length() > 400 )
					cancel = true;
			}
			if ( fabs(angles.y) > 60 )
				cancel = true;
			
			if ( cancel )
			{
				m_flWaitFinished -= 0.5;
				m_flameTime -= 0.5;
			}

			//TEMP TEMP
			//FlameControls( angles.x + 2 * sin(gpGlobals->curtime*8), angles.y + 28 * sin(gpGlobals->curtime*8.5) );
			FlameControls( angles.x, angles.y );
		}
		break;

	default:
		BaseClass::RunTask( pTask );
		break;
	}
}
예제 #16
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}
/* Destructeur */
SceneBasement::~SceneBasement()
{
   XDELETE(_lpTimerGhost);
   _lpGhostVoice->stopStream();
   StopAnimation("basement_ghostup_anim");
}
예제 #18
0
	CFadeButtonUI::~CFadeButtonUI()
	{
		StopAnimation();
	}
예제 #19
0
void CGargantua::RunTask( const Task_t& task )
{
	switch ( task.iTask )
	{
	case TASK_DIE:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			SetRenderFX( kRenderFxExplode );
			SetRenderColor( Vector( 255, 0, 0 ) );
			StopAnimation();
			SetNextThink( gpGlobals->time + 0.15 );
			SetThink( &CGargantua::SUB_Remove );
			int i;
			int parts = MODEL_FRAMES( gGargGibModel );
			for ( i = 0; i < 10; i++ )
			{
				auto pGib = CGib::GibCreate( GARG_GIB_MODEL );
				
				int bodyPart = 0;
				if ( parts > 1 )
					bodyPart = RANDOM_LONG( 0, GetBody() -1 );

				pGib->SetBody( bodyPart );
				pGib->m_bloodColor = BLOOD_COLOR_YELLOW;
				pGib->m_material = matNone;
				pGib->SetAbsOrigin( GetAbsOrigin() );
				pGib->SetAbsVelocity( UTIL_RandomBloodVector() * RANDOM_FLOAT( 300, 500 ) );
				pGib->SetNextThink( gpGlobals->time + 1.25 );
				pGib->SetThink( &CGib::SUB_FadeOut );
			}
			MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, GetAbsOrigin() );
				WRITE_BYTE( TE_BREAKMODEL);

				// position
				WRITE_COORD( GetAbsOrigin().x );
				WRITE_COORD( GetAbsOrigin().y );
				WRITE_COORD( GetAbsOrigin().z );

				// size
				WRITE_COORD( 200 );
				WRITE_COORD( 200 );
				WRITE_COORD( 128 );

				// velocity
				WRITE_COORD( 0 ); 
				WRITE_COORD( 0 );
				WRITE_COORD( 0 );

				// randomization
				WRITE_BYTE( 200 ); 

				// Model
				WRITE_SHORT( gGargGibModel );	//model id#

				// # of shards
				WRITE_BYTE( 50 );

				// duration
				WRITE_BYTE( 20 );// 3.0 seconds

				// flags

				WRITE_BYTE( BREAK_FLESH );
			MESSAGE_END();

			return;
		}
		else
			CBaseMonster::RunTask( task );
		break;

	case TASK_FLAME_SWEEP:
		if ( gpGlobals->time > m_flWaitFinished )
		{
			FlameDestroy();
			TaskComplete();
			FlameControls( 0, 0 );
			SetBoneController( 0, 0 );
			SetBoneController( 1, 0 );
		}
		else
		{
			bool cancel = false;

			Vector angles = g_vecZero;

			FlameUpdate();
			CBaseEntity *pEnemy = m_hEnemy;
			if ( pEnemy )
			{
				Vector org = GetAbsOrigin();
				org.z += 64;
				Vector dir = pEnemy->BodyTarget(org) - org;
				angles = UTIL_VecToAngles( dir );
				angles.x = -angles.x;
				angles.y -= GetAbsAngles().y;
				if ( dir.Length() > 400 )
					cancel = true;
			}
			if ( fabs(angles.y) > 60 )
				cancel = true;
			
			if ( cancel )
			{
				m_flWaitFinished -= 0.5;
				m_flameTime -= 0.5;
			}
			// FlameControls( angles.x + 2 * sin(gpGlobals->time*8), angles.y + 28 * sin(gpGlobals->time*8.5) );
			FlameControls( angles.x, angles.y );
		}
		break;

	default:
		CBaseMonster::RunTask( task );
		break;
	}
}
예제 #20
0
//=========================================================
// RunTask 
//=========================================================
void CBaseMonster :: RunTask ( Task_t *pTask )
{
	switch ( pTask->iTask )
	{
	case TASK_TURN_RIGHT:
	case TASK_TURN_LEFT:
		{
			ChangeYaw( pev->yaw_speed );

			if ( FacingIdeal() )
			{
				TaskComplete();
			}
			break;
		}

	case TASK_PLAY_SEQUENCE_FACE_ENEMY:
	case TASK_PLAY_SEQUENCE_FACE_TARGET:
		{
			CBaseEntity *pTarget;

			if ( pTask->iTask == TASK_PLAY_SEQUENCE_FACE_TARGET )
				pTarget = m_hTargetEnt;
			else
				pTarget = m_hEnemy;
			if ( pTarget )
			{
				pev->ideal_yaw = UTIL_VecToYaw( pTarget->pev->origin - pev->origin );
				ChangeYaw( pev->yaw_speed );
			}
			if ( m_fSequenceFinished )
				TaskComplete();
		}
		break;

	case TASK_PLAY_SEQUENCE:
	case TASK_PLAY_ACTIVE_IDLE:
		{
			if ( m_fSequenceFinished )
			{
				TaskComplete();
			}
			break;
		}


	case TASK_FACE_ENEMY:
		{
			MakeIdealYaw( m_vecEnemyLKP );

			ChangeYaw( pev->yaw_speed );

			if ( FacingIdeal() )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_FACE_HINTNODE:
	case TASK_FACE_LASTPOSITION:
	case TASK_FACE_TARGET:
	case TASK_FACE_IDEAL:
	case TASK_FACE_ROUTE:
		{
			ChangeYaw( pev->yaw_speed );

			if ( FacingIdeal() )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_WAIT_PVS:
		{
			if ( !FNullEnt(FIND_CLIENT_IN_PVS(edict())) )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_WAIT_INDEFINITE:
		{
			// don't do anything.
			break;
		}
	case TASK_WAIT:
	case TASK_WAIT_RANDOM:
		{
			if ( gpGlobals->time >= m_flWaitFinished )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_WAIT_FACE_ENEMY:
		{
			MakeIdealYaw ( m_vecEnemyLKP );
			ChangeYaw( pev->yaw_speed ); 

			if ( gpGlobals->time >= m_flWaitFinished )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_MOVE_TO_TARGET_RANGE:
		{
			float distance;

			if ( m_hTargetEnt == NULL )
				TaskFail();
			else
			{
				distance = ( m_vecMoveGoal - pev->origin ).Length2D();
				// Re-evaluate when you think your finished, or the target has moved too far
				if ( (distance < pTask->flData) || (m_vecMoveGoal - m_hTargetEnt->pev->origin).Length() > pTask->flData * 0.5 )
				{
					m_vecMoveGoal = m_hTargetEnt->pev->origin;
					distance = ( m_vecMoveGoal - pev->origin ).Length2D();
					FRefreshRoute();
				}

				// Set the appropriate activity based on an overlapping range
				// overlap the range to prevent oscillation
				if ( distance < pTask->flData )
				{
					TaskComplete();
					RouteClear();		// Stop moving
				}
				else if ( distance < 190 && m_movementActivity != ACT_WALK )
					m_movementActivity = ACT_WALK;
				else if ( distance >= 270 && m_movementActivity != ACT_RUN )
					m_movementActivity = ACT_RUN;
			}

			break;
		}
	case TASK_WAIT_FOR_MOVEMENT:
		{
			if (MovementIsComplete())
			{
				TaskComplete();
				RouteClear();		// Stop moving
			}
			break;
		}
	case TASK_DIE:
		{
			if ( m_fSequenceFinished && pev->frame >= 255 )
			{
				pev->deadflag = DEAD_DEAD;
				
				SetThink ( NULL );
				StopAnimation();

				if ( !BBoxFlat() )
				{
					// a bit of a hack. If a corpses' bbox is positioned such that being left solid so that it can be attacked will
					// block the player on a slope or stairs, the corpse is made nonsolid. 
//					pev->solid = SOLID_NOT;
					UTIL_SetSize ( pev, Vector ( -4, -4, 0 ), Vector ( 4, 4, 1 ) );
				}
				else // !!!HACKHACK - put monster in a thin, wide bounding box until we fix the solid type/bounding volume problem
					UTIL_SetSize ( pev, Vector ( pev->mins.x, pev->mins.y, pev->mins.z ), Vector ( pev->maxs.x, pev->maxs.y, pev->mins.z + 1 ) );

				if ( ShouldFadeOnDeath() )
				{
					// this monster was created by a monstermaker... fade the corpse out.
					SUB_StartFadeOut();
				}
				else
				{
					// body is gonna be around for a while, so have it stink for a bit.
					CSoundEnt::InsertSound ( bits_SOUND_CARCASS, pev->origin, 384, 30 );
				}
			}
			break;
		}
	case TASK_RANGE_ATTACK1_NOTURN:
	case TASK_MELEE_ATTACK1_NOTURN:
	case TASK_MELEE_ATTACK2_NOTURN:
	case TASK_RANGE_ATTACK2_NOTURN:
	case TASK_RELOAD_NOTURN:
		{
			if ( m_fSequenceFinished )
			{
				m_Activity = ACT_RESET;
				TaskComplete();
			}
			break;
		}
	case TASK_RANGE_ATTACK1:
	case TASK_MELEE_ATTACK1:
	case TASK_MELEE_ATTACK2:
	case TASK_RANGE_ATTACK2:
	case TASK_SPECIAL_ATTACK1:
	case TASK_SPECIAL_ATTACK2:
	case TASK_RELOAD:
		{
			MakeIdealYaw ( m_vecEnemyLKP );
			ChangeYaw ( pev->yaw_speed );

			if ( m_fSequenceFinished )
			{
				m_Activity = ACT_RESET;
				TaskComplete();
			}
			break;
		}
	case TASK_SMALL_FLINCH:
		{
			if ( m_fSequenceFinished )
			{
				TaskComplete();
			}
		}
		break;
	case TASK_WAIT_FOR_SCRIPT:
		{
			if ( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime )
			{
				TaskComplete();
			}
			break;
		}
	case TASK_PLAY_SCRIPT:
		{
//			ALERT(at_console, "Play Script\n");
			if (m_fSequenceFinished)
			{
//				ALERT(at_console, "Anim Finished\n");
				if (m_pCine->m_iRepeatsLeft > 0)
				{
//					ALERT(at_console, "Frame %f; Repeat %d from %f\n", pev->frame, m_pCine->m_iRepeatsLeft, m_pCine->m_fRepeatFrame);
					m_pCine->m_iRepeatsLeft--;
					pev->frame = m_pCine->m_fRepeatFrame;
					ResetSequenceInfo( );
				}
				else
				{
					TaskComplete();
				}
			}
			break;
		}
	}
}
예제 #21
0
//////////////////////////////////////////////////////////////////////
/// Draw
void COGLWin::Draw()
{

	if (!m_Parse.IsCodeOK())
	{
		m_ToolBox.ResetToolInUseFlags();
		// Keep fixed tools but do not redraw here
		m_ToolBox.PruneToolMap(true, false);
		// Redraw tools here explicitly
//		m_ToolBox.Update();

		if (m_pOutput)
			m_pOutput->SetText(" ");
	
		// Standard reason for re-evaluation of script.
		SetExecModeVar(EXEC_MODE_NONE);

		return;
	}

	// Set standard color
	if (m_bUseLighting)
	{
		m_Filter.SetColor(MGray);
		m_StdMaterial.Apply();
	}
	else
	{
		m_Filter.SetColor(MGray);
	}

	m_ToolBox.ResetToolInUseFlags();
	m_Parse.ToggleTempImageList();
	m_Parse.ResetTempImageList();

	// Reset Filter Modes
	m_Filter.ResetModes();
	m_bFrameTransChanged = false;
	MultiV<float> vR(m_vRMain);

	m_mTransform[0].ResetTransChanged();

	ClearOutput();
	ClearError();
	//m_Parse.ResetTempVexList();

	if (!m_Parse.RunCode())
	{
		int iErrLine, iErrPos, iErrInPos;
		cStr csErrFile, csText;
		CCLUCodeBase::SOutputObject OutObj;
/*
		m_sError = "<b>Runtime Errors:</b><p>";
		m_sError += m_Parse.PrintCodeErrors().Str();
		m_sError += "</p> <p>";
		//csText << "Vars:\n" << m_Parse.PrintVars() << "\n";
		m_sError += "<b>Stack:</b><br> <br>";
		m_sError += m_Parse.PrintStack().Str();
		m_sError += "</p>";
*/

		OutObj.sName = "Output up to Error";
		OutObj.bCanChangeSize = false;
		OutObj.bCanHideValue = false;
		OutObj.bBRAfterValue = true;
		OutObj.bBRBeforeValue = true;
		OutObj.bShowInfo = false;
		OutObj.bShowValue = true;
		OutObj.sRelSym = ":";
		OutObj.sType = " ";
		OutObj.iSize = 0;
		OutObj.sValue = " ";
		m_Parse.InsertOutputObject(OutObj);

		OutObj.sName = "Stack";
		OutObj.bCanChangeSize = true;
		OutObj.bCanHideValue = true;
		OutObj.bBRAfterValue = true;
		OutObj.bBRBeforeValue = true;
		OutObj.bShowInfo = false;
		OutObj.bShowValue = false;
		OutObj.sRelSym = ":";
		OutObj.sType = "stack";
		OutObj.iSize = 0;
		OutObj.sValue = m_Parse.PrintStack().Str();
		m_Parse.InsertOutputObject(OutObj);

		OutObj.sName = "Runtime Error";
		OutObj.bCanChangeSize = false;
		OutObj.bCanHideValue = true;
		OutObj.bBRAfterValue = true;
		OutObj.bBRBeforeValue = true;
		OutObj.bShowInfo = true;
		OutObj.bShowValue = true;
		OutObj.sRelSym = " ";
		OutObj.sType = "error message";
		OutObj.iSize = 0;

		m_Parse.GetCodeErrorPos(iErrLine, iErrPos, iErrInPos, csErrFile);
		csText = "";
		csText << "Line " << iErrLine << ", Pos " << iErrPos;
		OutObj.sInfo = csText;

		csText = "<font size=\"10\">File: <i>";
		csText << csErrFile << "</i></font><p>";
		csText << m_Parse.PrintCodeErrors().Str();
		OutObj.sValue = csText;

		m_Parse.InsertOutputObject(OutObj);

		m_bHasError = true;
		m_bHasOutput = true;

/*
		cStr &rText = m_Parse.GetTextOutput();

		if (rText.Len())
		{
			m_sError += "<br><b>Script Output:</b><br> <br>";
			m_sError += rText.Str();
		}
*/
/*
		if (m_pOutput && !m_bVizOnlyMode)
		{
			m_pOutput->SetText(m_sError.c_str());
			m_pOutput->show();
		}
*/		//ClearError();

		if (m_pEditor && !m_bVizOnlyMode)
		{
			cStr csFilename;
			int iLine, iPos, iInputPos;

			if (m_Parse.GetCodeErrorPos(iLine, iPos, iInputPos, csFilename))
				m_pEditor->HighlightLinePos(csFilename.Str(), iInputPos);

			m_pEditor->show();
		}

		m_Parse.ResetErrors();

		m_bExecCode = false;
		SetAnimCode(false);
		StopAnimation();

		m_Parse.OverrideSetRenderLatex(false);
	}
	else 
	{
		//m_vecOutObj = m_Parse.GetOutputObjectList();
		//cStr &rText = m_Parse.GetTextOutput();

		m_bHasOutput = true;

		if (m_mTransform[0].HasTransChanged(0) ||
			m_mTransform[0].HasTransChanged(1) ||
			m_mTransform[0].HasTransChanged(2))
		{
			m_mTransform[0].iFlags = 0;
			m_bFrameTransChanged = true;
		}

		if (vR != m_vRMain)
		{
			m_bFrameTransChanged = true;
		}

		m_Parse.OverrideSetRenderLatex(false);
	}

	// Keep fixed tools but do not redraw here
	m_ToolBox.PruneToolMap(true, false);

	// Redraw tools here explicitly
//	m_ToolBox.Update();

	// Reset Tool Name Variable
	if (m_iExecMode & 
		(EXEC_MODE_TOOL | EXEC_MODE_LINK | EXEC_MODE_KEYUP | EXEC_MODE_KEYDOWN | EXEC_MODE_ANIM))
	{
		SetToolNameVar("None");
		SetLinkDataVar("None");
	}

	// Standard reason for re-evaluation of script.
	SetExecModeVar(EXEC_MODE_NONE);
}
예제 #22
0
BOOL CBaseMonster::CineCleanup()
{
	CCineMonster *pOldCine = m_pCine;

	// am I linked to a cinematic?
	if(m_pCine)
	{
		// okay, reset me to what it thought I was before
		m_pCine->m_hTargetEnt = NULL;
		pev->movetype         = m_pCine->m_saved_movetype;
		pev->solid            = m_pCine->m_saved_solid;
		pev->effects          = m_pCine->m_saved_effects;
	}
	else
	{
		// arg, punt
		pev->movetype = MOVETYPE_STEP; // this is evil
		pev->solid    = SOLID_SLIDEBOX;
	}
	m_pCine      = NULL;
	m_hTargetEnt = NULL;
	m_pGoalEnt   = NULL;
	if(pev->deadflag == DEAD_DYING)
	{
		// last frame of death animation?
		pev->health    = 0;
		pev->framerate = 0.0;
		pev->solid     = SOLID_NOT;
		SetState(MONSTERSTATE_DEAD);
		pev->deadflag = DEAD_DEAD;
		UTIL_SetSize(pev, pev->mins, Vector(pev->maxs.x, pev->maxs.y, pev->mins.z + 2));

		if(pOldCine && FBitSet(pOldCine->pev->spawnflags, SF_SCRIPT_LEAVECORPSE))
		{
			SetUse(NULL);   // BUGBUG -- This doesn't call Killed()
			SetThink(NULL); // This will probably break some stuff
			SetTouch(NULL);
		}
		else
			SUB_StartFadeOut(); // SetThink( SUB_DoNothing );
		// This turns off animation & physics in case their origin ends up stuck in the world or something
		StopAnimation();
		pev->movetype = MOVETYPE_NONE;
		pev->effects |= EF_NOINTERP; // Don't interpolate either, assume the corpse is positioned in its final resting place
		return FALSE;
	}

	// If we actually played a sequence
	if(pOldCine && pOldCine->m_iszPlay)
	{
		if(!(pOldCine->pev->spawnflags & SF_SCRIPT_NOSCRIPTMOVEMENT))
		{
			// reset position
			Vector new_origin, new_angle;
			GetBonePosition(0, new_origin, new_angle);

			// Figure out how far they have moved
			// We can't really solve this problem because we can't query the movement of the origin relative
			// to the sequence.  We can get the root bone's position as we do here, but there are
			// cases where the root bone is in a different relative position to the entity's origin
			// before/after the sequence plays.  So we are stuck doing this:

			// !!!HACKHACK: Float the origin up and drop to floor because some sequences have
			// irregular motion that can't be properly accounted for.

			// UNDONE: THIS SHOULD ONLY HAPPEN IF WE ACTUALLY PLAYED THE SEQUENCE.
			Vector oldOrigin = pev->origin;

			// UNDONE: ugly hack.  Don't move monster if they don't "seem" to move
			// this really needs to be done with the AX,AY,etc. flags, but that aren't consistantly
			// being set, so animations that really do move won't be caught.
			if((oldOrigin - new_origin).Length2D() < 8.0)
				new_origin = oldOrigin;

			pev->origin.x = new_origin.x;
			pev->origin.y = new_origin.y;
			pev->origin.z += 1;

			pev->flags |= FL_ONGROUND;
			int drop = DROP_TO_FLOOR(ENT(pev));

			// Origin in solid?  Set to org at the end of the sequence
			if(drop < 0)
				pev->origin = oldOrigin;
			else if(drop == 0) // Hanging in air?
			{
				pev->origin.z = new_origin.z;
				pev->flags &= ~FL_ONGROUND;
			}
			// else entity hit floor, leave there

			// pEntity->pev->origin.z = new_origin.z + 5.0; // damn, got to fix this

			UTIL_SetOrigin(pev, pev->origin);
			pev->effects |= EF_NOINTERP;
		}

		// We should have some animation to put these guys in, but for now it's idle.
		// Due to NOINTERP above, there won't be any blending between this anim & the sequence
		m_Activity = ACT_RESET;
	}
	// set them back into a normal state
	pev->enemy = NULL;
	if(pev->health > 0)
		m_IdealMonsterState = MONSTERSTATE_IDLE; // m_previousState;
	else
	{
		// Dropping out because he got killed
		// Can't call killed() no attacker and weirdness (late gibbing) may result
		m_IdealMonsterState = MONSTERSTATE_DEAD;
		SetConditions(bits_COND_LIGHT_DAMAGE);
		pev->deadflag = DEAD_DYING;
		FCheckAITrigger();
		pev->deadflag = DEAD_NO;
	}

	//	SetAnimation( m_MonsterState );
	ClearBits(pev->spawnflags, SF_MONSTER_WAIT_FOR_SCRIPT);

	return TRUE;
}
예제 #23
0
void CBasePlayer::PlayerDeathThink()
{
	if( GetFlags().Any( FL_ONGROUND ) )
	{
		const float flForward = GetAbsVelocity().Length() - 20;
		if( flForward <= 0 )
			SetAbsVelocity( g_vecZero );
		else
			SetAbsVelocity( flForward * GetAbsVelocity().Normalize() );
	}

	if( HasWeapons() )
	{
		// we drop the guns here because weapons that have an area effect and can kill their user
		// will sometimes crash coming back from CBasePlayer::Killed() if they kill their owner because the
		// player class sometimes is freed. It's safer to manipulate the weapons once we know
		// we aren't calling into any of their code anymore through the player pointer.
		PackDeadPlayerItems();
	}


	if( GetModelIndex() && ( !m_fSequenceFinished ) && ( GetDeadFlag() == DEAD_DYING ) )
	{
		StudioFrameAdvance();

		m_iRespawnFrames++;				// Note, these aren't necessarily real "frames", so behavior is dependent on # of client movement commands
		if( m_iRespawnFrames < 120 )   // Animations should be no longer than this
			return;
	}

	// once we're done animating our death and we're on the ground, we want to set movetype to None so our dead body won't do collisions and stuff anymore
	// this prevents a bug where the dead body would go to a player's head if he walked over it while the dead player was clicking their button to respawn
	if( GetMoveType() != MOVETYPE_NONE && GetFlags().Any( FL_ONGROUND ) )
		SetMoveType( MOVETYPE_NONE );

	if( GetDeadFlag() == DEAD_DYING )
		SetDeadFlag( DEAD_DEAD );

	StopAnimation();

	GetEffects() |= EF_NOINTERP;
	SetFrameRate( 0.0 );

	const bool fAnyButtonDown = ( GetButtons().Any( ~IN_SCORE ) ) != 0;

	// wait for all buttons released
	if( GetDeadFlag() == DEAD_DEAD )
	{
		if( fAnyButtonDown )
			return;

		if( g_pGameRules->FPlayerCanRespawn( this ) )
		{
			m_fDeadTime = gpGlobals->time;
			SetDeadFlag( DEAD_RESPAWNABLE );
		}

		return;
	}

	// if the player has been dead for one second longer than allowed by forcerespawn, 
	// forcerespawn isn't on. Send the player off to an intermission camera until they 
	// choose to respawn.
	if( g_pGameRules->IsMultiplayer() && ( gpGlobals->time > ( m_fDeadTime + 6 ) ) && !( m_afPhysicsFlags & PFLAG_OBSERVER ) )
	{
		// go to dead camera. 
		StartDeathCam();
	}

	if( IsObserver() )	// player is in spectator mode
		return;

	// wait for any button down,  or mp_forcerespawn is set and the respawn time is up
	if( !fAnyButtonDown
		&& !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && ( gpGlobals->time > ( m_fDeadTime + 5 ) ) ) )
		return;

	GetButtons().ClearAll();
	m_iRespawnFrames = 0;

	//ALERT(at_console, "Respawn\n");

	g_pGameRules->PlayerRespawn( this, !( m_afPhysicsFlags & PFLAG_OBSERVER ) );// don't copy a corpse if we're in deathcam.
	SetNextThink( -1 );
}