BVB Source Codes

CRYENGINE Show FlowSystemCVars.cpp Source code

Return Download CRYENGINE: download FlowSystemCVars.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: CVars for the FlowSystem
  8.    -------------------------------------------------------------------------
  9.    History:
  10.    - 02:03:2006  12:00 : Created by AlexL
  11.  
  12. *************************************************************************/
  13.  
  14. #include "StdAfx.h"
  15. #include "FlowSystemCVars.h"
  16. #include "Inspectors/FlowFilters.h"
  17. #include <CryAction.h>
  18. #include <CryFlowGraph/IFlowSystem.h>
  19.  
  20. CFlowSystemCVars* CFlowSystemCVars::s_pThis = 0;
  21.  
  22. namespace
  23. {
  24. IFlowGraphInspector::IFilterPtr pTheFilter;
  25.  
  26. void SetCurrentFilter(IFlowGraphInspector::IFilterPtr pFilter)
  27. {
  28.         static IFlowSystem* pFlowSystem = CCryAction::GetCryAction()->GetIFlowSystem();
  29.         IFlowGraphInspectorPtr pInspector = pFlowSystem->GetDefaultInspector();
  30.         if (pTheFilter)
  31.                 pInspector->RemoveFilter(pTheFilter);
  32.         pTheFilter = pFilter;
  33.         if (pTheFilter)
  34.         {
  35.                 pInspector->AddFilter(pTheFilter);
  36.                 pFlowSystem->EnableInspecting(true);
  37.         }
  38. }
  39.  
  40. const char* MakeEmptyIfAny(const char* param)
  41. {
  42.         if (param && stricmp(param, "_ANY") == 0)
  43.                 return "";
  44.         return param;
  45. }
  46.  
  47. EntityId GetEntityIdByName(const char* entityName)
  48. {
  49.         if (entityName == 0 || entityName[0] == '\0')
  50.                 return 0;
  51.         static IEntitySystem* pEntitySys = gEnv->pEntitySystem;
  52.         IEntity* pEntity = pEntitySys->FindEntityByName(entityName);
  53.         if (pEntity != 0)
  54.                 return pEntity->GetId();
  55.  
  56.         GameWarning("Entity '%s' not found", entityName);
  57.         return 0;
  58. }
  59.  
  60. // called when ConsoleVariable fg_Inspector changes
  61. void Inspector(IConsoleCmdArgs* args)
  62. {
  63.         const int argCount = args->GetArgCount();
  64.         if (argCount < 2 || argCount > 6)
  65.         {
  66.                 GameWarning("Usage: %s [0/1]", args->GetArg(0));
  67.                 return;
  68.         }
  69.         int mode = atoi(args->GetArg(1));
  70.         CCryAction::GetCryAction()->GetIFlowSystem()->EnableInspecting(mode == 0 ? false : true);
  71.         SetCurrentFilter(0);    // clear all filters
  72. }
  73.  
  74. void InspectAction(IConsoleCmdArgs* args)
  75. {
  76.         const int argCount = args->GetArgCount();
  77.         if (argCount < 2 || argCount > 6)
  78.         {
  79.                 GameWarning("Usage: %s [ActionName] [UserClass] [ObjectClass] [UserEntityName] [ObjectEntityName]", args->GetArg(0));
  80.                 return;
  81.         }
  82.  
  83.         // at least one arg
  84.         const char* actionName = args->GetArg(1);
  85.         bool isAnyAction = stricmp(actionName, "_ANY") == 0;
  86.  
  87.         if (!isAnyAction && gEnv->pAISystem && gEnv->pAISystem->GetAIActionManager()->GetAIAction(actionName) == 0)
  88.         {
  89.                 GameWarning("AIAction '%s' not found", actionName);
  90.                 return;
  91.         }
  92.  
  93.         const char* userClass = 0;
  94.         const char* objectClass = 0;
  95.         const char* userEntity = 0;
  96.         const char* objectEntity = 0;
  97.         if (argCount > 2)
  98.                 userClass = args->GetArg(2);
  99.         if (argCount > 3)
  100.                 objectClass = args->GetArg(3);
  101.         if (argCount > 4)
  102.                 userEntity = args->GetArg(4);
  103.         if (argCount > 5)
  104.                 objectEntity = args->GetArg(5);
  105.  
  106.         actionName = MakeEmptyIfAny(actionName);
  107.         userClass = MakeEmptyIfAny(userClass);
  108.         objectClass = MakeEmptyIfAny(objectClass);
  109.         userEntity = MakeEmptyIfAny(userEntity);
  110.         objectEntity = MakeEmptyIfAny(objectEntity);
  111.  
  112.         EntityId userId = GetEntityIdByName(userEntity);
  113.         EntityId objectId = GetEntityIdByName(objectEntity);
  114.  
  115.         CFlowFilterAIAction* pFilter = new CFlowFilterAIAction();
  116.         pFilter->SetAction(actionName);
  117.         pFilter->SetParams(userClass, objectClass, userId, objectId);
  118.         SetCurrentFilter(pFilter);
  119. }
  120.  
  121. void InspectEntity(IConsoleCmdArgs* args)
  122. {
  123.         const int argCount = args->GetArgCount();
  124.         if (argCount < 2 || argCount > 2)
  125.         {
  126.                 GameWarning("Usage: %s [EntityName]", args->GetArg(0));
  127.                 return;
  128.         }
  129.  
  130.         // at least one arg
  131.         const char* entityName = args->GetArg(1);
  132.         if (entityName[0] == '\0')
  133.         {
  134.                 SetCurrentFilter(0);
  135.                 return;
  136.         }
  137.         EntityId entityId = 0;
  138.         if (entityName[0] == '#' && entityName[1] == '#')
  139.                 entityId = atoi(entityName + 2);
  140.         else
  141.                 entityId = GetEntityIdByName(entityName);
  142.         if (entityId == 0)
  143.                 return;
  144.  
  145.         CFlowFilterEntity* pFilter = new CFlowFilterEntity();
  146.         pFilter->SetEntity(entityId);
  147.         SetCurrentFilter(pFilter);
  148. }
  149. };
  150.  
  151. CFlowSystemCVars::CFlowSystemCVars()
  152. {
  153.         assert(s_pThis == 0);
  154.         s_pThis = this;
  155.  
  156.         IConsole* pConsole = gEnv->pConsole;
  157.  
  158.         REGISTER_COMMAND("fg_Inspector", Inspector, 0,
  159.                          "Toggles FlowGraph System DefaultInspector.\n"
  160.                          "Usage: fg_Inspector [0/1]\n"
  161.                          "Default is 0 (off).");
  162.         REGISTER_COMMAND("fg_InspectEntity", InspectEntity, 0, "Inspects the specified Entity graph");
  163.         REGISTER_COMMAND("fg_InspectAction", InspectAction, 0, "Inspects the specified AIAction graph");
  164.         REGISTER_CVAR2("fg_SystemEnable", &this->m_enableUpdates, 1, VF_CHEAT, "Toggles FlowGraph System Updates.\nUsage: fg_SystemEnable [0/1]\nDefault is 1 (on).");
  165.         REGISTER_CVAR2("fg_profile", &this->m_profile, 0, 0, "Flow graph profiling enable/disable");
  166.         REGISTER_CVAR2("fg_inspectorLog", &this->m_inspectorLog, 0, 0, "Log inspector on console.");
  167.  
  168. #ifdef _RELEASE
  169.         REGISTER_CVAR2("fg_abortOnLoadError", &this->m_abortOnLoadError, 0, VF_NULL, "Abort on load error of flowgraphs\n2:abort, 1:dialog, 0:log only");
  170.         REGISTER_CVAR2("fg_noDebugText", &this->m_noDebugText, 1, VF_NULL, "Don't show debug text [0/1]\nDefault is 0 (show debug text).");
  171. #else
  172.         REGISTER_CVAR2("fg_abortOnLoadError", &this->m_abortOnLoadError, 1, VF_NULL, "Abort on load error of flowgraphs\n2:abort, 1:dialog, 0:log only");
  173.         REGISTER_CVAR2("fg_noDebugText", &this->m_noDebugText, 0, VF_NULL, "Don't show debug text [0/1]\nDefault is 0 (show debug text).");
  174. #endif
  175.  
  176.         REGISTER_CVAR2("fg_iEnableFlowgraphNodeDebugging", &this->m_enableFlowgraphNodeDebugging, 0, VF_DUMPTODISK, "Toggles visual flowgraph debugging.");
  177.         REGISTER_CVAR2("fg_iDebugNextStep", &this->m_debugNextStep, 0, VF_DUMPTODISK, "Update flowgraph debug by one step.");
  178. }
  179.  
  180. CFlowSystemCVars::~CFlowSystemCVars()
  181. {
  182.         assert(s_pThis != 0);
  183.         s_pThis = 0;
  184.  
  185.         IConsole* pConsole = gEnv->pConsole;
  186.  
  187.         pConsole->RemoveCommand("fg_Inspector");
  188.         pConsole->RemoveCommand("fg_InspectEntity");
  189.         pConsole->RemoveCommand("fg_InspectAction");
  190.  
  191.         pConsole->UnregisterVariable("fg_SystemEnable", true);
  192.         pConsole->UnregisterVariable("fg_profile", true);
  193.         pConsole->UnregisterVariable("fg_abortOnLoadError", true);
  194.         pConsole->UnregisterVariable("fg_inspectorLog", true);
  195.         pConsole->UnregisterVariable("fg_noDebugText", true);
  196.  
  197.         pConsole->UnregisterVariable("fg_iEnableFlowgraphNodeDebugging", true);
  198.         pConsole->UnregisterVariable("fg_iDebugNextStep", true);
  199. }
  200.  
downloadFlowSystemCVars.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