BVB Source Codes

CRYENGINE Show GroupManager.cpp Source code

Return Download CRYENGINE: download GroupManager.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #include "StdAfx.h"
  4. #include "GroupManager.h"
  5. #include "Group.h"
  6.  
  7. static Group s_emptyGroup;
  8.  
  9. CGroupManager::CGroupManager()
  10.         : m_notifications(0)
  11. {
  12. }
  13.  
  14. CGroupManager::~CGroupManager()
  15. {
  16.         Group::ClearStaticData();
  17. }
  18.  
  19. void CGroupManager::Reset(EObjectResetType type)
  20. {
  21.         Group::ClearStaticData();
  22.  
  23.         Groups::iterator it = m_groups.begin();
  24.         Groups::iterator end = m_groups.end();
  25.  
  26.         for (; it != end; ++it)
  27.         {
  28.                 Group& group = it->second;
  29.  
  30.                 group.Reset(type);
  31.         }
  32. }
  33.  
  34. void CGroupManager::Update(float updateTime)
  35. {
  36.         Groups::iterator it = m_groups.begin();
  37.         Groups::iterator end = m_groups.end();
  38.  
  39.         for (; it != end; ++it)
  40.         {
  41.                 Group& group = it->second;
  42.  
  43.                 group.Update(updateTime);
  44.         }
  45. }
  46.  
  47. void CGroupManager::AddGroupMember(const GroupID& groupID, tAIObjectID objectID)
  48. {
  49.         std::pair<Groups::iterator, bool> iresult = m_groups.insert(Groups::value_type(groupID, Group()));
  50.         Group& group = iresult.first->second;
  51.  
  52.         if (iresult.second)
  53.         {
  54.                 Group(groupID).Swap(group);
  55.         }
  56.  
  57.         group.AddMember(objectID);
  58. }
  59.  
  60. void CGroupManager::RemoveGroupMember(const GroupID& groupID, tAIObjectID objectID)
  61. {
  62.         Groups::iterator git = m_groups.find(groupID);
  63.  
  64.         if (git != m_groups.end())
  65.         {
  66.                 Group& group = git->second;
  67.  
  68.                 group.RemoveMember(objectID);
  69.         }
  70. }
  71.  
  72. Group& CGroupManager::GetGroup(const GroupID& groupID)
  73. {
  74.         Groups::iterator git = m_groups.find(groupID);
  75.         if (git != m_groups.end())
  76.         {
  77.                 Group& group = git->second;
  78.  
  79.                 return group;
  80.         }
  81.  
  82.         return s_emptyGroup;
  83. }
  84.  
  85. const Group& CGroupManager::GetGroup(const GroupID& groupID) const
  86. {
  87.         Groups::const_iterator git = m_groups.find(groupID);
  88.         if (git != m_groups.end())
  89.         {
  90.                 const Group& group = git->second;
  91.  
  92.                 return group;
  93.         }
  94.  
  95.         return s_emptyGroup;
  96. }
  97.  
  98. uint32 CGroupManager::GetGroupMemberCount(const GroupID& groupID) const
  99. {
  100.         Groups::const_iterator git = m_groups.find(groupID);
  101.  
  102.         if (git != m_groups.end())
  103.         {
  104.                 const Group& group = git->second;
  105.  
  106.                 return group.GetMemberCount();
  107.         }
  108.  
  109.         return 0;
  110. }
  111.  
  112. Group::NotificationID CGroupManager::NotifyGroup(const GroupID& groupID, tAIObjectID senderID, const char* name)
  113. {
  114.         if (groupID > 0)
  115.         {
  116.                 Group& group = GetGroup(groupID);
  117.  
  118.                 group.Notify(++m_notifications, senderID, name);
  119.         }
  120.  
  121.         return m_notifications;
  122. }
  123.  
  124. void CGroupManager::Serialize(TSerialize ser)
  125. {
  126.         ser.BeginGroup("CGroupManager");
  127.         {
  128.                 ser.Value("Groups", m_groups);
  129.                 ser.Value("m_notifications", m_notifications);
  130.         }
  131.         ser.EndGroup();
  132. }
  133.  
downloadGroupManager.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