BVB Source Codes

CRYENGINE Show AnimatedCharacterEventProxies.cpp Source code

Return Download CRYENGINE: download AnimatedCharacterEventProxies.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "AnimatedCharacterEventProxies.h"
  5. #include "AnimatedCharacter.h"
  6.  
  7. #include "CryActionCVars.h"
  8.  
  9. #include <CryEntitySystem/IEntityComponent.h>
  10.  
  11. #include <CryExtension/ClassWeaver.h>
  12. #include <CryExtension/CryCreateClassInstance.h>
  13.  
  14. //////////////////////////////////////////////////////////////////////////
  15.  
  16. CAnimatedCharacterComponent_Base::CAnimatedCharacterComponent_Base()
  17.         : m_pAnimCharacter(nullptr)
  18. {
  19. }
  20.  
  21. void CAnimatedCharacterComponent_Base::ProcessEvent(SEntityEvent& event)
  22. {
  23.         switch (event.event)
  24.         {
  25.         case ENTITY_EVENT_PREPHYSICSUPDATE:
  26.                 OnPrePhysicsUpdate(event.fParam[0]);
  27.                 break;
  28.         }
  29. }
  30.  
  31. uint64 CAnimatedCharacterComponent_Base::GetEventMask() const
  32. {
  33.         return BIT64(ENTITY_EVENT_PREPHYSICSUPDATE);
  34. }
  35.  
  36. //////////////////////////////////////////////////////////////////////////
  37.  
  38. CAnimatedCharacterComponent_PrepareAnimatedCharacterForUpdate::CAnimatedCharacterComponent_PrepareAnimatedCharacterForUpdate()
  39.         : m_queuedRotation(IDENTITY)
  40.         , m_hasQueuedRotation(false)
  41. {
  42. }
  43.  
  44. void CAnimatedCharacterComponent_PrepareAnimatedCharacterForUpdate::OnPrePhysicsUpdate(float)
  45. {
  46.         CRY_ASSERT(m_pAnimCharacter);
  47.  
  48.         if (CAnimationGraphCVars::Get().m_useQueuedRotation && m_hasQueuedRotation)
  49.         {
  50.                 m_pEntity->SetRotation(m_queuedRotation, ENTITY_XFORM_USER | ENTITY_XFORM_NOT_REREGISTER);
  51.                 ClearQueuedRotation();
  52.         }
  53.  
  54.         m_pAnimCharacter->PrepareAnimatedCharacterForUpdate();
  55. }
  56.  
  57. IEntityComponent::ComponentEventPriority CAnimatedCharacterComponent_PrepareAnimatedCharacterForUpdate::GetEventPriority(const int eventID) const
  58. {
  59.         CRY_ASSERT(m_pAnimCharacter);
  60.  
  61.         switch (eventID)
  62.         {
  63.         case ENTITY_EVENT_PREPHYSICSUPDATE:
  64.                 {
  65.                         int priority = ENTITY_PROXY_LAST - ENTITY_PROXY_USER + EEntityEventPriority_PrepareAnimatedCharacterForUpdate;
  66.  
  67.                         if (m_pAnimCharacter->GetEntityId() == CCryAction::GetCryAction()->GetClientActorId())
  68.                         {
  69.                                 // we want the client StartAnimProc to happen after both CActor and GenMoveRequest.
  70.                                 priority += EEntityEventPriority_Client;
  71.                         }
  72.  
  73.                         return priority;
  74.                 }
  75.         }
  76.         return(ENTITY_PROXY_LAST - ENTITY_PROXY_USER);
  77. }
  78.  
  79. //////////////////////////////////////////////////////////////////////////
  80.  
  81. void CAnimatedCharacterComponent_StartAnimProc::OnPrePhysicsUpdate(float elapsedTime)
  82. {
  83.         CRY_ASSERT(m_pAnimCharacter);
  84.  
  85.         m_pAnimCharacter->PrepareAndStartAnimProc();
  86. }
  87.  
  88. IEntityComponent::ComponentEventPriority CAnimatedCharacterComponent_StartAnimProc::GetEventPriority(const int eventID) const
  89. {
  90.         CRY_ASSERT(m_pAnimCharacter);
  91.  
  92.         switch (eventID)
  93.         {
  94.         case ENTITY_EVENT_PREPHYSICSUPDATE:
  95.                 {
  96.                         int priority = ENTITY_PROXY_LAST - ENTITY_PROXY_USER + EEntityEventPriority_StartAnimProc;
  97.  
  98.                         if (m_pAnimCharacter->GetEntityId() == CCryAction::GetCryAction()->GetClientActorId())
  99.                         {
  100.                                 // we want the client StartAnimProc to happen after both CActor and GenMoveRequest.
  101.                                 priority += EEntityEventPriority_Client;
  102.                         }
  103.                         return priority;
  104.                 }
  105.         }
  106.  
  107.         return(ENTITY_PROXY_LAST - ENTITY_PROXY_USER);
  108. }
  109.  
  110. //////////////////////////////////////////////////////////////////////////
  111.  
  112. void CAnimatedCharacterComponent_GenerateMoveRequest::OnPrePhysicsUpdate(float elapsedTime)
  113. {
  114.         CRY_ASSERT(m_pAnimCharacter);
  115.  
  116.         m_pAnimCharacter->GenerateMovementRequest();
  117. }
  118.  
  119. IEntityComponent::ComponentEventPriority CAnimatedCharacterComponent_GenerateMoveRequest::GetEventPriority(const int eventID) const
  120. {
  121.         CRY_ASSERT(m_pAnimCharacter);
  122.  
  123.         switch (eventID)
  124.         {
  125.         case ENTITY_EVENT_PREPHYSICSUPDATE:
  126.                 {
  127.                         int priority = ENTITY_PROXY_LAST - ENTITY_PROXY_USER + EEntityEventPriority_AnimatedCharacter;
  128.  
  129.                         if (m_pAnimCharacter->GetEntityId() == CCryAction::GetCryAction()->GetClientActorId())
  130.                         {
  131.                                 priority += EEntityEventPriority_Client;
  132.                         }
  133.                         return priority;
  134.                 }
  135.         }
  136.  
  137.         return(ENTITY_PROXY_LAST - ENTITY_PROXY_USER);
  138. }
  139.  
downloadAnimatedCharacterEventProxies.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top