Exemple #1
0
bool Prop::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Anim("ANIM");
	static CParsedMsg::CToken s_cTok_AnimLoop("ANIMLOOP");
	static CParsedMsg::CToken s_cTok_Activate("ACTIVATE");
	static CParsedMsg::CToken s_cTok_Remove("REMOVE");
	static CParsedMsg::CToken s_cTok_Destroy("DESTROY");

	uint32 dwFlags;
	g_pCommonLT->GetObjectFlags(m_hObject, OFT_User, dwFlags);

	if ( cMsg.GetArg(0) == s_cTok_Anim )
	{
        g_pLTServer->SetModelLooping(m_hObject, LTFALSE);
        g_pLTServer->SetModelAnimation(m_hObject, g_pLTServer->GetAnimIndex(m_hObject, ( char* )( char const* )cMsg.GetArg( 1 )));
		g_pLTServer->ResetModelAnimation(m_hObject);
		SetNextUpdate(UPDATE_NEXT_FRAME); // Needed to get string keys
	}
	else if ( cMsg.GetArg(0) == s_cTok_AnimLoop )
	{
        g_pLTServer->SetModelLooping(m_hObject, LTTRUE);
        g_pLTServer->SetModelAnimation(m_hObject, g_pLTServer->GetAnimIndex(m_hObject, ( char* )( char const* )cMsg.GetArg( 1 )));
		g_pLTServer->ResetModelAnimation(m_hObject);
		SetNextUpdate(UPDATE_NEXT_FRAME); // Needed to get string keys
	}
	else if ( cMsg.GetArg(0) == s_cTok_Activate )
	{
		if(dwFlags & USRFLG_CAN_ACTIVATE)
		{
			SendActivateMessage( );

 			HandleTouch(hSender);
		}
	}
	else if( cMsg.GetArg(0) == s_cTok_Remove )
	{
		// Remove us...

		g_pLTServer->RemoveObject( m_hObject );
	}
	else if( cMsg.GetArg(0) == s_cTok_Destroy )
	{
		m_damage.HandleDestruction( LTNULL );
		HandleDestroy( LTNULL );
	}
	else
	{
		return GameBase::OnTrigger(hSender, cMsg);
	}

	return true;
}
FReply SVirtualJoystick::OnTouchStarted(const FGeometry& MyGeometry, const FPointerEvent& Event)
{
//	UE_LOG(LogTemp, Log, TEXT("Pointer index: %d"), Event.GetPointerIndex());

	FVector2D LocalCoord = MyGeometry.AbsoluteToLocal( Event.GetScreenSpacePosition() );

	for (int32 ControlIndex = 0; ControlIndex < Controls.Num(); ControlIndex++)
	{
		FControlInfo& Control = Controls[ControlIndex];

		// skip controls already in use
		if (Control.CapturedPointerIndex == -1)
		{
			if (PositionIsInside(Control, LocalCoord, Control.InteractionSize))
			{
				// Align Joystick inside of Screen
				AlignBoxIntoScreen(LocalCoord, Control.VisualSize, MyGeometry.Size);

				Control.CapturedPointerIndex = Event.GetPointerIndex();

				if (ActivationDelay == 0.f)
				{
					CurrentOpacity = ActiveOpacity;

					if (!bPreventReCenter)
					{
						Control.VisualCenter = LocalCoord;
					}

					if (HandleTouch(ControlIndex, LocalCoord, MyGeometry.Size)) // Never fail!
					{
						return FReply::Handled();
					}
				}
				else
				{
					Control.bNeedUpdatedCenter = true;
					Control.ElapsedTime = 0.f;
					Control.NextCenter = LocalCoord;

					return FReply::Unhandled();
				}
			}
		}
	}

//	CapturedPointerIndex[CapturedJoystick] = -1;

	return FReply::Unhandled();
}
Exemple #3
0
void View::ProcessQTouchEvent(QTouchEvent* pEvent)
{
    const QList<QTouchEvent::TouchPoint>& touchPoints = pEvent->touchPoints();

    for (int i=0; i < touchPoints.size(); i++)
    {
        const QTouchEvent::TouchPoint& touchPoint = touchPoints.at(i);

        if (!touchPoint.isPrimary())
        {
            int state = touchPoint.state();
            QPointF pos = touchPoint.pos();

            TouchEvent touchEvent;
            touchEvent.x  = pos.x();
            touchEvent.y  = pos.y();
            touchEvent.id = touchPoint.id() + 1;

            if (state == Qt::TouchPointMoved)
            {
                touchEvent.type = TouchEvent::Type_Move;
                HandleTouch(&touchEvent);
            }
            else if (state == Qt::TouchPointPressed)
            {
                touchEvent.type = TouchEvent::Type_Press;
                HandleTouch(&touchEvent);
            }
            else if (state == Qt::TouchPointReleased)
            {
                touchEvent.type = TouchEvent::Type_Release;
                HandleTouch(&touchEvent);
            }
        }
    }
}
FReply SVirtualJoystick::OnTouchMoved(const FGeometry& MyGeometry, const FPointerEvent& Event)
{
	FVector2D LocalCoord = MyGeometry.AbsoluteToLocal( Event.GetScreenSpacePosition() );

	for (int32 ControlIndex = 0; ControlIndex < Controls.Num(); ControlIndex++)
	{
		FControlInfo& Control = Controls[ControlIndex];

		// is this control the one captured to this pointer?
		if (Control.CapturedPointerIndex == Event.GetPointerIndex())
		{
			if (Control.bNeedUpdatedCenter)
			{
				return FReply::Unhandled();
			}
			else if (HandleTouch(ControlIndex, LocalCoord, MyGeometry.Size))
			{
				return FReply::Handled();
			}
		}
	}

	return FReply::Unhandled();
}
uint32 CProjectile::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData)
{
	switch(messageID)
	{
		case MID_UPDATE:
		{
			Update();
		}
		break;

		case MID_PRECREATE:
		{
			ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData;
			if (pStruct)
			{
				pStruct->m_Flags = m_dwFlags;

				// This will be set in Setup()...
				SAFE_STRCPY(pStruct->m_Filename, "Models\\Default.abc");

				pStruct->m_NextUpdate = UPDATE_DELTA;
			}
		}
		break;

		case MID_INITIALUPDATE:
		{
			InitialUpdate((int)fData);
		}
		break;

		case MID_TOUCHNOTIFY:
		{
			HandleTouch((HOBJECT)pData);
		}
		break;

		case MID_LINKBROKEN :
		{
			HOBJECT hLink = (HOBJECT)pData;
			if (hLink)
			{
				if (hLink == m_hFiredFrom)
				{
                    m_hFiredFrom = LTNULL;
				}
			}
		}
		break;

		case MID_SAVEOBJECT:
		{
            Save((HMESSAGEWRITE)pData, (uint32)fData);
		}
		break;

		case MID_LOADOBJECT:
		{
            Load((HMESSAGEREAD)pData, (uint32)fData);
		}
		break;

		default : break;
	}


	return GameBase::EngineMessageFn(messageID, pData, fData);
}
//---------------------------------------------------------
//---------------------------------------------------------
void CBaseSpriteProjectile::Touch( CBaseEntity *pOther )
{
	HandleTouch( pOther );
}
void SVirtualJoystick::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
	SLeafWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);

	if (State == State_WaitForStart || State == State_CountingDownToStart)
	{
		CurrentOpacity = 0.f;
	}
	else
	{
		// lerp to the desired opacity based on whether the user is interacting with the joystick
		CurrentOpacity = FMath::Lerp(CurrentOpacity, GetBaseOpacity(), OPACITY_LERP_RATE * InDeltaTime);
	}

	// count how many controls are active
	int32 NumActiveControls = 0;

	for (int32 ControlIndex = 0; ControlIndex < Controls.Num(); ControlIndex++)
	{
		FControlInfo& Control = Controls[ControlIndex];

		if (Control.bNeedUpdatedCenter)
		{
			Control.ElapsedTime += InDeltaTime;
			if (Control.ElapsedTime > ActivationDelay)
			{
				Control.bNeedUpdatedCenter = false;
				CurrentOpacity = ActiveOpacity;

				if (!bPreventReCenter)
				{
					Control.VisualCenter = Control.NextCenter;
				}

				HandleTouch(ControlIndex, Control.NextCenter, AllottedGeometry.Size);
			}
		}

		// calculate absolute positions based on geometry
		// @todo: Need to manage geometry changing!
		if (!Control.bHasBeenPositioned)
		{
			// figure out how much to scale the control sizes
			float ScaleFactor = GetScaleFactor(AllottedGeometry);

			// update all the sizes
			Control.Center = FVector2D(ResolveRelativePosition(Control.Center.X, AllottedGeometry.Size.X, ScaleFactor), ResolveRelativePosition(Control.Center.Y, AllottedGeometry.Size.Y, ScaleFactor));
			Control.VisualCenter = Control.Center;
			Control.VisualSize = FVector2D(ResolveRelativePosition(Control.VisualSize.X, AllottedGeometry.Size.X, ScaleFactor), ResolveRelativePosition(Control.VisualSize.Y, AllottedGeometry.Size.Y, ScaleFactor));
			Control.InteractionSize = FVector2D(ResolveRelativePosition(Control.InteractionSize.X, AllottedGeometry.Size.X, ScaleFactor), ResolveRelativePosition(Control.InteractionSize.Y, AllottedGeometry.Size.Y, ScaleFactor));
			Control.ThumbSize = FVector2D(ResolveRelativePosition(Control.ThumbSize.X, AllottedGeometry.Size.X, ScaleFactor), ResolveRelativePosition(Control.ThumbSize.Y, AllottedGeometry.Size.Y, ScaleFactor));
//			Control.InputScale = Control.InputScale * ScaleFactor;
			Control.bHasBeenPositioned = true;
		}

		if (Control.CapturedPointerIndex >= 0 || Control.bSendOneMoreEvent)
		{
			Control.bSendOneMoreEvent = false;

			// now pass the fake joystick events to the game
			// Assume that joystick size is all equal
			float JoysticInputSize = Control.ThumbPosition.Size() * 2.f / Control.VisualSize.X;
			FVector2D NormalizedOffset = Control.ThumbPosition.SafeNormal() * Control.InputScale * JoysticInputSize;
			EControllerButtons::Type XAxis = ControlIndex == 0 ? EControllerButtons::LeftAnalogX : EControllerButtons::RightAnalogX;
			EControllerButtons::Type YAxis = ControlIndex == 0 ? EControllerButtons::LeftAnalogY : EControllerButtons::RightAnalogY;

	//		UE_LOG(LogTemp, Log, TEXT("Joysticking %f,%f"), NormalizedOffset.X, -NormalizedOffset.Y);
			FSlateApplication::Get().SetJoystickCaptorToGameViewport();
			FSlateApplication::Get().OnControllerAnalog(Control.MainInputKey, 0, NormalizedOffset.X);
			FSlateApplication::Get().OnControllerAnalog(Control.AltInputKey, 0, -NormalizedOffset.Y);
		}

		// is this active?
		if (Control.CapturedPointerIndex != -1)
		{
			NumActiveControls++;
		}
	}


	// STATE MACHINE!
	if (NumActiveControls > 0 || bPreventReCenter)
	{
		// any active control snaps the state to active immediately
		State = State_Active;
	}
	else
	{
		switch (State)
		{
			case State_WaitForStart:
				{
					State = State_CountingDownToStart;
					Countdown = StartupDelay;
				}
				break;
			case State_CountingDownToStart:
				// update the countdown
				Countdown -= InDeltaTime;
				if (Countdown <= 0.0f)
				{
					State = State_Inactive;
				}
				break;
			case State_Active:
				if (NumActiveControls == 0)
				{
					// start going to inactive
					State = State_CountingDownToInactive;
					Countdown = TimeUntilDeactive;
				}
				break;

			case State_CountingDownToInactive:
				// update the countdown
				Countdown -= InDeltaTime;
				if (Countdown <= 0.0f)
				{
					// should we start counting down to a control reset?
					if (TimeUntilReset > 0.0f)
					{
						State = State_CountingDownToReset;
						Countdown = TimeUntilReset;
					}
					else
					{
						// if not, then just go inactive
						State = State_Inactive;
					}
				}
				break;

			case State_CountingDownToReset:
				Countdown -= InDeltaTime;
				if (Countdown <= 0.0f)
				{
					// reset all the controls
					for (int32 ControlIndex = 0; ControlIndex < Controls.Num(); ControlIndex++)
					{
						Controls[ControlIndex].Reset();
					}

					// finally, go inactive
					State = State_Inactive;
				}
				break;
		}
	}
}
Exemple #8
0
bool View::eventFilter(QObject* pTarget, QEvent* pEvent)
{
    QEvent::Type eventType = pEvent->type();

    if (eventType == QEvent::MouseMove)
    {
        TouchEvent touchEvent;

        touchEvent.x    = ((QMouseEvent*)pEvent)->x();
        touchEvent.y    = ((QMouseEvent*)pEvent)->y();
        touchEvent.id   = 0;
        touchEvent.type = TouchEvent::Type_Move;

        HandleTouch(&touchEvent);
        return true;
    }
    else if (eventType == QEvent::MouseButtonPress)
    {
        if (m_numButtonsPressed == 0)
        {
            if (((QMouseEvent*)pEvent)->button() == Qt::RightButton)
            {
                InputModeChangeEvent event;
                event.mode = InputMode_Gesture;
                m_pEventDispatcher->DispatchInputModeChangeEvent(&event);
            }

            TouchEvent touchEvent;

            touchEvent.x    = ((QMouseEvent*)pEvent)->x();
            touchEvent.y    = ((QMouseEvent*)pEvent)->y();
            touchEvent.id   = 0;
            touchEvent.type = TouchEvent::Type_Press;

            HandleTouch(&touchEvent);
        }

        m_numButtonsPressed++;
        return true;
    }
    else if (eventType == QEvent::MouseButtonRelease)
    {
        if (m_numButtonsPressed > 0)
        {
            /*
             * Only process the mouse release event if the
             * numButtonsPressed is greater than 0 since a
             * double click will send two release events for
             * every one press event which would otherwise
             * make numButtonsPressed negative.
             */

            m_numButtonsPressed--;

            if (m_numButtonsPressed == 0)
            {
                TouchEvent touchEvent;

                touchEvent.x    = ((QMouseEvent*)pEvent)->x();
                touchEvent.y    = ((QMouseEvent*)pEvent)->y();
                touchEvent.id   = 0;
                touchEvent.type = TouchEvent::Type_Release;

                HandleTouch(&touchEvent);
            }
        }

        return true;
    }
    else if ((eventType == QEvent::TouchUpdate) ||
             (eventType == QEvent::TouchBegin) ||
             (eventType == QEvent::TouchEnd))
    {
        ProcessQTouchEvent((QTouchEvent*)pEvent);
        pEvent->setAccepted(true);
        return true;
    }
    else if (eventType == QEvent::KeyPress)
    {
        KeyEvent keyEvent;
        keyEvent.id   = ((QKeyEvent*)pEvent)->key();
        keyEvent.key  = ((QKeyEvent*)pEvent)->key();
        keyEvent.type = KeyEvent::Type_Press;

        ProcessKeyPressEvent(&keyEvent);

        return true;
    }
    else if (eventType == QEvent::KeyRelease)
    {
        KeyEvent keyEvent;
        keyEvent.id   = ((QKeyEvent*)pEvent)->key();
        keyEvent.key  = ((QKeyEvent*)pEvent)->key();
        keyEvent.type = KeyEvent::Type_Release;

        ProcessKeyReleaseEvent(&keyEvent);

        return true;
    }
    else if (eventType == QEvent::Resize)
    {
        HandleResizeEvent((QResizeEvent*)pEvent);
        return false;
    }
    else if (eventType == QEvent::Close)
    {
        HandleCloseEvent((QCloseEvent*)pEvent);
        return true;
    }

    return QObject::eventFilter(pTarget, pEvent);
}
Exemple #9
0
uint32 Prop::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData)
{
	switch(messageID)
	{
		case MID_TOUCHNOTIFY:
		{
			if(m_bTouchable)
			{
				HOBJECT hToucher = (HOBJECT)pData;
				if( IsCharacterHitBox( hToucher ) )
				{
					CCharacterHitBox* pHB = (CCharacterHitBox*)g_pLTServer->HandleToObject(hToucher);
					hToucher = pHB->GetModelObject();
				}

				// Could be a body.
				if( IsCharacter(hToucher) )
				{
					HandleTouch( hToucher );
				}
			}
			else if( m_bAttachmentShotOff )
			{
				HandleAttachmentTouch( (HOBJECT)pData );
			}
		}
		break;

		case MID_UPDATE:
		{
			Update();
		}
		break;

		case MID_MODELSTRINGKEY :
		{
			HandleModelString( (ArgList*)pData );
		}
		break;

		case MID_PRECREATE:
		{
			if (fData == PRECREATE_WORLDFILE || fData == PRECREATE_STRINGPROP)
			{
				ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData;
				ReadProp(pStruct);

				// If this prop is spawned, assume it should be visible (if they
				// specify Visible 0, our parent class will handle it ;)

				if (fData == PRECREATE_STRINGPROP)
				{
					m_dwFlags |= FLAG_VISIBLE;
				}
			}

			// We must remove aggregates before sending the message to the base classs...

			if( !m_bCanTransition )
			{
				// Disallow transitioning of this object through TransAMs...

				DestroyTransitionAggregate();
			}

            uint32 dwRet = GameBase::EngineMessageFn(messageID, pData, fData);

			PostPropRead((ObjectCreateStruct*)pData);
			return dwRet;
		}
		break;

		case MID_INITIALUPDATE:
		{
			if (fData != INITIALUPDATE_SAVEGAME)
			{
				InitialUpdate();
			}
		}
		break;

		case MID_SAVEOBJECT:
		{
            Save((ILTMessage_Write*)pData, (uint32)fData);
		}
		break;

		case MID_LOADOBJECT:
		{
            Load((ILTMessage_Read*)pData, (uint32)fData);
		}
		break;

		default : break;
	}


	return GameBase::EngineMessageFn(messageID, pData, fData);
}
Exemple #10
0
void Prop::Update()
{
	if (m_bFirstUpdate && m_bMoveToFloor)
	{
		// Make sure object starts on floor...
		m_bFirstUpdate = LTFALSE;
		MoveObjectToFloor(m_hObject);

		SetNextUpdate(UPDATE_NEXT_FRAME);
	}
	else if( m_pDisturb && (m_eState == kState_PropTouching) )
	{
		HandleTouch(LTNULL);
	}
	else if( m_pDisturb && (m_eState == kState_PropHit) )
	{
		HandleHit(LTNULL);
	}
	else if( m_bRotating )
	{
		if( m_fPitchVel != 0 || m_fYawVel != 0 || m_fRollVel != 0 )
		{
			float fDeltaTime = g_pLTServer->GetFrameTime();

			m_fPitch += m_fPitchVel * fDeltaTime;
			m_fYaw   += m_fYawVel * fDeltaTime;
			m_fRoll  += m_fRollVel * fDeltaTime;

			LTRotation rRot( m_fPitch, m_fYaw, m_fRoll );
			g_pLTServer->SetObjectRotation( m_hObject, &rRot );

			SetNextUpdate(UPDATE_NEXT_FRAME);
		}
	}
	else if ( m_bFading )
	{
		UpdateFade();
	}
	else if ( m_bCanDeactivate )
	{
		// At this point the model only needs to get updates if we're playing
		// a non-looping animation so we can deactivate the object when the animation
		// is done playing.  However, if the model is playing a looping animation
		// we'll stop updating but leave the object active (so it will continue to
		// animate and get key strings)...

		// See if we're animating...

		HMODELANIM hAnim = g_pLTServer->GetModelAnimation(m_hObject);
		if (hAnim != INVALID_ANI)
		{
			if (g_pLTServer->GetModelLooping(m_hObject))
			{
				// We're playing a looping animation that is long enough, don't deactivate, 
				// just stop updating the object (since the state can only be changed 
				// externally)...NOTE: Short animations are default anis that you can't
				// see so we'll deactivate in those cases...

				uint32 nLength = 0;
				g_pModelLT->GetAnimLength(m_hObject, hAnim, nLength);
				
				if (nLength > 200)
				{
					SetNextUpdate(UPDATE_NEVER, eControlUpdateOnly);
				}
				else
				{
					SetNextUpdate(UPDATE_NEVER);
				}
			}
			else  // Playing a non-looping animation...
			{
				bool bAniDone = !!(MS_PLAYDONE & g_pLTServer->GetModelPlaybackState(m_hObject));

				if (bAniDone)
				{
					// Cool we can stop updating
					SetNextUpdate(UPDATE_NEVER);
				}
				else
				{
					// Keep updating until the animation is done...
					SetNextUpdate(UPDATE_NEXT_FRAME);
				}
			}
		}
		else  // Not animating so no reason to update...
		{
			SetNextUpdate(UPDATE_NEVER);
		}
	}
	else
	{
		// Just keep updating
		SetNextUpdate(UPDATE_NEXT_FRAME);
	}
}
Exemple #11
0
void Prop::HandleHit( HOBJECT hDamager )
{
	if( ( hDamager != LTNULL ) &&
		( !IsCharacter(hDamager) ) &&
		( !IsExplosion(hDamager) ) )
	{
		return;
	}

	if( (m_eState == kState_PropDestroyed)
		|| (m_eState == kState_PropKnocked) 
		|| (!(m_pDisturb && m_pDisturb->pPD)) )
	{
		return;
	}

	// If we don't have a valid hit animation default to the touch animation...

	if( m_pDisturb->hHitAnim == INVALID_ANI )
		HandleTouch( hDamager );

	// Resolve the toucher to a character handle.

	HOBJECT hCharacter = LTNULL;
	if( IsCharacterHitBox( hDamager ) )
	{
		CCharacterHitBox* pHB = (CCharacterHitBox*)g_pLTServer->HandleToObject(hDamager);
		hCharacter = pHB->GetModelObject();
	}
	else if( IsExplosion( hDamager ) )
	{
		Explosion* pExplosion = (Explosion*)g_pLTServer->HandleToObject(hDamager);
		hCharacter = pExplosion->GetFiredFrom();
	}
	else if( IsCharacter( hDamager ) ) 
	{
		hCharacter = hDamager;
	}

	// Only characters can hit (for now).
	if((hCharacter != LTNULL) && !IsCharacter(hCharacter)) return;

	if(m_eState == kState_PropHit)
	{
		// Check if both sound and animation are done

		ClearHitSoundIfDone( LTFALSE );
		if( m_pDisturb->hHitSound == LTNULL )
		{
			ClearHitAnimIfDone( LTFALSE );
			if( g_pLTServer->GetModelAnimation(m_hObject) != m_pDisturb->hHitAnim )
			{
				m_eState = kState_PropDefault;
				return;
			}
		}
	}
	
	// Play the hit sound and animation.

	if( (m_eState == kState_PropDefault) && (hCharacter != LTNULL))
	{
        LTVector vPos;
		g_pLTServer->GetObjectPos(m_hObject, &vPos);

		// Play sound.
		PlayHitSound(vPos);

		// Play animation.
		if(m_pDisturb->hHitAnim != INVALID_ANI)
		{
			g_pLTServer->SetModelAnimation( m_hObject, m_pDisturb->hHitAnim );
			g_pLTServer->SetModelLooping( m_hObject, LTFALSE );
			g_pLTServer->ResetModelAnimation(m_hObject);
		}

		// Register touch disturbance stimulus.

		if( (m_pDisturb->pPD->nHitAlarmLevel > 0) && (m_pDisturb->pPD->fStimRadius > 0.f) )
		{
			g_pAIStimulusMgr->RegisterStimulus( kStim_EnemyDisturbanceSound, m_pDisturb->pPD->nHitAlarmLevel, hCharacter, m_hObject, vPos, m_pDisturb->pPD->fStimRadius );
		}

		m_eState = kState_PropHit;
	}

	// Update while playing touch sound and/or animation.
	SetNextUpdate(UPDATE_NEXT_FRAME);
}	
Exemple #12
0
uint32 Prop::EngineMessageFn(uint32 messageID, void *pData, LTFLOAT fData)
{
	switch(messageID)
	{
		case MID_TOUCHNOTIFY:
		{
			HandleTouch((HOBJECT)pData);
		}
		break;

		case MID_UPDATE:
		{
			// Make sure object starts on floor...
			
			if (m_bFirstUpdate && m_bMoveToFloor)
			{
				m_bFirstUpdate = LTFALSE;
				MoveObjectToFloor(m_hObject);
			}
		}
		break;

		case MID_PRECREATE:
		{
			if (fData == PRECREATE_WORLDFILE || fData == PRECREATE_STRINGPROP)
			{
				ObjectCreateStruct* pStruct = (ObjectCreateStruct*)pData;
				ReadProp(pStruct);

				// If this prop is spawned, assume it should be visible (if they
				// specify Visible 0, our parent class will handle it ;)

				if (fData == PRECREATE_STRINGPROP)
				{
					m_dwFlags |= FLAG_VISIBLE;
				}
			}

            uint32 dwRet = GameBase::EngineMessageFn(messageID, pData, fData);

			PostPropRead((ObjectCreateStruct*)pData);

			CacheFiles();

			return dwRet;
		}
		break;

		case MID_INITIALUPDATE:
		{
			if (fData != INITIALUPDATE_SAVEGAME)
			{
				InitialUpdate();
			}
		}
		break;

		case MID_SAVEOBJECT:
		{
            Save((HMESSAGEWRITE)pData, (uint32)fData);
		}
		break;

		case MID_LOADOBJECT:
		{
            Load((HMESSAGEREAD)pData, (uint32)fData);
		}
		break;

		default : break;
	}


	return GameBase::EngineMessageFn(messageID, pData, fData);
}
Exemple #13
0
DDWORD CProjectile::EngineMessageFn(DDWORD messageID, void *pData, DFLOAT fData)
{
	switch(messageID)
	{
		case MID_UPDATE:
		{
			if (!Update((DVector *)pData))
			{
				CServerDE* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) return 0;

				pServerDE->RemoveObject(m_hObject);		
			}
			break;
		}

		case MID_PRECREATE:
		{
			ObjectCreateStruct *ocs = (ObjectCreateStruct*)pData;
			m_dwClientID = ocs->m_UserData;
			ocs = DNULL;

			DDWORD dwRet = BaseClass::EngineMessageFn(messageID, pData, fData);

			if (fData != PRECREATE_SAVEGAME)
				PostPropRead((ObjectCreateStruct*)pData);

			return dwRet;
		}

		case MID_INITIALUPDATE:
		{
			if (fData != INITIALUPDATE_SAVEGAME)
				InitialUpdate((DVector *)pData);
			break;
		}

		case MID_TOUCHNOTIFY:
		{
			HandleTouch((HOBJECT)pData);
			break;
		}

		case MID_LINKBROKEN:
		{
			HOBJECT hObj = (HOBJECT)pData;
			BreakLink(hObj);
			break;
		}

		case MID_SAVEOBJECT:
			Save((HMESSAGEWRITE)pData, (DDWORD)fData);
			break;

		case MID_LOADOBJECT:
			Load((HMESSAGEREAD)pData, (DDWORD)fData);
			break;

		default : break;
	}


	return BaseClass::EngineMessageFn(messageID, pData, fData);
}