Exemplo n.º 1
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();
  }
}
Exemplo n.º 2
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);
  }
}
Exemplo n.º 3
0
/*virtual*/ void EldritchGame::HandleEvent( const WBEvent& Event )
{
    XTRACE_FUNCTION;

    STATIC_HASHED_STRING( ReturnToHub );
    STATIC_HASHED_STRING( GoToNextLevel );
    STATIC_HASHED_STRING( GoToPrevLevel );
    STATIC_HASHED_STRING( GoToLevel );
    STATIC_HASHED_STRING( Checkpoint );
    STATIC_HASHED_STRING( TweetRIP );
    STATIC_HASHED_STRING( PlayMusic );
    STATIC_HASHED_STRING( StopMusic );
    STATIC_HASHED_STRING( LaunchWebSite );
    STATIC_HASHED_STRING( GoToLevelImmediate );

    const HashedString EventName = Event.GetEventName();
    if( EventName == sReturnToHub )
    {
        STATIC_HASHED_STRING( Restart );
        const bool Restart = Event.GetBool( sRestart );

        STATIC_HASHED_STRING( FlushHub );
        const bool FlushHub = Event.GetBool( sFlushHub );

        RequestReturnToHub( Restart, FlushHub );
    }
    else if( EventName == sGoToNextLevel )
    {
        RequestGoToNextLevel();
    }
    else if( EventName == sGoToPrevLevel )
    {
        RequestGoToPrevLevel();
    }
    else if( EventName == sGoToLevel )
    {
        STATIC_HASHED_STRING( Level );
        const SimpleString Level = Event.GetString( sLevel );

        STATIC_HASHED_STRING( WorldDef );
        const HashedString WorldDef = Event.GetHash( sWorldDef );

        RequestGoToLevel( Level, WorldDef, true );
    }
    else if( EventName == sCheckpoint )
    {
        Checkpoint();
    }
    else if( EventName == sTweetRIP )
    {
        LaunchRIPTweet();
    }
    else if( EventName == sLaunchWebSite )
    {
        LaunchWebSite();
    }
    else if( EventName == sPlayMusic )
    {
        STATIC_HASHED_STRING( Music );
        const SimpleString Music = Event.GetString( sMusic );

        m_Music->PlayMusic( ( Music == "" ) ? m_CurrentMusic : Music );
    }
    else if( EventName == sStopMusic )
    {
        m_Music->StopMusic();
    }
    else if( EventName == sGoToLevelImmediate )
    {
        // This should only be called after we've queued a go-to.
        ASSERT( m_GoToLevelOnNextTick );
        if( m_GoToLevelOnNextTick )
        {
            GoToLevel();
        }

        // HACK: Tick world once to pump the event queue. Fixes title screen bugs. (Hack because this assumes we only ever use this when returning to title screen.)
        EldritchFramework* const pFramework = EldritchFramework::GetInstance();
        EldritchWorld* const pWorld = pFramework->GetWorld();
        pWorld->Tick( 0.0f );
    }
}
Exemplo n.º 4
0
/*virtual*/ void WBCompEldFrobbable::HandleEvent(const WBEvent& Event) {
  XTRACE_FUNCTION;

  Super::HandleEvent(Event);

  STATIC_HASHED_STRING(MarshalFrob);
  STATIC_HASHED_STRING(OnInitialized);
  STATIC_HASHED_STRING(OnDestroyed);
  STATIC_HASHED_STRING(OnMeshUpdated);
  STATIC_HASHED_STRING(SetIsFrobbable);
  STATIC_HASHED_STRING(BecomeFrobbable);
  STATIC_HASHED_STRING(BecomeNonFrobbable);
  STATIC_HASHED_STRING(SetHoldReleaseMode);
  STATIC_HASHED_STRING(SetFriendlyName);
  STATIC_HASHED_STRING(SetFrobVerb);
  STATIC_HASHED_STRING(SetBoundExtents);
  STATIC_HASHED_STRING(SetBoundOffsetZ);

  const HashedString EventName = Event.GetEventName();

  if (EventName == sMarshalFrob) {
    STATIC_HASHED_STRING(Frobber);
    WBEntity* const pFrobber = Event.GetEntity(sFrobber);

    STATIC_HASHED_STRING(InputEdge);
    const int InputEdge = Event.GetInt(sInputEdge);

    MarshalFrob(pFrobber, InputEdge);
  } else if (EventName == sOnInitialized) {
    if (m_UseCollisionExtents) {
      WBCompEldCollision* const pCollision =
          GET_WBCOMP(GetEntity(), EldCollision);
      if (pCollision) {
        m_BoundExtents =
            pCollision->GetExtents() +
            Vector(m_ExtentsFatten, m_ExtentsFatten, m_ExtentsFatten);
      }
    }
  } else if (EventName == sOnDestroyed) {
    if (m_IsProbableFrobbable) {
      SetHUDHidden(true);
    }
  } else if (EventName == sOnMeshUpdated) {
    ASSERT(m_UseMeshExtents);

    WBCompEldTransform* const pTransform =
        GetEntity()->GetTransformComponent<WBCompEldTransform>();
    DEVASSERT(pTransform);

    WBCompEldMesh* const pMeshComponent = GET_WBCOMP(GetEntity(), EldMesh);
    ASSERT(pMeshComponent);

    EldritchMesh* const pMesh = pMeshComponent->GetMesh();
    ASSERT(pMesh);

    m_BoundExtents = pMesh->m_AABB.GetExtents() +
                     Vector(m_ExtentsFatten, m_ExtentsFatten, m_ExtentsFatten);
    m_BoundOffset = pMesh->m_AABB.GetCenter() - pTransform->GetLocation();
  } else if (EventName == sSetIsFrobbable) {
    STATIC_HASHED_STRING(IsFrobbable);
    m_IsFrobbable = Event.GetBool(sIsFrobbable);
  } else if (EventName == sBecomeFrobbable) {
    m_IsFrobbable = true;
  } else if (EventName == sBecomeNonFrobbable) {
    m_IsFrobbable = false;
  } else if (EventName == sSetHoldReleaseMode) {
    const bool WasHoldReleaseMode = m_HoldReleaseMode;

    STATIC_HASHED_STRING(HoldReleaseMode);
    m_HoldReleaseMode = Event.GetBool(sHoldReleaseMode);

    if (m_HoldReleaseMode && !WasHoldReleaseMode) {
      m_HandleHoldRelease = false;
    }

    if (GetIsFrobTarget()) {
      PublishToHUD();
    }
  } else if (EventName == sSetFriendlyName) {
    STATIC_HASHED_STRING(FriendlyName);
    m_FriendlyName = Event.GetString(sFriendlyName);

    if (GetIsFrobTarget()) {
      PublishToHUD();
    }
  } else if (EventName == sSetFrobVerb) {
    STATIC_HASHED_STRING(FrobVerb);
    m_FrobVerb = Event.GetString(sFrobVerb);

    if (GetIsFrobTarget()) {
      PublishToHUD();
    }
  } else if (EventName == sSetBoundExtents) {
    STATIC_HASHED_STRING(BoundExtents);
    m_BoundExtents = Event.GetVector(sBoundExtents);
  } else if (EventName == sSetBoundOffsetZ) {
    STATIC_HASHED_STRING(BoundOffsetZ);
    m_BoundOffset.z = Event.GetFloat(sBoundOffsetZ);
  }
}