BVB Source Codes

CRYENGINE Show EffectSystem.cpp Source code

Return Download CRYENGINE: download EffectSystem.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    History:
  6.    - 17:01:2006:                Created by Marco Koegler
  7.  
  8. *************************************************************************/
  9. #include <StdAfx.h>
  10. #include "EffectSystem.h"
  11. #include "BloodSplats.h"
  12. #include "GroundEffect.h"
  13.  
  14. CEffectSystem::CEffectSystem()
  15. {
  16. }
  17.  
  18. CEffectSystem::~CEffectSystem()
  19. {
  20. }
  21.  
  22. bool CEffectSystem::Init()
  23. {
  24.         CBloodSplats* pBloodSplats = new CBloodSplats;
  25.         pBloodSplats->Init(0, 2.5f);
  26.         BindEffect("BloodSplats_Human", pBloodSplats);
  27.  
  28.         pBloodSplats = new CBloodSplats;
  29.         pBloodSplats->Init(1, 2.5f);
  30.         BindEffect("BloodSplats_Alien", pBloodSplats);
  31.  
  32.         return true;
  33. }
  34.  
  35. void CEffectSystem::Update(float delta)
  36. {
  37.         for (TEffectVec::iterator i = m_effects.begin(); i != m_effects.end(); )
  38.         {
  39.                 if ((*i)->GetState() == eES_Activating && (*i)->Activating(delta))
  40.                 {
  41.                         (*i)->SetState(eES_Updating);
  42.                 }
  43.                 if ((*i)->GetState() == eES_Updating && (*i)->Update(delta))
  44.                 {
  45.                         (*i)->SetState(eES_Deactivating);
  46.                 }
  47.                 if ((*i)->GetState() == eES_Deactivating && (*i)->Deactivating(delta))
  48.                 {
  49.                         (*i)->OnDeactivate();
  50.                         (*i)->SetState(eES_Deactivated);
  51.                 }
  52.  
  53.                 ++i;
  54.         }
  55. }
  56.  
  57. void CEffectSystem::Shutdown()
  58. {
  59. }
  60.  
  61. EffectId CEffectSystem::GetEffectId(const char* name)
  62. {
  63.         TNameToId::iterator i = m_nameToId.find(CONST_TEMP_STRING(name));
  64.  
  65.         if (i == m_nameToId.end())
  66.                 return -1;
  67.  
  68.         return (*i).second;
  69. }
  70.  
  71. void CEffectSystem::Activate(const EffectId& eid)
  72. {
  73.         if (eid < 0 || eid >= m_effects.size())
  74.                 return;
  75.  
  76.         if (m_effects[eid]->OnActivate())
  77.         {
  78.                 m_effects[eid]->SetState(eES_Activating);
  79.         }
  80. }
  81.  
  82. bool CEffectSystem::BindEffect(const char* name, IEffect* pEffect)
  83. {
  84.         if (GetEffectId(name) != -1)
  85.                 return false;
  86.  
  87.         m_nameToId[name] = m_effects.size();
  88.         m_effects.push_back(pEffect);
  89.         pEffect->SetState(eES_Deactivated);
  90.  
  91.         return true;
  92. }
  93.  
  94. IGroundEffect* CEffectSystem::CreateGroundEffect(IEntity* pEntity)
  95. {
  96.         return new CGroundEffect(pEntity);
  97. }
  98.  
  99. void CEffectSystem::RegisterFactory(const char* name, IEffect*(*func)(), bool isAI)
  100. {
  101.         m_effectClasses[name] = func;
  102. }
  103.  
  104. void CEffectSystem::GetMemoryStatistics(ICrySizer* s)
  105. {
  106.         SIZER_SUBCOMPONENT_NAME(s, "EffectSystem");
  107.         s->AddObject(this, sizeof(*this));
  108.         s->AddObject(m_nameToId);
  109.         s->AddObject(m_effects);
  110.  
  111.         for (TEffectClassMap::iterator iter = m_effectClasses.begin(); iter != m_effectClasses.end(); ++iter)
  112.                 s->AddObject(iter->first);
  113. }
  114.  
downloadEffectSystem.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