BVB Source Codes

CRYENGINE Show UnitAction.cpp Source code

Return Download CRYENGINE: download UnitAction.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /********************************************************************
  4.    -------------------------------------------------------------------------
  5.    File name:   UnitAction.cpp
  6.    $Id$
  7.    Description: Refactoring CLeadeActions; adding Serialization support
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 2:6:2005   15:23 : Created by Kirill Bulatsev
  12.  
  13.  *********************************************************************/
  14.  
  15. #include "StdAfx.h"
  16. #include "UnitAction.h"
  17. #include "AISignal.h"
  18. #include <CryNetwork/ISerialize.h>
  19.  
  20. //
  21. //----------------------------------------------------------------------------------------------------
  22. // cppcheck-suppress uninitMemberVar
  23. CUnitAction::CUnitAction() :
  24.         m_Action(UA_NONE)
  25. {
  26. }
  27.  
  28. //
  29. //----------------------------------------------------------------------------------------------------
  30. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking) :
  31.         m_Action(eAction),
  32.         m_BlockingPlan(bBlocking),
  33.         m_Priority(PRIORITY_NORMAL),
  34.         m_fDistance(1),
  35.         m_Tag(0)
  36. {
  37. }
  38.  
  39. //
  40. //----------------------------------------------------------------------------------------------------
  41. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, const Vec3& point) :
  42.         m_Action(eAction),
  43.         m_BlockingPlan(bBlocking),
  44.         m_Point(point),
  45.         m_Priority(PRIORITY_NORMAL),
  46.         m_fDistance(1),
  47.         m_Tag(0)
  48. {
  49. }
  50. //
  51. //----------------------------------------------------------------------------------------------------
  52. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, const Vec3& point, const Vec3& dir) :
  53.         m_Action(eAction),
  54.         m_BlockingPlan(bBlocking),
  55.         m_Point(point),
  56.         m_Direction(dir),
  57.         m_Priority(PRIORITY_NORMAL),
  58.         m_fDistance(1),
  59.         m_Tag(0)
  60. {
  61. }
  62. //
  63. //----------------------------------------------------------------------------------------------------
  64. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, float fDistance) :
  65.         m_Action(eAction),
  66.         m_BlockingPlan(bBlocking),
  67.         m_fDistance(fDistance),
  68.         m_Priority(PRIORITY_NORMAL),
  69.         m_Tag(0)
  70. {
  71. }
  72.  
  73. //
  74. //----------------------------------------------------------------------------------------------------
  75. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, const char* szText) :
  76.         m_Action(eAction),
  77.         m_BlockingPlan(bBlocking),
  78.         m_SignalText(szText),
  79.         m_Priority(PRIORITY_NORMAL),
  80.         m_fDistance(1),
  81.         m_Tag(0)
  82. {
  83. }
  84.  
  85. //
  86. //----------------------------------------------------------------------------------------------------
  87. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, const char* szText, const AISignalExtraData& data) :
  88.         m_Action(eAction),
  89.         m_BlockingPlan(bBlocking),
  90.         m_SignalText(szText),
  91.         m_Priority(PRIORITY_NORMAL),
  92.         m_fDistance(1),
  93.         m_SignalData(data),
  94.         m_Tag(0)
  95. {
  96. }
  97.  
  98. //
  99. //----------------------------------------------------------------------------------------------------
  100. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, int priority) :
  101.         m_Action(eAction),
  102.         m_BlockingPlan(bBlocking),
  103.         m_Priority(priority),
  104.         m_fDistance(1),
  105.         m_Tag(0)
  106. {
  107. }
  108.  
  109. //
  110. //----------------------------------------------------------------------------------------------------
  111. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, int priority, const Vec3& point) :
  112.         m_Action(eAction),
  113.         m_BlockingPlan(bBlocking),
  114.         m_Point(point),
  115.         m_Priority(priority),
  116.         m_fDistance(1),
  117.         m_Tag(0)
  118. {
  119. }
  120.  
  121. //
  122. //----------------------------------------------------------------------------------------------------
  123. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, int priority, const char* szText) :
  124.         m_Action(eAction),
  125.         m_BlockingPlan(bBlocking),
  126.         m_SignalText(szText),
  127.         m_Priority(priority),
  128.         m_fDistance(1),
  129.         m_Tag(0)
  130. {
  131. }
  132.  
  133. //
  134. //----------------------------------------------------------------------------------------------------
  135. CUnitAction::CUnitAction(EUnitAction eAction, bool bBlocking, int priority, const char* szText, const AISignalExtraData& data) :
  136.         m_Action(eAction),
  137.         m_BlockingPlan(bBlocking),
  138.         m_SignalText(szText),
  139.         m_Priority(priority),
  140.         m_fDistance(1),
  141.         m_SignalData(data),
  142.         m_Tag(0)
  143. {
  144. }
  145.  
  146. //
  147. //----------------------------------------------------------------------------------------------------
  148. CUnitAction::~CUnitAction()
  149. {
  150.         //unlock all my blocked actions
  151.         UnlockMyBlockedActions();
  152.         NotifyMyBlockingActions();
  153. }
  154.  
  155. //
  156. //----------------------------------------------------------------------------------------------------
  157. void CUnitAction::BlockedBy(CUnitAction* blockingAction)
  158. {
  159.         m_BlockingActions.push_back(blockingAction);
  160.         blockingAction->m_BlockedActions.push_back(this);
  161. }
  162.  
  163. //
  164. //----------------------------------------------------------------------------------------------------
  165. void CUnitAction::UnlockMyBlockedActions()
  166. {
  167.         // unlock all the blocked actions
  168.         //
  169.         for (TActionList::iterator itAction = m_BlockedActions.begin(); itAction != m_BlockedActions.end(); ++itAction)
  170.         {
  171.                 CUnitAction* blockedAction = (*itAction);
  172.                 TActionList::iterator itOtherUnitAction = find(blockedAction->m_BlockingActions.begin(), blockedAction->m_BlockingActions.end(), this);
  173.  
  174.                 if (itOtherUnitAction != blockedAction->m_BlockingActions.end())
  175.                         blockedAction->m_BlockingActions.erase(itOtherUnitAction);// delete myself's pointer from the other action's blocking actions list
  176.  
  177.         }
  178. }
  179.  
  180. //
  181. //----------------------------------------------------------------------------------------------------
  182. void CUnitAction::NotifyMyBlockingActions()
  183. {
  184.         // remove myself from the Blocking actions' list (so they won't block a finished action)
  185.         for (TActionList::iterator itAction = m_BlockingActions.begin(); itAction != m_BlockingActions.end(); ++itAction)
  186.         {
  187.                 CUnitAction* blockingAction = (*itAction);
  188.                 TActionList::iterator itOtherUnitAction = std::find(blockingAction->m_BlockedActions.begin(), blockingAction->m_BlockedActions.end(), this);
  189.  
  190.                 if (itOtherUnitAction != blockingAction->m_BlockedActions.end())
  191.                         blockingAction->m_BlockedActions.erase(itOtherUnitAction);// delete myself's pointer from the other action's blocking actions list
  192.  
  193.         }
  194. }
  195.  
downloadUnitAction.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