/*virtual*/ void UIScreenEldMirror::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	STATIC_HASHED_STRING( SetHeadMesh );
	STATIC_HASHED_STRING( SetBodyMesh );

	const HashedString EventName = Event.GetEventName();

	if( EventName == sSetHeadMesh )
	{
		STATIC_HASHED_STRING( HeadMesh );
		const SimpleString HeadMesh = Event.GetString( sHeadMesh );

		STATIC_HASHED_STRING( HeadTexture );
		const SimpleString HeadTexture = Event.GetString( sHeadTexture );

		SetHeadMesh( HeadMesh, HeadTexture );
	}
	else if( EventName == sSetBodyMesh )
	{
		STATIC_HASHED_STRING( BodyMesh );
		const SimpleString BodyMesh = Event.GetString( sBodyMesh );

		STATIC_HASHED_STRING( BodyTexture );
		const SimpleString BodyTexture = Event.GetString( sBodyTexture );

		SetBodyMesh( BodyMesh, BodyTexture );
	}
}
void AnimEventEldExecuteAction::Call( Mesh* pMesh, Animation* pAnimation )
{
	Unused( pMesh );
	Unused( pAnimation );

	EldritchMesh* const	pEldritchMesh	= static_cast<EldritchMesh*>( pMesh );
	WBEntity* const		pEntity			= WBCompOwner::GetTopmostOwner( pEldritchMesh->GetEntity() );
	DEVASSERT( pEntity );

	WBEvent OnAnimEventEvent;
	STATIC_HASHED_STRING( OnAnimEvent );
	OnAnimEventEvent.SetEventName( sOnAnimEvent );
	pEntity->AddContextToEvent( OnAnimEventEvent );

	const uint NumActions = m_Actions.Size();
	for( uint ActionIndex = 0; ActionIndex < NumActions; ++ActionIndex )
	{
		WBAction* const pAction = m_Actions[ ActionIndex ];
		ASSERT( pAction );

		WBActionStack::Push( OnAnimEventEvent );
		pAction->Execute();
		WBActionStack::Pop();
	}
}
示例#3
0
/*virtual*/ void WBCompEldSleeper::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnDamaged);
  STATIC_HASHED_STRING(OnAINoise);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnDamaged) {
    Wake();
  } else if (EventName == sOnAINoise) {
    STATIC_HASHED_STRING(EventOwner);
    WBEntity* const pEventOwner = Event.GetEntity(sEventOwner);
    ASSERT(pEventOwner);

    if (pEventOwner == GetEntity()) {
      // Ignore AI noises from self (see SensorHearing for more details).
    } else {
      STATIC_HASHED_STRING(NoiseLocation);
      const Vector NoiseLocation = Event.GetVector(sNoiseLocation);

      STATIC_HASHED_STRING(NoiseRadius);
      const float NoiseRadius = Event.GetFloat(sNoiseRadius);

      HandleNoise(NoiseLocation, NoiseRadius);
    }
  }
}
示例#4
0
/*virtual*/ void WBCompEldWallet::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(AddMoney);
  STATIC_HASHED_STRING(RemoveMoney);
  STATIC_HASHED_STRING(OnInitialized);
  STATIC_HASHED_STRING(PushPersistence);
  STATIC_HASHED_STRING(PullPersistence);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnInitialized) {
    PublishToHUD();
  } else if (EventName == sAddMoney) {
    STATIC_HASHED_STRING(Money);
    const uint Money = Event.GetInt(sMoney);

    STATIC_HASHED_STRING(ShowPickupScreen);
    const bool ShowPickupScreen = Event.GetBool(sShowPickupScreen);

    AddMoney(Money, ShowPickupScreen);
  } else if (EventName == sRemoveMoney) {
    STATIC_HASHED_STRING(Money);
    const uint Money = Event.GetInt(sMoney);
    RemoveMoney(Money);
  } else if (EventName == sPushPersistence) {
    PushPersistence();
  } else if (EventName == sPullPersistence) {
    PullPersistence();
  }
}
示例#5
0
/*virtual*/ void WBCompOwner::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	// Bit of a hack; OnEquipped is sent from Eldritch code and this lives in Workbench.
	STATIC_HASHED_STRING( OnEquipped );
	STATIC_HASHED_STRING( SetOwner );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnEquipped )
	{
		STATIC_HASHED_STRING( Owner );
		WBEntity* const pOwner = Event.GetEntity( sOwner );
		SetOwner( pOwner );
	}
	else if( EventName == sSetOwner )
	{
		STATIC_HASHED_STRING( NewOwner );
		WBEntity* const pNewOwner = Event.GetEntity( sNewOwner );

		SetOwner( pNewOwner );
	}
}
示例#6
0
/*virtual*/ void EldritchFramework::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Framework3D::HandleEvent(Event);

  STATIC_HASHED_STRING(ToggleInvertY);
  STATIC_HASHED_STRING(ToggleFullscreen);
  STATIC_HASHED_STRING(OnSliderChanged);
  STATIC_HASHED_STRING(WritePrefsConfig);
  STATIC_HASHED_STRING(CheckForUpdates);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sToggleInvertY) {
    XTRACE_NAMED(ToggleInvertY);

    // TODO: Also invert controller? Or on a separate button?

    STATIC_HASHED_STRING(TurnY);
    const bool InvertY = !m_InputSystem->GetMouseInvert(sTurnY);
    m_InputSystem->SetMouseInvert(sTurnY, InvertY);
    m_InputSystem->SetControllerInvert(sTurnY, InvertY);

    // Publish config var so UI can reflect the change.
    // I could make input system publish config vars for each adjustment, but
    // that seems wasteful since most inputs currently have no adjustment.
    STATICHASH(InvertY);
    ConfigManager::SetBool(sInvertY, InvertY);
  } else if (EventName == sToggleFullscreen) {
    XTRACE_NAMED(ToggleFullscreen);
    ToggleFullscreen();
  } else if (EventName == sOnSliderChanged) {
    XTRACE_NAMED(OnSliderChanged);

    STATIC_HASHED_STRING(SliderName);
    const HashedString SliderName = Event.GetHash(sSliderName);

    STATIC_HASHED_STRING(SliderValue);
    const float SliderValue = Event.GetFloat(sSliderValue);

    HandleUISliderEvent(SliderName, SliderValue);
  } else if (EventName == sWritePrefsConfig) {
    XTRACE_NAMED(WritePrefsConfig);
    WritePrefsConfig();
  } else if (EventName == sCheckForUpdates) {
#if BUILD_WINDOWS && !BUILD_STEAM
    XTRACE_NAMED(CheckForUpdates);

    // So I can compile updating out of certain builds.
    STATICHASH(Framework);
    STATICHASH(CheckForUpdates);
    const bool CheckForUpdates =
        ConfigManager::GetBool(sCheckForUpdates, true, sFramework);
    if (CheckForUpdates) {
      m_CheckForUpdates->Check(false, true);
    }
#endif
  }
}
/*virtual*/ void WBCompEldPickup::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnFrobbed );
	STATIC_HASHED_STRING( OnPurchaseBuy );
	STATIC_HASHED_STRING( OnPurchaseSteal );
	STATIC_HASHED_STRING( OnShopkeeperDied );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnShopkeeperDied )
	{
		m_Price = 0;
	}
	else if( EventName == sOnFrobbed )
	{
		STATIC_HASHED_STRING( Frobber );
		WBEntity* const pFrobber = Event.GetEntity( sFrobber );
		ASSERT( pFrobber );

		if( m_Price > 0 )
		{
			SellItemTo( pFrobber );
		}
		else
		{
			GiveItemTo( pFrobber );
		}
	}
	else if( EventName == sOnPurchaseBuy )
	{
		if( this == sm_PurchasePickup )
		{
			ASSERT( sm_Purchaser );
			AcceptPaymentFrom( sm_Purchaser );
			NotifyPurchasedBy( sm_Purchaser );
			GiveItemTo( sm_Purchaser );
		}
	}
	else if( EventName == sOnPurchaseSteal )
	{
		if( this == sm_PurchasePickup )
		{
			ASSERT( sm_Purchaser );
			NotifyTheftBy( sm_Purchaser );
			GiveItemTo( sm_Purchaser );
		}
	}
}
/*virtual*/ void EldritchPersistence::HandleEvent( const WBEvent& Event )
{
	STATIC_HASHED_STRING( SetPersistentVar );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sSetPersistentVar )
	{
		STATIC_HASHED_STRING( Name );
		const HashedString Name = Event.GetHash( sName );

		STATIC_HASHED_STRING( Value );
		const WBEvent::SParameter* const pParameter = Event.GetParameter( sValue );
		m_VariableMap.Set( Name, pParameter );
	}
}
示例#9
0
/*virtual*/ void WBCompState::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(SetState);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sSetState) {
    STATIC_HASHED_STRING(NewState);
    const HashedString State = Event.GetHash(sNewState);

    SetState(State);
  }
}
示例#10
0
/*virtual*/ void WBCompEldHard::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( SetHard );
	STATIC_HASHED_STRING( PushPersistence );
	STATIC_HASHED_STRING( PullPersistence );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sSetHard )
	{
		m_Hard = true;

		// Broadcast event to everything with an EldHardListener component.
		WB_MAKE_EVENT( NotifyHardModeSet, NULL );
		WB_DISPATCH_EVENT( GetEventManager(), NotifyHardModeSet, NULL );
	}
	else if( EventName == sPushPersistence )
	{
		PushPersistence();
	}
	else if( EventName == sPullPersistence )
	{
		PullPersistence();
	}
}
/*virtual*/ void WBCompEldEndgameCounter::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnInitialized);
  STATIC_HASHED_STRING(IncrementEndgameCount);
  STATIC_HASHED_STRING(PushPersistence);
  STATIC_HASHED_STRING(PullPersistence);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnInitialized) {
    if (m_Count > 0) {
      PublishToHUD();
    } else {
      SetHUDHidden(true);
    }
  } else if (EventName == sIncrementEndgameCount) {
    ++m_Count;

    PublishToHUD();
  } else if (EventName == sPushPersistence) {
    PushPersistence();
  } else if (EventName == sPullPersistence) {
    PullPersistence();
  }
}
示例#12
0
/*virtual*/ void WBCompEldRope::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnWorldChanged);
  STATIC_HASHED_STRING(OnStaticCollisionChanged);
  STATIC_HASHED_STRING(OnInitialOrientationSet);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnWorldChanged || EventName == sOnStaticCollisionChanged) {
    if (m_Dropped) {
      // If anchor is removed, destroy the rope (and drop anyone climbing on
      // it!)

      CollisionInfo Info;
      Info.m_CollideWorld = true;
      Info.m_CollideEntities = true;
      Info.m_CollidingEntity = GetEntity();
      Info.m_UserFlags = EECF_CollideAsEntity | EECF_CollideStaticEntities;

      EldritchWorld* const pWorld = GetWorld();
      if (!pWorld->PointCheck(m_Anchor, Info)) {
        GetEntity()->Destroy();
      }
    }
  } else if (EventName == sOnInitialOrientationSet) {
    DropRope();
  }
}
/*virtual*/ void WBCompEldAnchor::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnSpawnedQueued );
	STATIC_HASHED_STRING( OnWorldChanged );
	STATIC_HASHED_STRING( OnStaticCollisionChanged );
	STATIC_HASHED_STRING( Unanchor );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnSpawnedQueued )
	{
		SetAnchor();
	}
	else if( EventName == sOnWorldChanged || EventName == sOnStaticCollisionChanged )
	{
		if( m_IsAnchored )
		{
			CheckAnchor();
		}
	}
	else if( EventName == sUnanchor )
	{
		if( m_IsAnchored )
		{
			// Forcibly unanchor the entity
			Unanchor();
		}
	}
}
示例#14
0
/*virtual*/ void Framework3D::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  STATIC_HASHED_STRING(QuitGame);
  STATIC_HASHED_STRING(ResetRenderer);
  STATIC_HASHED_STRING(ConditionalRefreshDisplay);
  STATIC_HASHED_STRING(RefreshDisplay);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sQuitGame) {
#if BUILD_WINDOWS_NO_SDL
    XTRACE_NAMED(PostQuitMessage);
    PostQuitMessage(0);
#endif
#if BUILD_SDL
    SDL_Event QuitEvent;
    QuitEvent.type = SDL_QUIT;
    const int Success = SDL_PushEvent(&QuitEvent);
    ASSERT(Success);
    Unused(Success);
#endif
  } else if (EventName == sResetRenderer) {
    ResetRenderer();
  } else if (EventName == sConditionalRefreshDisplay) {
    ConditionalRefreshDisplay();
  } else if (EventName == sRefreshDisplay) {
    RefreshDisplay(m_Display->m_Fullscreen, m_Display->m_Width,
                   m_Display->m_Height);
  }
}
示例#15
0
/*virtual*/ void WBCompEldLock::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnSpawned );
	STATIC_HASHED_STRING( Unlock );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnSpawned )
	{
		EldritchPersistence* const pPersistence = GetGame()->GetPersistence();
		ASSERT( pPersistence );

		if( pPersistence->IsOpenLock( m_Key ) )
		{
			Unlock();
		}
	}
	else if( EventName == sUnlock )
	{
		Unlock();
	}
}
示例#16
0
/*virtual*/ void WBCompEldLight::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnMoved );
	STATIC_HASHED_STRING( OnDestroyed );
	STATIC_HASHED_STRING( AddLight );
	STATIC_HASHED_STRING( RemoveLight );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnMoved )
	{
		if( m_DeferAddLight )
		{
			// Do nothing
		}
		else
		{
			AddLight();
		}
	}
	else if( EventName == sAddLight )
	{
		AddLight();
	}
	else if( EventName == sOnDestroyed || EventName == sRemoveLight )
	{
		RemoveLight();
	}
}
示例#17
0
/*virtual*/ void WBCompEldFaction::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(SetFaction);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sSetFaction) {
    if (m_Immutable) {
      // Faction can't be changed, do nothing
    } else {
      STATIC_HASHED_STRING(Faction);
      m_Faction = Event.GetHash(sFaction);
    }
  }
}
示例#18
0
/*virtual*/ void WBCompEldThinker::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  WBEldritchComponent::HandleEvent(Event);

  STATIC_HASHED_STRING(TickThinkers);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sTickThinkers) {
    Tick(0.0f);
  }
}
示例#19
0
/*virtual*/ void WBCompEldFrobber::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnFrob);
  STATIC_HASHED_STRING(EnableFrob);
  STATIC_HASHED_STRING(DisableFrob);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnFrob) {
    STATIC_HASHED_STRING(InputEdge);
    const int InputEdge = Event.GetInt(sInputEdge);

    TryFrob(InputEdge);
  } else if (EventName == sEnableFrob) {
    m_FrobDisabled = false;
  } else if (EventName == sDisableFrob) {
    m_FrobDisabled = true;
  }
}
/*virtual*/ void WBCompEldIcicles::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnTouched );

	const HashedString EventName = Event.GetEventName();
	// TODO
	Unused( EventName );
}
RodinBTNode::ETickStatus RodinBTNodeSendEvent::Tick( float DeltaTime )
{
	Unused( DeltaTime );

	WBEntity* const pEntity = GetEntity();

	WBEvent Event;

	Event.SetEventName( m_EventName );

	if( pEntity )
	{
		pEntity->AddContextToEvent( Event );
	}

	WBParamEvaluator::SPEContext PEContext;
	PEContext.m_Entity = pEntity;

	const uint NumParameters = m_Parameters.Size();
	for( uint ParameterIndex = 0; ParameterIndex < NumParameters; ++ParameterIndex )
	{
		SNamedParameter& Parameter = m_Parameters[ ParameterIndex ];
		Parameter.m_ValuePE.Evaluate( PEContext );
		Event.Set( Parameter.m_Name, Parameter.m_ValuePE );
	}

	m_RecipientPE.Evaluate( PEContext );

	if( m_QueueEvent )
	{
		WBWorld::GetInstance()->GetEventManager()->QueueEvent( Event, m_RecipientPE.GetEntity(), m_DispatchDelay );
	}
	else
	{
		WBWorld::GetInstance()->GetEventManager()->DispatchEvent( Event, m_RecipientPE.GetEntity() );
	}

	return ETS_Success;
}
示例#22
0
/*virtual*/ void WBCompEldSensorTheft::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnTheft);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnTheft) {
    STATIC_HASHED_STRING(Thief);
    WBEntity* const pThief = Event.GetEntity(sThief);

    HandleTheft(pThief);

    // Also, forward event to this entity for scripting to handle.
    {
      WB_MAKE_EVENT(OnTheftSensed, GetEntity());
      WB_SET_AUTO(OnTheftSensed, Entity, Thief, pThief);
      WB_DISPATCH_EVENT(GetEventManager(), OnTheftSensed, GetEntity());
    }
  }
}
示例#23
0
RodinBTNode::ETickStatus RodinBTNodePlayActions::Tick(float DeltaTime) {
  Unused(DeltaTime);

  WBEntity* const pEntity = GetEntity();

  WBEvent BTNodePlayActionsEvent;
  STATIC_HASHED_STRING(BTNodePlayActionsEvent);
  BTNodePlayActionsEvent.SetEventName(sBTNodePlayActionsEvent);
  pEntity->AddContextToEvent(BTNodePlayActionsEvent);

  const uint NumActions = m_Actions.Size();
  for (uint ActionIndex = 0; ActionIndex < NumActions; ++ActionIndex) {
    WBAction* const pAction = m_Actions[ActionIndex];
    ASSERT(pAction);

    WBActionStack::Push(BTNodePlayActionsEvent);
    pAction->Execute();
    WBActionStack::Pop();
  }

  return ETS_Success;
}
/*virtual*/ void WBCompEldHUDMarker::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnCameraTicked );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnCameraTicked )
	{
		UpdateMarkerPosition();
	}
}
void AnimEventEldSendEvent::Call( Mesh* pMesh, Animation* pAnimation )
{
	Unused( pAnimation );

	EldritchMesh* const pEldritchMesh = static_cast<EldritchMesh*>( pMesh );
	WBEntity* const pEntity = pEldritchMesh->GetEntity();

	WBEvent Event;

	Event.SetEventName( m_EventName );

	if( pEntity )
	{
		pEntity->AddContextToEvent( Event );
	}

	WBParamEvaluator::SPEContext PEContext;
	PEContext.m_Entity = pEntity;

	const uint NumParameters = m_Parameters.Size();
	for( uint ParameterIndex = 0; ParameterIndex < NumParameters; ++ParameterIndex )
	{
		SNamedParameter& Parameter = m_Parameters[ ParameterIndex ];
		Parameter.m_ValuePE.Evaluate( PEContext );
		Event.Set( Parameter.m_Name, Parameter.m_ValuePE );
	}

	if( m_QueueEvent )
	{
		WBWorld::GetInstance()->GetEventManager()->QueueEvent( Event, pEntity, m_DispatchDelay );
	}
	else
	{
		WBWorld::GetInstance()->GetEventManager()->DispatchEvent( Event, pEntity );
	}
}
示例#26
0
/*virtual*/ void WBCompEldVisible::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(SetVisible);
  STATIC_HASHED_STRING(SetInvisible);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sSetVisible) {
    m_Visible = true;
  } else if (EventName == sSetInvisible) {
    m_Visible = false;
  }
}
/*virtual*/ void WBCompRodinBehaviorTree::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(PauseBT);
  STATIC_HASHED_STRING(UnpauseBT);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sPauseBT) {
    m_Paused = true;

    // Also flush the scheduler so that running actions clean up.
    Flush();
  } else if (EventName == sUnpauseBT) {
    m_Paused = false;
  }
}
/*virtual*/ void WBCompEldSensor::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	WBEldritchComponent::HandleEvent( Event );

	STATIC_HASHED_STRING( TickSensors );
	STATIC_HASHED_STRING( PauseSensors );
	STATIC_HASHED_STRING( UnpauseSensors );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sTickSensors )
	{
		Tick( 0.0f );
	}
	else if( EventName == sPauseSensors )
	{
		m_Paused = true;
	}
	else if( EventName == sUnpauseSensors )
	{
		m_Paused = false;
	}
}
/*virtual*/ void WBCompEldMapMarker::HandleEvent( const WBEvent& Event )
{
	Super::HandleEvent( Event );

	STATIC_HASHED_STRING( OnMoved );
	STATIC_HASHED_STRING( OnTurned );
	STATIC_HASHED_STRING( OnInitializedQueued );
	STATIC_HASHED_STRING( OnDestroyed );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sOnInitializedQueued )
	{
		AddMarker();
		UpdateMarker();
	}
	else if( EventName == sOnMoved || sOnTurned )
	{
		UpdateMarker();
	}
	else if( EventName == sOnDestroyed )
	{
		RemoveMarker();
	}
}
示例#30
0
/*virtual*/ void WBCompEldMesh::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(OnInitialized);
  STATIC_HASHED_STRING(OnSpawnedQueued);
  STATIC_HASHED_STRING(OnLoaded);
  STATIC_HASHED_STRING(OnBecameFrobTarget);
  STATIC_HASHED_STRING(Hide);
  STATIC_HASHED_STRING(Show);
  STATIC_HASHED_STRING(HideMesh);
  STATIC_HASHED_STRING(ShowMesh);
  STATIC_HASHED_STRING(PlayAnim);
  STATIC_HASHED_STRING(SetAnim);
  STATIC_HASHED_STRING(CopyAnimations);
  STATIC_HASHED_STRING(SetMesh);
  STATIC_HASHED_STRING(SetTexture);

  const HashedString EventName = Event.GetEventName();
  if (EventName == sOnInitialized) {
    SetSendUpdatedEvent();
  } else if (EventName == sOnSpawnedQueued ||
             EventName == sOnLoaded)  // Need to have a valid transform
  {
    ImmediateUpdateBlendedIrradiance();
  } else if (EventName == sOnBecameFrobTarget) {
    STATIC_HASHED_STRING(IsFrobTarget);
    const bool IsFrobTarget = Event.GetBool(sIsFrobTarget);

    if (IsFrobTarget) {
      STATIC_HASHED_STRING(Highlight);
      m_CurrentHighlight = Event.GetVector(sHighlight);
    } else {
      m_CurrentHighlight.Zero();
    }
  } else if (EventName == sHide || EventName == sHideMesh) {
    m_Hidden = true;
  } else if (EventName == sShow || EventName == sShowMesh) {
    m_Hidden = false;
  } else if (EventName == sPlayAnim) {
    STATIC_HASHED_STRING(AnimationName);
    const HashedString AnimationName = Event.GetHash(sAnimationName);

    STATIC_HASHED_STRING(Loop);
    const bool Loop = Event.GetBool(sLoop);

    STATIC_HASHED_STRING(IgnoreIfAlreadyPlaying);
    const bool IgnoreIfAlreadyPlaying = Event.GetBool(sIgnoreIfAlreadyPlaying);

    STATIC_HASHED_STRING(PlayRate);
    const float PlayRate = Event.GetFloat(sPlayRate);

    PlayAnimation(AnimationName, Loop, IgnoreIfAlreadyPlaying, PlayRate);
  } else if (EventName == sSetAnim) {
    STATIC_HASHED_STRING(AnimationIndex);
    const int AnimationIndex = Event.GetInt(sAnimationIndex);

    STATIC_HASHED_STRING(AnimationTime);
    const float AnimationTime = Event.GetFloat(sAnimationTime);

    STATIC_HASHED_STRING(AnimationEndBehavior);
    const int AnimationEndBehavior = Event.GetInt(sAnimationEndBehavior);

    STATIC_HASHED_STRING(AnimationPlayRate);
    const float AnimationPlayRate = Event.GetFloat(sAnimationPlayRate);

    AnimationState::SPlayAnimationParams PlayParams;
    PlayParams.m_EndBehavior =
        static_cast<AnimationState::EAnimationEndBehavior>(
            AnimationEndBehavior);

    m_Mesh->SetAnimation(AnimationIndex, PlayParams);
    m_Mesh->SetAnimationTime(AnimationTime);
    m_Mesh->SetAnimationPlayRate(AnimationPlayRate > 0.0f ? AnimationPlayRate
                                                          : 1.0f);
  } else if (EventName == sCopyAnimations) {
    STATIC_HASHED_STRING(SourceEntity);
    WBEntity* const pSourceEntity = Event.GetEntity(sSourceEntity);

    STATIC_HASHED_STRING(SuppressAnimEvents);
    const bool SuppressAnimEvents = Event.GetBool(sSuppressAnimEvents);

    CopyAnimationsFrom(pSourceEntity, SuppressAnimEvents);
  } else if (EventName == sSetMesh) {
    STATIC_HASHED_STRING(Mesh);
    const SimpleString Mesh = Event.GetString(sMesh);

    STATIC_HASHED_STRING(Texture);
    const SimpleString Texture = Event.GetString(sTexture);

    SetMesh(Mesh);
    SetTexture(Texture);
    UpdateMesh(0.0f);
  } else if (EventName == sSetTexture) {
    STATIC_HASHED_STRING(Texture);
    const SimpleString Texture = Event.GetString(sTexture);

    SetTexture(Texture);
  }
}