BVB Source Codes

CRYENGINE Show ScriptBind_DialogSystem.cpp Source code

Return Download CRYENGINE: download ScriptBind_DialogSystem.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   ScriptBind_DialogSystem.cpp
  5. //  Version:     v1.00
  6. //  Created:     02/08/2006 by AlexL
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: Dialog System ScriptBinding
  9. // -------------------------------------------------------------------------
  10. //  History:
  11. //
  12. ////////////////////////////////////////////////////////////////////////////
  13. #include "StdAfx.h"
  14. #include "ScriptBind_DialogSystem.h"
  15. #include "DialogSystem.h"
  16. #include "DialogSession.h"
  17.  
  18. //------------------------------------------------------------------------
  19. CScriptBind_DialogSystem::CScriptBind_DialogSystem(ISystem* pSystem, CDialogSystem* pDS)
  20. {
  21.         m_pSystem = pSystem;
  22.         m_pEntitySystem = gEnv->pEntitySystem;
  23.         m_pDS = pDS;
  24.         assert(m_pDS != 0);
  25.  
  26.         Init(gEnv->pScriptSystem, m_pSystem);
  27.         SetGlobalName("DialogSystem");
  28.  
  29.         RegisterGlobals();
  30.         RegisterMethods();
  31. }
  32.  
  33. //------------------------------------------------------------------------
  34. CScriptBind_DialogSystem::~CScriptBind_DialogSystem()
  35. {
  36. }
  37.  
  38. //------------------------------------------------------------------------
  39. void CScriptBind_DialogSystem::RegisterGlobals()
  40. {
  41. }
  42.  
  43. //------------------------------------------------------------------------
  44. void CScriptBind_DialogSystem::RegisterMethods()
  45. {
  46. #undef SCRIPT_REG_CLASSNAME
  47. #define SCRIPT_REG_CLASSNAME &CScriptBind_DialogSystem::
  48.  
  49.         SCRIPT_REG_TEMPLFUNC(CreateSession, "scriptID");
  50.         SCRIPT_REG_TEMPLFUNC(DeleteSession, "sessionID");
  51.         SCRIPT_REG_TEMPLFUNC(SetActor, "sessionID, actorID, entityID");
  52.         SCRIPT_REG_TEMPLFUNC(Play, "sessionID");
  53.         SCRIPT_REG_TEMPLFUNC(Stop, "sessionID");
  54.         SCRIPT_REG_TEMPLFUNC(IsEntityInDialog, "entityID");
  55. }
  56.  
  57. //------------------------------------------------------------------------
  58. int CScriptBind_DialogSystem::CreateSession(IFunctionHandler* pH, const char* scriptID)
  59. {
  60.         CDialogSystem::SessionID sessionID = m_pDS->CreateSession(scriptID);
  61.         return pH->EndFunction(sessionID);
  62. }
  63.  
  64. //------------------------------------------------------------------------
  65. int CScriptBind_DialogSystem::DeleteSession(IFunctionHandler* pH, int sessionID)
  66. {
  67.         const bool ok = m_pDS->DeleteSession(sessionID);
  68.         return pH->EndFunction(ok);
  69. }
  70.  
  71. //------------------------------------------------------------------------
  72. int CScriptBind_DialogSystem::SetActor(IFunctionHandler* pH, int sessionID, int actorID, ScriptHandle entity)
  73. {
  74.         bool ok = false;
  75.         CDialogSession* pSession = m_pDS->GetSession(sessionID);
  76.         if (pSession)
  77.         {
  78.                 ok = pSession->SetActor(actorID, (EntityId) entity.n);
  79.         }
  80.         else
  81.         {
  82.                 GameWarning("[DiaLOG] CScriptBind_DialogSystem::SetActor: Cannot find session %d", sessionID);
  83.         }
  84.         return pH->EndFunction(ok);
  85. }
  86.  
  87. //------------------------------------------------------------------------
  88. int CScriptBind_DialogSystem::Play(IFunctionHandler* pH, int sessionID)
  89. {
  90.         bool ok = false;
  91.         CDialogSession* pSession = m_pDS->GetSession(sessionID);
  92.         if (pSession)
  93.         {
  94.                 pSession->SetAutoDelete(true);
  95.                 ok = pSession->Play();
  96.         }
  97.         else
  98.         {
  99.                 GameWarning("[DiaLOG] CScriptBind_DialogSystem::Play: Cannot find session %d", sessionID);
  100.         }
  101.         return pH->EndFunction(ok);
  102. }
  103.  
  104. //------------------------------------------------------------------------
  105. int CScriptBind_DialogSystem::Stop(IFunctionHandler* pH, int sessionID)
  106. {
  107.         bool ok = false;
  108.         CDialogSession* pSession = m_pDS->GetSession(sessionID);
  109.         if (pSession)
  110.         {
  111.                 pSession->Stop();
  112.                 m_pDS->DeleteSession(sessionID);
  113.         }
  114.         else
  115.         {
  116.                 GameWarning("[DiaLOG] CScriptBind_DialogSystem::Play: Cannot find session %d", sessionID);
  117.         }
  118.         return pH->EndFunction(ok);
  119. }
  120.  
  121. //------------------------------------------------------------------------
  122. int CScriptBind_DialogSystem::IsEntityInDialog(IFunctionHandler* pH, ScriptHandle entity)
  123. {
  124.         CDialogScript::TActorID actorID;
  125.         CDialogSystem::SessionID sessionID;
  126.         const bool inDialog = m_pDS->FindSessionAndActorForEntity((EntityId)entity.n, sessionID, actorID);
  127.         return pH->EndFunction(inDialog);
  128. }
  129.  
downloadScriptBind_DialogSystem.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