PageRenderTime 51ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/Code/GameSDK/GameDll/Effects/GameEffectsSystem.cpp

https://gitlab.com/blackbird91/CS188_AI_Game
C++ | 1200 lines | 859 code | 128 blank | 213 comment | 126 complexity | 5d6e68fb897b3095301f9ef7703525fe MD5 | raw file
  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. // Original file Copyright Crytek GMBH or its affiliates, used under license.
  13. // Description : System to handle game effects, render nodes and render elements
  14. #include "StdAfx.h"
  15. #include "GameEffectsSystem.h"
  16. #include "Effects/GameEffects/GameEffect.h"
  17. #include "GameCVars.h"
  18. #include "ItemSystem.h"
  19. #include "BitFiddling.h"
  20. #include "Effects/RenderNodes/IGameRenderNode.h"
  21. #include "Effects/RenderElements/GameRenderElement.h"
  22. #include "GameRules.h"
  23. //--------------------------------------------------------------------------------------------------
  24. // Desc: Defines
  25. //--------------------------------------------------------------------------------------------------
  26. #define GAME_FX_DATA_FILE "scripts/effects/gameeffects.xml"
  27. //--------------------------------------------------------------------------------------------------
  28. //--------------------------------------------------------------------------------------------------
  29. // Desc: Debug data
  30. //--------------------------------------------------------------------------------------------------
  31. #if DEBUG_GAME_FX_SYSTEM
  32. int GameSDKCGameEffectsSystem::s_currentDebugEffectId = 0;
  33. const char* GAME_FX_DEBUG_VIEW_NAMES[eMAX_GAME_FX_DEBUG_VIEWS] = { "None",
  34. "Profiling",
  35. "Effect List",
  36. "Bounding Box",
  37. "Bounding Sphere",
  38. "Particles" };
  39. #endif
  40. //--------------------------------------------------------------------------------------------------
  41. //--------------------------------------------------------------------------------------------------
  42. // Desc: Static data
  43. //--------------------------------------------------------------------------------------------------
  44. GameSDKCGameEffectsSystem* GameSDKCGameEffectsSystem::s_singletonInstance = NULL;
  45. bool GameSDKCGameEffectsSystem::s_hasLoadedData = false;
  46. int GameSDKCGameEffectsSystem::s_postEffectCVarNameOffset = 0;
  47. //--------------------------------------------------------------------------------------------------
  48. //--------------------------------------------------------------------------------------------------
  49. // Desc: Game Effect System Static data - contains access to any data where static initialisation
  50. // order is critical, this will enforce initialisation on first use
  51. //--------------------------------------------------------------------------------------------------
  52. struct SGameEffectSystemStaticData
  53. {
  54. static PodArray<DataLoadCallback>& GetDataLoadCallbackList()
  55. {
  56. static PodArray<DataLoadCallback> dataLoadCallbackList;
  57. return dataLoadCallbackList;
  58. }
  59. static PodArray<DataReleaseCallback>& GetDataReleaseCallbackList()
  60. {
  61. static PodArray<DataReleaseCallback> dataReleaseCallbackList;
  62. return dataReleaseCallbackList;
  63. }
  64. static PodArray<DataReloadCallback>& GetDataReloadCallbackList()
  65. {
  66. static PodArray<DataReloadCallback> dataReloadCallbackList;
  67. return dataReloadCallbackList;
  68. }
  69. static PodArray<EnteredGameCallback>& GetEnteredGameCallbackList()
  70. {
  71. static PodArray<EnteredGameCallback> enteredGameCallbackList;
  72. return enteredGameCallbackList;
  73. }
  74. #if DEBUG_GAME_FX_SYSTEM
  75. static PodArray<GameSDKCGameEffectsSystem::SEffectDebugData>& GetEffectDebugList()
  76. {
  77. static PodArray<GameSDKCGameEffectsSystem::SEffectDebugData> effectDebugList;
  78. return effectDebugList;
  79. }
  80. #endif
  81. };
  82. // Easy access macros
  83. #define s_dataLoadCallbackList SGameEffectSystemStaticData::GetDataLoadCallbackList()
  84. #define s_dataReleaseCallbackList SGameEffectSystemStaticData::GetDataReleaseCallbackList()
  85. #define s_dataReloadCallbackList SGameEffectSystemStaticData::GetDataReloadCallbackList()
  86. #define s_enteredGameCallbackList SGameEffectSystemStaticData::GetEnteredGameCallbackList()
  87. #if DEBUG_GAME_FX_SYSTEM
  88. #define s_effectDebugList SGameEffectSystemStaticData::GetEffectDebugList()
  89. #endif
  90. //--------------------------------------------------------------------------------------------------
  91. //==================================================================================================
  92. // Name: CGameRenderNodeSoftCodeListener
  93. // Desc: Game Render Node Soft Code Listener
  94. // Author: James Chilvers
  95. //==================================================================================================
  96. class CGameRenderNodeSoftCodeListener : public ISoftCodeListener
  97. {
  98. public:
  99. CGameRenderNodeSoftCodeListener()
  100. {
  101. if(gEnv->pSoftCodeMgr)
  102. {
  103. gEnv->pSoftCodeMgr->AddListener(GAME_RENDER_NODE_LIBRARY_NAME,this,GAME_RENDER_NODE_LISTENER_NAME);
  104. }
  105. }
  106. virtual ~CGameRenderNodeSoftCodeListener()
  107. {
  108. if(gEnv->pSoftCodeMgr)
  109. {
  110. gEnv->pSoftCodeMgr->RemoveListener(GAME_RENDER_NODE_LIBRARY_NAME,this);
  111. }
  112. }
  113. virtual void InstanceReplaced(void* pOldInstance, void* pNewInstance)
  114. {
  115. GAME_FX_SYSTEM.GameRenderNodeInstanceReplaced(pOldInstance,pNewInstance);
  116. }
  117. };//------------------------------------------------------------------------------------------------
  118. //==================================================================================================
  119. // Name: CGameRenderElementSoftCodeListener
  120. // Desc: Game Render Element Soft Code Listener
  121. // Author: James Chilvers
  122. //==================================================================================================
  123. class CGameRenderElementSoftCodeListener : public ISoftCodeListener
  124. {
  125. public:
  126. CGameRenderElementSoftCodeListener()
  127. {
  128. if(gEnv->pSoftCodeMgr)
  129. {
  130. gEnv->pSoftCodeMgr->AddListener(GAME_RENDER_ELEMENT_LIBRARY_NAME,this,GAME_RENDER_ELEMENT_LISTENER_NAME);
  131. }
  132. }
  133. virtual ~CGameRenderElementSoftCodeListener()
  134. {
  135. if(gEnv->pSoftCodeMgr)
  136. {
  137. gEnv->pSoftCodeMgr->RemoveListener(GAME_RENDER_ELEMENT_LIBRARY_NAME,this);
  138. }
  139. }
  140. virtual void InstanceReplaced(void* pOldInstance, void* pNewInstance)
  141. {
  142. GAME_FX_SYSTEM.GameRenderElementInstanceReplaced(pOldInstance,pNewInstance);
  143. }
  144. };//------------------------------------------------------------------------------------------------
  145. //--------------------------------------------------------------------------------------------------
  146. // Name: CGameEffectsSystem
  147. // Desc: Constructor
  148. //--------------------------------------------------------------------------------------------------
  149. GameSDKCGameEffectsSystem::GameSDKCGameEffectsSystem()
  150. {
  151. #if DEBUG_GAME_FX_SYSTEM
  152. if(gEnv->pInput)
  153. {
  154. gEnv->pInput->AddEventListener(this);
  155. }
  156. #endif
  157. #ifdef SOFTCODE_ENABLED
  158. if(gEnv->pSoftCodeMgr)
  159. {
  160. gEnv->pSoftCodeMgr->AddListener(GAME_FX_LIBRARY_NAME,this,GAME_FX_LISTENER_NAME);
  161. }
  162. m_gameRenderNodes.clear();
  163. m_gameRenderNodeSoftCodeListener = new CGameRenderNodeSoftCodeListener;
  164. m_gameRenderElements.clear();
  165. m_gameRenderElementSoftCodeListener = new CGameRenderElementSoftCodeListener;
  166. RegisterSoftCodeLib(GameSDKIGameEffect::TLibrary::Instance());
  167. RegisterSoftCodeLib(IGameRenderNode::TLibrary::Instance());
  168. RegisterSoftCodeLib(GameSDKIGameRenderElement::TLibrary::Instance());
  169. #endif
  170. Reset();
  171. }//-------------------------------------------------------------------------------------------------
  172. //--------------------------------------------------------------------------------------------------
  173. // Name: ~CGameEffectsSystem
  174. // Desc: Destructor
  175. //--------------------------------------------------------------------------------------------------
  176. GameSDKCGameEffectsSystem::~GameSDKCGameEffectsSystem()
  177. {
  178. #if DEBUG_GAME_FX_SYSTEM
  179. if(gEnv->pInput)
  180. {
  181. gEnv->pInput->RemoveEventListener(this);
  182. }
  183. #endif
  184. #ifdef SOFTCODE_ENABLED
  185. if(gEnv->pSoftCodeMgr)
  186. {
  187. gEnv->pSoftCodeMgr->RemoveListener(GAME_FX_LIBRARY_NAME,this);
  188. }
  189. SAFE_DELETE(m_gameRenderNodeSoftCodeListener);
  190. SAFE_DELETE(m_gameRenderElementSoftCodeListener);
  191. m_softCodeTypeLibs.clear();
  192. m_gameRenderNodes.clear();
  193. m_gameRenderElements.clear();
  194. #endif
  195. // Remove as game rules listener
  196. if(g_pGame)
  197. {
  198. CGameRules* pGameRules = g_pGame->GetGameRules();
  199. if(pGameRules)
  200. {
  201. pGameRules->RemoveGameRulesListener(this);
  202. }
  203. }
  204. }//-------------------------------------------------------------------------------------------------
  205. //--------------------------------------------------------------------------------------------------
  206. // Name: Destroy
  207. // Desc: Destroys effects system
  208. //--------------------------------------------------------------------------------------------------
  209. void GameSDKCGameEffectsSystem::Destroy()
  210. {
  211. if(s_singletonInstance)
  212. {
  213. s_singletonInstance->AutoReleaseAndDeleteFlaggedEffects(s_singletonInstance->m_effectsToUpdate);
  214. s_singletonInstance->AutoReleaseAndDeleteFlaggedEffects(s_singletonInstance->m_effectsNotToUpdate);
  215. FX_ASSERT_MESSAGE( (s_singletonInstance->m_effectsToUpdate==NULL) &&
  216. (s_singletonInstance->m_effectsNotToUpdate==NULL),
  217. "Game Effects System being destroyed even though game effects still exist!");
  218. }
  219. SAFE_DELETE(s_singletonInstance);
  220. }//-------------------------------------------------------------------------------------------------
  221. //--------------------------------------------------------------------------------------------------
  222. // Name: Reset
  223. // Desc: Resets effects systems data
  224. //--------------------------------------------------------------------------------------------------
  225. void GameSDKCGameEffectsSystem::Reset()
  226. {
  227. m_isInitialised = false;
  228. m_effectsToUpdate = NULL;
  229. m_effectsNotToUpdate = NULL;
  230. m_nextEffectToUpdate = NULL;
  231. s_postEffectCVarNameOffset = 0;
  232. #if DEBUG_GAME_FX_SYSTEM
  233. m_debugView = eGAME_FX_DEBUG_VIEW_None;
  234. #endif
  235. }//-------------------------------------------------------------------------------------------------
  236. //--------------------------------------------------------------------------------------------------
  237. // Name: Initialise
  238. // Desc: Initialises effects system
  239. //--------------------------------------------------------------------------------------------------
  240. void GameSDKCGameEffectsSystem::Initialise()
  241. {
  242. if(m_isInitialised == false)
  243. {
  244. Reset();
  245. SetPostEffectCVarCallbacks();
  246. m_isInitialised = true;
  247. }
  248. }//-------------------------------------------------------------------------------------------------
  249. //--------------------------------------------------------------------------------------------------
  250. // Name: GameRulesInitialise
  251. // Desc: Game Rules initialise
  252. //--------------------------------------------------------------------------------------------------
  253. void GameSDKCGameEffectsSystem::GameRulesInitialise()
  254. {
  255. // Add as game rules listener
  256. if(g_pGame)
  257. {
  258. CGameRules* pGameRules = g_pGame->GetGameRules();
  259. if(pGameRules)
  260. {
  261. pGameRules->AddGameRulesListener(this);
  262. }
  263. }
  264. }//-------------------------------------------------------------------------------------------------
  265. //--------------------------------------------------------------------------------------------------
  266. // Name: LoadData
  267. // Desc: Loads data for game effects system and effects
  268. //--------------------------------------------------------------------------------------------------
  269. void GameSDKCGameEffectsSystem::LoadData()
  270. {
  271. if(s_hasLoadedData == false)
  272. {
  273. XmlNodeRef rootNode = gEnv->pSystem->LoadXmlFromFile(GAME_FX_DATA_FILE);
  274. if(!rootNode)
  275. {
  276. GameWarning("Could not load game effects data. Invalid XML file '%s'! ", GAME_FX_DATA_FILE);
  277. return;
  278. }
  279. IItemParamsNode* paramNode = g_pGame->GetIGameFramework()->GetIItemSystem()->CreateParams();
  280. if(paramNode)
  281. {
  282. paramNode->ConvertFromXML(rootNode);
  283. // Pass data to any callback functions registered
  284. int callbackCount = s_dataLoadCallbackList.size();
  285. DataLoadCallback dataLoadCallbackFunc = NULL;
  286. for(int i=0; i<callbackCount; i++)
  287. {
  288. dataLoadCallbackFunc = s_dataLoadCallbackList[i];
  289. if(dataLoadCallbackFunc)
  290. {
  291. dataLoadCallbackFunc(paramNode);
  292. }
  293. }
  294. paramNode->Release();
  295. s_hasLoadedData = true;
  296. }
  297. }
  298. }//-------------------------------------------------------------------------------------------------
  299. //--------------------------------------------------------------------------------------------------
  300. // Name: ReleaseData
  301. // Desc: Releases any loaded data for game effects system and any effects with registered callbacks
  302. //--------------------------------------------------------------------------------------------------
  303. void GameSDKCGameEffectsSystem::ReleaseData()
  304. {
  305. if(s_hasLoadedData)
  306. {
  307. #if DEBUG_GAME_FX_SYSTEM
  308. // Unload all debug effects which rely on effect data
  309. for(size_t i=0; i<s_effectDebugList.Size(); i++)
  310. {
  311. if(s_effectDebugList[i].inputCallback)
  312. {
  313. s_effectDebugList[i].inputCallback(GAME_FX_INPUT_ReleaseDebugEffect);
  314. }
  315. }
  316. #endif
  317. // Pass data to any callback functions registered
  318. int callbackCount = s_dataReleaseCallbackList.size();
  319. DataReleaseCallback dataReleaseCallbackFunc = NULL;
  320. for(int i=0; i<callbackCount; i++)
  321. {
  322. dataReleaseCallbackFunc = s_dataReleaseCallbackList[i];
  323. if(dataReleaseCallbackFunc)
  324. {
  325. dataReleaseCallbackFunc();
  326. }
  327. }
  328. s_hasLoadedData = false;
  329. }
  330. }//-------------------------------------------------------------------------------------------------
  331. //--------------------------------------------------------------------------------------------------
  332. // Name: ReloadData
  333. // Desc: Reloads any loaded data for game effects registered callbacks
  334. //--------------------------------------------------------------------------------------------------
  335. void GameSDKCGameEffectsSystem::ReloadData()
  336. {
  337. XmlNodeRef rootNode = gEnv->pSystem->LoadXmlFromFile(GAME_FX_DATA_FILE);
  338. if(!rootNode)
  339. {
  340. GameWarning("Could not load game effects data. Invalid XML file '%s'! ", GAME_FX_DATA_FILE);
  341. return;
  342. }
  343. IItemParamsNode* paramNode = g_pGame->GetIGameFramework()->GetIItemSystem()->CreateParams();
  344. if(paramNode)
  345. {
  346. paramNode->ConvertFromXML(rootNode);
  347. // Pass data to any callback functions registered
  348. int callbackCount = s_dataReloadCallbackList.size();
  349. DataReloadCallback dataReloadCallbackFunc = NULL;
  350. for(int i=0; i<callbackCount; i++)
  351. {
  352. dataReloadCallbackFunc = s_dataReloadCallbackList[i];
  353. if(dataReloadCallbackFunc)
  354. {
  355. dataReloadCallbackFunc(paramNode);
  356. }
  357. }
  358. paramNode->Release();
  359. }
  360. }//-------------------------------------------------------------------------------------------------
  361. //--------------------------------------------------------------------------------------------------
  362. // Name: EnteredGame
  363. // Desc: Called when entering a game
  364. //--------------------------------------------------------------------------------------------------
  365. void GameSDKCGameEffectsSystem::EnteredGame()
  366. {
  367. const int callbackCount = s_enteredGameCallbackList.size();
  368. EnteredGameCallback enteredGameCallbackFunc = NULL;
  369. for(int i=0; i<callbackCount; i++)
  370. {
  371. enteredGameCallbackFunc = s_enteredGameCallbackList[i];
  372. if(enteredGameCallbackFunc)
  373. {
  374. enteredGameCallbackFunc();
  375. }
  376. }
  377. }//-------------------------------------------------------------------------------------------------
  378. //--------------------------------------------------------------------------------------------------
  379. // Name: RegisterDataLoadCallback
  380. // Desc: Registers data load callback
  381. //--------------------------------------------------------------------------------------------------
  382. void GameSDKCGameEffectsSystem::RegisterDataLoadCallback(DataLoadCallback dataLoadCallback)
  383. {
  384. if(dataLoadCallback)
  385. {
  386. s_dataLoadCallbackList.push_back(dataLoadCallback);
  387. }
  388. }//-------------------------------------------------------------------------------------------------
  389. //--------------------------------------------------------------------------------------------------
  390. // Name: RegisterDataReleaseCallback
  391. // Desc: Registers data release callback
  392. //--------------------------------------------------------------------------------------------------
  393. void GameSDKCGameEffectsSystem::RegisterDataReleaseCallback(DataReleaseCallback dataReleaseCallback)
  394. {
  395. if(dataReleaseCallback)
  396. {
  397. s_dataReleaseCallbackList.push_back(dataReleaseCallback);
  398. }
  399. }//-------------------------------------------------------------------------------------------------
  400. //--------------------------------------------------------------------------------------------------
  401. // Name: RegisterDataReloadCallback
  402. // Desc: Registers data reload callback
  403. //--------------------------------------------------------------------------------------------------
  404. void GameSDKCGameEffectsSystem::RegisterDataReloadCallback(DataReloadCallback dataReloadCallback)
  405. {
  406. if(dataReloadCallback)
  407. {
  408. s_dataReloadCallbackList.push_back(dataReloadCallback);
  409. }
  410. }//-------------------------------------------------------------------------------------------------
  411. //--------------------------------------------------------------------------------------------------
  412. // Name: RegisterEnteredGameCallback
  413. // Desc: Registers entered game callback
  414. //--------------------------------------------------------------------------------------------------
  415. void GameSDKCGameEffectsSystem::RegisterEnteredGameCallback(EnteredGameCallback enteredGameCallback)
  416. {
  417. if(enteredGameCallback)
  418. {
  419. s_enteredGameCallbackList.push_back(enteredGameCallback);
  420. }
  421. }//-------------------------------------------------------------------------------------------------
  422. //--------------------------------------------------------------------------------------------------
  423. // Name: AutoReleaseAndDeleteFlaggedEffects
  424. // Desc: Calls release and delete on any effects with the these flags set
  425. //--------------------------------------------------------------------------------------------------
  426. void GameSDKCGameEffectsSystem::AutoReleaseAndDeleteFlaggedEffects(GameSDKIGameEffect* effectList)
  427. {
  428. if(effectList)
  429. {
  430. GameSDKIGameEffect* effect = effectList;
  431. while(effect)
  432. {
  433. m_nextEffectToUpdate = effect->Next();
  434. bool autoRelease = effect->IsFlagSet(GAME_EFFECT_AUTO_RELEASE);
  435. bool autoDelete = effect->IsFlagSet(GAME_EFFECT_AUTO_DELETE);
  436. if(autoRelease || autoDelete)
  437. {
  438. SOFTCODE_RETRY(effect,effect->Release());
  439. if(autoDelete)
  440. {
  441. SAFE_DELETE(effect);
  442. }
  443. }
  444. effect = m_nextEffectToUpdate;
  445. }
  446. m_nextEffectToUpdate = NULL;
  447. }
  448. }//-------------------------------------------------------------------------------------------------
  449. //--------------------------------------------------------------------------------------------------
  450. // Name: InstanceReplaced
  451. // Desc: Replaces instance for soft coding
  452. //--------------------------------------------------------------------------------------------------
  453. void GameSDKCGameEffectsSystem::InstanceReplaced(void* pOldInstance, void* pNewInstance)
  454. {
  455. #ifdef SOFTCODE_ENABLED
  456. if(pNewInstance && pOldInstance)
  457. {
  458. GameSDKIGameEffect* pNewGameEffectInstance = static_cast<GameSDKIGameEffect*>(pNewInstance);
  459. GameSDKIGameEffect* pOldGameEffectInstance = static_cast<GameSDKIGameEffect*>(pOldInstance);
  460. // Copy over flags and remove registered flag so new effect instance can be registered
  461. // We haven't used the SOFT macro on the m_flags member because the oldInstance's flags
  462. // would then be Nulled out, and they are needed for the effect to be deregistered
  463. uint32 oldGameEffectFlags = pOldGameEffectInstance->GetFlags();
  464. SET_FLAG(oldGameEffectFlags,GAME_EFFECT_REGISTERED,false);
  465. pNewGameEffectInstance->SetFlags(oldGameEffectFlags);
  466. // Register new effect instance, old instance will get unregistered by destructor
  467. GAME_FX_SYSTEM.RegisterEffect(pNewGameEffectInstance);
  468. // Reload all data used by effects, then data can be added/removed for soft coding
  469. ReloadData();
  470. // Data used by effect will be copied to new effect, so mustn't release it but
  471. // must set flag so destructor doesn't assert
  472. pOldGameEffectInstance->SetFlag(GAME_EFFECT_RELEASED,true);
  473. }
  474. #endif
  475. }//-------------------------------------------------------------------------------------------------
  476. //--------------------------------------------------------------------------------------------------
  477. // Name: GameRenderNodeInstanceReplaced
  478. // Desc: Replaces Game Render Node instance for soft coding
  479. //--------------------------------------------------------------------------------------------------
  480. void GameSDKCGameEffectsSystem::GameRenderNodeInstanceReplaced(void* pOldInstance, void* pNewInstance)
  481. {
  482. #ifdef SOFTCODE_ENABLED
  483. if(pOldInstance && pNewInstance)
  484. {
  485. IGameRenderNode* pOldGameRenderNodeInstance = (IGameRenderNode*)pOldInstance;
  486. IGameRenderNode* pNewGameRenderNodeInstance = (IGameRenderNode*)pNewInstance;
  487. // Unregister old node from engine
  488. gEnv->p3DEngine->FreeRenderNodeState(pOldGameRenderNodeInstance);
  489. // Register new node with engine
  490. gEnv->p3DEngine->RegisterEntity(pNewGameRenderNodeInstance);
  491. for(TGameRenderNodeVec::iterator iter(m_gameRenderNodes.begin()); iter != m_gameRenderNodes.end(); ++iter)
  492. {
  493. IGameRenderNodePtr* ppRenderNode = *iter;
  494. if(ppRenderNode)
  495. {
  496. IGameRenderNodePtr& pRenderNode = *ppRenderNode;
  497. if(pRenderNode == pOldGameRenderNodeInstance)
  498. {
  499. pRenderNode = pNewGameRenderNodeInstance;
  500. }
  501. }
  502. }
  503. }
  504. #endif
  505. }//-------------------------------------------------------------------------------------------------
  506. //--------------------------------------------------------------------------------------------------
  507. // Name: GameRenderElementInstanceReplaced
  508. // Desc: Replaces Game Render Element instance for soft coding
  509. //--------------------------------------------------------------------------------------------------
  510. void GameSDKCGameEffectsSystem::GameRenderElementInstanceReplaced(void* pOldInstance, void* pNewInstance)
  511. {
  512. #ifdef SOFTCODE_ENABLED
  513. if(pOldInstance && pNewInstance)
  514. {
  515. GameSDKIGameRenderElement* pOldGameRenderElementInstance = (GameSDKIGameRenderElement*)pOldInstance;
  516. GameSDKIGameRenderElement* pNewGameRenderElementInstance = (GameSDKIGameRenderElement*)pNewInstance;
  517. pNewGameRenderElementInstance->UpdatePrivateImplementation();
  518. for(TGameRenderElementVec::iterator iter(m_gameRenderElements.begin()); iter != m_gameRenderElements.end(); ++iter)
  519. {
  520. GameSDKIGameRenderElementPtr* ppRenderElement = *iter;
  521. if(ppRenderElement)
  522. {
  523. GameSDKIGameRenderElementPtr& pRenderElement = *ppRenderElement;
  524. if(pRenderElement == pOldGameRenderElementInstance)
  525. {
  526. pRenderElement = pNewGameRenderElementInstance;
  527. }
  528. }
  529. }
  530. }
  531. #endif
  532. }//-------------------------------------------------------------------------------------------------
  533. //--------------------------------------------------------------------------------------------------
  534. // Name: SetPostEffectCVarCallbacks
  535. // Desc: Sets Post effect CVar callbacks for testing and tweaking post effect values
  536. //--------------------------------------------------------------------------------------------------
  537. void GameSDKCGameEffectsSystem::SetPostEffectCVarCallbacks()
  538. {
  539. #if DEBUG_GAME_FX_SYSTEM
  540. ICVar* postEffectCvar = NULL;
  541. const char postEffectNames[][64] = { "g_postEffect.FilterGrain_Amount",
  542. "g_postEffect.FilterRadialBlurring_Amount",
  543. "g_postEffect.FilterRadialBlurring_ScreenPosX",
  544. "g_postEffect.FilterRadialBlurring_ScreenPosY",
  545. "g_postEffect.FilterRadialBlurring_Radius",
  546. "g_postEffect.Global_User_ColorC",
  547. "g_postEffect.Global_User_ColorM",
  548. "g_postEffect.Global_User_ColorY",
  549. "g_postEffect.Global_User_ColorK",
  550. "g_postEffect.Global_User_Brightness",
  551. "g_postEffect.Global_User_Contrast",
  552. "g_postEffect.Global_User_Saturation",
  553. "g_postEffect.Global_User_ColorHue",
  554. "g_postEffect.HUD3D_Interference",
  555. "g_postEffect.HUD3D_FOV"};
  556. int postEffectNameCount = sizeof(postEffectNames)/sizeof(*postEffectNames);
  557. if(postEffectNameCount > 0)
  558. {
  559. // Calc name offset
  560. const char* postEffectName = postEffectNames[0];
  561. s_postEffectCVarNameOffset = 0;
  562. while((*postEffectName) != 0)
  563. {
  564. s_postEffectCVarNameOffset++;
  565. if((*postEffectName) == '.')
  566. {
  567. break;
  568. }
  569. postEffectName++;
  570. }
  571. // Set callback functions
  572. for(int i=0; i<postEffectNameCount; i++)
  573. {
  574. postEffectCvar = gEnv->pConsole->GetCVar(postEffectNames[i]);
  575. if(postEffectCvar)
  576. {
  577. postEffectCvar->SetOnChangeCallback(PostEffectCVarCallback);
  578. }
  579. }
  580. }
  581. #endif
  582. }//-------------------------------------------------------------------------------------------------
  583. //--------------------------------------------------------------------------------------------------
  584. // Name: PostEffectCVarCallback
  585. // Desc: Callback function of post effect cvars to set their values
  586. //--------------------------------------------------------------------------------------------------
  587. void GameSDKCGameEffectsSystem::PostEffectCVarCallback(ICVar* cvar)
  588. {
  589. const char* effectName = cvar->GetName() + s_postEffectCVarNameOffset;
  590. gEnv->p3DEngine->SetPostEffectParam(effectName,cvar->GetFVal());
  591. }//-------------------------------------------------------------------------------------------------
  592. //--------------------------------------------------------------------------------------------------
  593. // Name: RegisterEffect
  594. // Desc: Registers effect with effect system
  595. //--------------------------------------------------------------------------------------------------
  596. void GameSDKCGameEffectsSystem::RegisterEffect(GameSDKIGameEffect* effect)
  597. {
  598. FX_ASSERT_MESSAGE(m_isInitialised,"Game Effects System trying to register an effect without being initialised");
  599. FX_ASSERT_MESSAGE(effect,"Trying to Register a NULL effect");
  600. if(effect)
  601. {
  602. // If effect is registered, then unregister first
  603. if(effect->IsFlagSet(GAME_EFFECT_REGISTERED))
  604. {
  605. UnRegisterEffect(effect);
  606. }
  607. // Add effect to effect list
  608. GameSDKIGameEffect** effectList = NULL;
  609. bool isActive = effect->IsFlagSet(GAME_EFFECT_ACTIVE);
  610. bool autoUpdatesWhenActive = effect->IsFlagSet(GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE);
  611. bool autoUpdatesWhenNotActive = effect->IsFlagSet(GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE);
  612. if((isActive && autoUpdatesWhenActive) ||
  613. ((!isActive) && autoUpdatesWhenNotActive))
  614. {
  615. effectList = &m_effectsToUpdate;
  616. }
  617. else
  618. {
  619. effectList = &m_effectsNotToUpdate;
  620. }
  621. if(*effectList)
  622. {
  623. (*effectList)->SetPrev(effect);
  624. effect->SetNext(*effectList);
  625. }
  626. (*effectList) = effect;
  627. effect->SetFlag(GAME_EFFECT_REGISTERED,true);
  628. }
  629. }//-------------------------------------------------------------------------------------------------
  630. //--------------------------------------------------------------------------------------------------
  631. // Name: UnRegisterEffect
  632. // Desc: UnRegisters effect from effect system
  633. //--------------------------------------------------------------------------------------------------
  634. void GameSDKCGameEffectsSystem::UnRegisterEffect(GameSDKIGameEffect* effect)
  635. {
  636. FX_ASSERT_MESSAGE(m_isInitialised,"Game Effects System trying to unregister an effect without being initialised");
  637. FX_ASSERT_MESSAGE(effect,"Trying to UnRegister a NULL effect");
  638. if(effect && effect->IsFlagSet(GAME_EFFECT_REGISTERED))
  639. {
  640. // If the effect is the next one to be updated, then point m_nextEffectToUpdate to the next effect after it
  641. if(effect == m_nextEffectToUpdate)
  642. {
  643. m_nextEffectToUpdate = m_nextEffectToUpdate->Next();
  644. }
  645. if(effect->Prev())
  646. {
  647. effect->Prev()->SetNext(effect->Next());
  648. }
  649. else
  650. {
  651. if(m_effectsToUpdate == effect)
  652. {
  653. m_effectsToUpdate = effect->Next();
  654. }
  655. else
  656. {
  657. FX_ASSERT_MESSAGE((m_effectsNotToUpdate == effect),"Effect isn't either updating list");
  658. m_effectsNotToUpdate = effect->Next();
  659. }
  660. }
  661. if(effect->Next())
  662. {
  663. effect->Next()->SetPrev(effect->Prev());
  664. }
  665. effect->SetNext(NULL);
  666. effect->SetPrev(NULL);
  667. effect->SetFlag(GAME_EFFECT_REGISTERED,false);
  668. }
  669. }//-------------------------------------------------------------------------------------------------
  670. //--------------------------------------------------------------------------------------------------
  671. // Name: Update
  672. // Desc: Updates effects system and any effects registered in it's update list
  673. //--------------------------------------------------------------------------------------------------
  674. void GameSDKCGameEffectsSystem::Update(float frameTime)
  675. {
  676. FX_ASSERT_MESSAGE(m_isInitialised,"Game Effects System trying to update without being initialised");
  677. // Get pause state
  678. bool isPaused = false;
  679. IGame* pGame = gEnv->pGame;
  680. if(pGame)
  681. {
  682. IGameFramework* pGameFramework = pGame->GetIGameFramework();
  683. if(pGameFramework)
  684. {
  685. isPaused = pGameFramework->IsGamePaused();
  686. }
  687. }
  688. // Update effects
  689. if(m_effectsToUpdate)
  690. {
  691. GameSDKIGameEffect* effect = m_effectsToUpdate;
  692. while(effect)
  693. {
  694. m_nextEffectToUpdate = effect->Next();
  695. if((!isPaused) || (effect->IsFlagSet(GAME_EFFECT_UPDATE_WHEN_PAUSED)))
  696. {
  697. SOFTCODE_RETRY(effect,effect->Update(frameTime));
  698. }
  699. effect = m_nextEffectToUpdate;
  700. }
  701. }
  702. m_nextEffectToUpdate = NULL;
  703. #if DEBUG_GAME_FX_SYSTEM
  704. DrawDebugDisplay();
  705. #endif
  706. }//-------------------------------------------------------------------------------------------------
  707. //--------------------------------------------------------------------------------------------------
  708. // Name: CreateSoftCodeInstance
  709. // Desc: Creates soft code instance
  710. //--------------------------------------------------------------------------------------------------
  711. #ifdef SOFTCODE_ENABLED
  712. void* GameSDKCGameEffectsSystem::CreateSoftCodeInstance(const char* pTypeName)
  713. {
  714. void* pNewInstance = NULL;
  715. if(pTypeName)
  716. {
  717. for(std::vector<ITypeLibrary*>::iterator iter(m_softCodeTypeLibs.begin()); iter != m_softCodeTypeLibs.end(); ++iter)
  718. {
  719. ITypeLibrary* pLib = *iter;
  720. if(pLib)
  721. {
  722. if(pNewInstance = pLib->CreateInstanceVoid(pTypeName))
  723. {
  724. break;
  725. }
  726. }
  727. }
  728. }
  729. return pNewInstance;
  730. }
  731. #endif
  732. //--------------------------------------------------------------------------------------------------
  733. //--------------------------------------------------------------------------------------------------
  734. // Name: RegisterSoftCodeLib
  735. // Desc: Register soft code lib for creation of instances
  736. //--------------------------------------------------------------------------------------------------
  737. #ifdef SOFTCODE_ENABLED
  738. void GameSDKCGameEffectsSystem::RegisterSoftCodeLib(ITypeLibrary* pLib)
  739. {
  740. m_softCodeTypeLibs.push_back(pLib);
  741. };
  742. #endif
  743. //--------------------------------------------------------------------------------------------------
  744. //--------------------------------------------------------------------------------------------------
  745. // Name: RegisterGameRenderNode
  746. // Desc: Registers game render node
  747. //--------------------------------------------------------------------------------------------------
  748. void GameSDKCGameEffectsSystem::RegisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode)
  749. {
  750. #ifdef SOFTCODE_ENABLED
  751. for(TGameRenderNodeVec::iterator iter(m_gameRenderNodes.begin()); iter != m_gameRenderNodes.end(); ++iter)
  752. {
  753. IGameRenderNodePtr* ppIterRenderNode = *iter;
  754. if(ppIterRenderNode == NULL)
  755. {
  756. *iter = &pGameRenderNode;
  757. return;
  758. }
  759. }
  760. m_gameRenderNodes.push_back(&pGameRenderNode);
  761. #endif
  762. }//-------------------------------------------------------------------------------------------------
  763. //--------------------------------------------------------------------------------------------------
  764. // Name: UnregisterGameRenderNode
  765. // Desc: Unregisters game render node
  766. //--------------------------------------------------------------------------------------------------
  767. void GameSDKCGameEffectsSystem::UnregisterGameRenderNode(IGameRenderNodePtr& pGameRenderNode)
  768. {
  769. #ifdef SOFTCODE_ENABLED
  770. TGameRenderNodeVec::iterator iter(std::find(m_gameRenderNodes.begin(), m_gameRenderNodes.end(), &pGameRenderNode));
  771. if(iter != m_gameRenderNodes.end())
  772. {
  773. *iter = NULL;
  774. }
  775. #endif
  776. }//-------------------------------------------------------------------------------------------------
  777. //--------------------------------------------------------------------------------------------------
  778. // Name: RegisterGameRenderElement
  779. // Desc: Registers game render element
  780. //--------------------------------------------------------------------------------------------------
  781. void GameSDKCGameEffectsSystem::RegisterGameRenderElement(GameSDKIGameRenderElementPtr& pGameRenderElement)
  782. {
  783. #ifdef SOFTCODE_ENABLED
  784. for(TGameRenderElementVec::iterator iter(m_gameRenderElements.begin()); iter != m_gameRenderElements.end(); ++iter)
  785. {
  786. GameSDKIGameRenderElementPtr* ppIterRenderElement = *iter;
  787. if(ppIterRenderElement == NULL)
  788. {
  789. *iter = &pGameRenderElement;
  790. return;
  791. }
  792. }
  793. m_gameRenderElements.push_back(&pGameRenderElement);
  794. #endif
  795. }//-------------------------------------------------------------------------------------------------
  796. //--------------------------------------------------------------------------------------------------
  797. // Name: UnregisterGameRenderElement
  798. // Desc: Unregisters game render element
  799. //--------------------------------------------------------------------------------------------------
  800. void GameSDKCGameEffectsSystem::UnregisterGameRenderElement(GameSDKIGameRenderElementPtr& pGameRenderElement)
  801. {
  802. #ifdef SOFTCODE_ENABLED
  803. TGameRenderElementVec::iterator iter(std::find(m_gameRenderElements.begin(), m_gameRenderElements.end(), &pGameRenderElement));
  804. if(iter != m_gameRenderElements.end())
  805. {
  806. *iter = NULL;
  807. }
  808. #endif
  809. }//-------------------------------------------------------------------------------------------------
  810. //--------------------------------------------------------------------------------------------------
  811. // Name: DrawDebugDisplay
  812. // Desc: Draws debug display
  813. //--------------------------------------------------------------------------------------------------
  814. #if DEBUG_GAME_FX_SYSTEM
  815. void GameSDKCGameEffectsSystem::DrawDebugDisplay()
  816. {
  817. static ColorF textCol(1.0f,1.0f,1.0f,1.0f);
  818. static ColorF controlCol(0.6f,0.6f,0.6f,1.0f);
  819. static Vec2 textPos(10.0f,10.0f);
  820. static float textSize = 1.4f;
  821. static float textYSpacing = 18.0f;
  822. static float effectNameXOffset = 100.0f;
  823. static ColorF effectNameCol(0.0f,1.0f,0.0f,1.0f);
  824. Vec2 currentTextPos = textPos;
  825. int debugEffectCount = s_effectDebugList.Size();
  826. if((g_pGameCVars->g_gameFXSystemDebug) && (debugEffectCount > 0))
  827. {
  828. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&textCol.r,false,"Debug view:");
  829. gEnv->pRenderer->Draw2dLabel(currentTextPos.x+effectNameXOffset,currentTextPos.y,textSize,&effectNameCol.r,false,GAME_FX_DEBUG_VIEW_NAMES[m_debugView]);
  830. currentTextPos.y += textYSpacing;
  831. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&controlCol.r,false,"(Change debug view: Left/Right arrows)");
  832. currentTextPos.y += textYSpacing;
  833. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&textCol.r,false,"Debug effect:");
  834. gEnv->pRenderer->Draw2dLabel(currentTextPos.x+effectNameXOffset,currentTextPos.y,textSize,&effectNameCol.r,false,s_effectDebugList[s_currentDebugEffectId].effectName);
  835. currentTextPos.y += textYSpacing;
  836. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&controlCol.r,false,"(Change effect: NumPad +/-)");
  837. currentTextPos.y += textYSpacing;
  838. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&controlCol.r,false,"(Reload effect data: NumPad .)");
  839. currentTextPos.y += textYSpacing;
  840. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&controlCol.r,false,"(Reset Particle System: Delete)");
  841. currentTextPos.y += textYSpacing;
  842. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&controlCol.r,false,"(Pause Particle System: End)");
  843. currentTextPos.y += textYSpacing;
  844. if(s_effectDebugList[s_currentDebugEffectId].displayCallback)
  845. {
  846. s_effectDebugList[s_currentDebugEffectId].displayCallback(currentTextPos,textSize,textYSpacing);
  847. }
  848. if(m_debugView==eGAME_FX_DEBUG_VIEW_EffectList)
  849. {
  850. static Vec2 listPos(350.0f,50.0f);
  851. static float nameSize = 150.0f;
  852. static float tabSize = 60.0f;
  853. currentTextPos = listPos;
  854. const int EFFECT_LIST_COUNT = 2;
  855. GameSDKIGameEffect* pEffectListArray[EFFECT_LIST_COUNT] = {m_effectsToUpdate,m_effectsNotToUpdate};
  856. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&effectNameCol.r,false,"Name");
  857. currentTextPos.x += nameSize;
  858. const int FLAG_COUNT = 9;
  859. const char* flagName[FLAG_COUNT] = {"Init","Rel","ARels","ADels","AUWA","AUWnA","Reg","Actv","DBG"};
  860. const int flag[FLAG_COUNT] = {GAME_EFFECT_INITIALISED,
  861. GAME_EFFECT_RELEASED,
  862. GAME_EFFECT_AUTO_RELEASE,
  863. GAME_EFFECT_AUTO_DELETE,
  864. GAME_EFFECT_AUTO_UPDATES_WHEN_ACTIVE,
  865. GAME_EFFECT_AUTO_UPDATES_WHEN_NOT_ACTIVE,
  866. GAME_EFFECT_REGISTERED,
  867. GAME_EFFECT_ACTIVE,
  868. GAME_EFFECT_DEBUG_EFFECT};
  869. for(int i=0; i<FLAG_COUNT; i++)
  870. {
  871. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&effectNameCol.r,false,flagName[i]);
  872. currentTextPos.x += tabSize;
  873. }
  874. currentTextPos.y += textYSpacing;
  875. for(int l=0; l<EFFECT_LIST_COUNT; l++)
  876. {
  877. GameSDKIGameEffect* pCurrentEffect = pEffectListArray[l];
  878. while(pCurrentEffect)
  879. {
  880. currentTextPos.x = listPos.x;
  881. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&textCol.r,false,pCurrentEffect->GetName());
  882. currentTextPos.x += nameSize;
  883. for(int i=0; i<FLAG_COUNT; i++)
  884. {
  885. gEnv->pRenderer->Draw2dLabel(currentTextPos.x,currentTextPos.y,textSize,&textCol.r,false,pCurrentEffect->IsFlagSet(flag[i])?"1":"0");
  886. currentTextPos.x += tabSize;
  887. }
  888. currentTextPos.y += textYSpacing;
  889. pCurrentEffect = pCurrentEffect->Next();
  890. }
  891. }
  892. }
  893. }
  894. }
  895. #endif
  896. //--------------------------------------------------------------------------------------------------
  897. //--------------------------------------------------------------------------------------------------
  898. // Name: OnInputEvent
  899. // Desc: Handles any debug input for the game effects system to test effects
  900. //--------------------------------------------------------------------------------------------------
  901. bool GameSDKCGameEffectsSystem::OnInputEvent(const SInputEvent& inputEvent)
  902. {
  903. #if DEBUG_GAME_FX_SYSTEM
  904. int debugEffectCount = s_effectDebugList.Size();
  905. if((g_pGameCVars->g_gameFXSystemDebug) && (debugEffectCount > 0))
  906. {
  907. if(inputEvent.deviceType == eIDT_Keyboard && inputEvent.state == eIS_Pressed)
  908. {
  909. switch(inputEvent.keyId)
  910. {
  911. case GAME_FX_INPUT_IncrementDebugEffectId:
  912. {
  913. if(s_currentDebugEffectId < (debugEffectCount-1))
  914. {
  915. s_currentDebugEffectId++;
  916. }
  917. break;
  918. }
  919. case GAME_FX_INPUT_DecrementDebugEffectId:
  920. {
  921. if(s_currentDebugEffectId > 0)
  922. {
  923. s_currentDebugEffectId--;
  924. }
  925. break;
  926. }
  927. case GAME_FX_INPUT_DecrementDebugView:
  928. {
  929. if(m_debugView > 0)
  930. {
  931. OnDeActivateDebugView(m_debugView);
  932. m_debugView--;
  933. OnActivateDebugView(m_debugView);
  934. }
  935. break;
  936. }
  937. case GAME_FX_INPUT_IncrementDebugView:
  938. {
  939. if(m_debugView < (eMAX_GAME_FX_DEBUG_VIEWS-1))
  940. {
  941. OnDeActivateDebugView(m_debugView);
  942. m_debugView++;
  943. OnActivateDebugView(m_debugView);
  944. }
  945. break;
  946. }
  947. case GAME_FX_INPUT_ReloadEffectData:
  948. {
  949. ReloadData();
  950. break;
  951. }
  952. case GAME_FX_INPUT_ResetParticleManager:
  953. {
  954. gEnv->pParticleManager->Reset(false);
  955. break;
  956. }
  957. case GAME_FX_INPUT_PauseParticleManager:
  958. {
  959. #if DEBUG_GAME_FX_SYSTEM
  960. ICVar* pParticleDebugCVar = gEnv->pConsole->GetCVar("e_ParticlesDebug");
  961. if(pParticleDebugCVar)
  962. {
  963. int flagValue = pParticleDebugCVar->GetIVal();
  964. if(flagValue & AlphaBit('z'))
  965. {
  966. flagValue &= ~AlphaBit('z');
  967. }
  968. else
  969. {
  970. flagValue |= AlphaBit('z');
  971. }
  972. pParticleDebugCVar->Set(flagValue);
  973. }
  974. #endif
  975. break;
  976. }
  977. }
  978. // Send input to current debug effect
  979. if(s_effectDebugList[s_currentDebugEffectId].inputCallback)
  980. {
  981. s_effectDebugList[s_currentDebugEffectId].inputCallback(inputEvent.keyId);
  982. }
  983. }
  984. }
  985. #endif
  986. return false; // Return false so that other listeners will get this event
  987. }//-------------------------------------------------------------------------------------------------
  988. //--------------------------------------------------------------------------------------------------
  989. // Name: GetDebugEffect
  990. // Desc: Gets debug instance of effect
  991. //--------------------------------------------------------------------------------------------------
  992. #if DEBUG_GAME_FX_SYSTEM
  993. GameSDKIGameEffect* GameSDKCGameEffectsSystem::GetDebugEffect(const char* pEffectName) const
  994. {
  995. const int EFFECT_LIST_COUNT = 2;
  996. GameSDKIGameEffect* pEffectListArray[EFFECT_LIST_COUNT] = {m_effectsToUpdate,m_effectsNotToUpdate};
  997. for(int l=0; l<EFFECT_LIST_COUNT;l++)
  998. {
  999. GameSDKIGameEffect* pCurrentEffect = pEffectListArray[l];
  1000. while(pCurrentEffect)
  1001. {
  1002. if(pCurrentEffect->IsFlagSet(GAME_EFFECT_DEBUG_EFFECT) &&
  1003. (strcmp(pCurrentEffect->GetName(),pEffectName) == 0))
  1004. {
  1005. return pCurrentEffect;
  1006. }
  1007. pCurrentEffect = pCurrentEffect->Next();
  1008. }
  1009. }
  1010. return NULL;
  1011. }
  1012. #endif
  1013. //--------------------------------------------------------------------------------------------------
  1014. //--------------------------------------------------------------------------------------------------
  1015. // Name: OnActivateDebugView
  1016. // Desc: Called on debug view activation
  1017. //--------------------------------------------------------------------------------------------------
  1018. #if DEBUG_GAME_FX_SYSTEM
  1019. void GameSDKCGameEffectsSystem::OnActivateDebugView(int debugView)
  1020. {
  1021. switch(debugView)
  1022. {
  1023. case eGAME_FX_DEBUG_VIEW_Profiling:
  1024. {
  1025. ICVar* r_displayInfoCVar = gEnv->pConsole->GetCVar("r_DisplayInfo");
  1026. if(r_displayInfoCVar)
  1027. {
  1028. r_displayInfoCVar->Set(1);
  1029. }
  1030. break;
  1031. }
  1032. }
  1033. }
  1034. #endif
  1035. //--------------------------------------------------------------------------------------------------
  1036. //--------------------------------------------------------------------------------------------------
  1037. // Name: OnDeActivateDebugView
  1038. // Desc: Called on debug view de-activation
  1039. //--------------------------------------------------------------------------------------------------
  1040. #if DEBUG_GAME_FX_SYSTEM
  1041. void GameSDKCGameEffectsSystem::OnDeActivateDebugView(int debugView)
  1042. {
  1043. switch(debugView)
  1044. {
  1045. case eGAME_FX_DEBUG_VIEW_Profiling:
  1046. {
  1047. ICVar* r_displayInfoCVar = gEnv->pConsole->GetCVar("r_DisplayInfo");
  1048. if(r_displayInfoCVar)
  1049. {
  1050. r_displayInfoCVar->Set(0);
  1051. }
  1052. break;
  1053. }
  1054. }
  1055. }
  1056. #endif
  1057. //--------------------------------------------------------------------------------------------------
  1058. //--------------------------------------------------------------------------------------------------
  1059. // Name: RegisterEffectDebugData
  1060. // Desc: Registers effect's debug data with the game effects system, which will then call the
  1061. // relevant debug callback functions for the for the effect when its selected using the
  1062. // s_currentDebugEffectId
  1063. //--------------------------------------------------------------------------------------------------
  1064. #if DEBUG_GAME_FX_SYSTEM
  1065. void GameSDKCGameEffectsSystem::RegisterEffectDebugData( DebugOnInputEventCallback inputEventCallback,
  1066. DebugDisplayCallback displayCallback,
  1067. const char* effectName)
  1068. {
  1069. s_effectDebugList.push_back(SEffectDebugData(inputEventCallback,displayCallback,effectName));
  1070. }
  1071. #endif
  1072. //--------------------------------------------------------------------------------------------------