home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 January / Gamestar_69_2005-01_dvd.iso / Dema / theprojectv1-0.exe / FCData / Scripts.pak / Scripts / EntityGroupMgr.lua < prev    next >
Encoding:
Text File  |  2004-07-21  |  1.5 KB  |  63 lines

  1. -------------------------------------------------------
  2. --
  3. --    Crytek Studios 2001
  4. --    FILE            :    EntityGroupMgr.lua
  5. --    Created by: Alberto Demichelis
  6. --    date            :    07 November 2001
  7. --
  8. -------------------------------------------------------
  9. EntityGroupMgr = {
  10.     groups={}
  11. }
  12.  
  13. -------------------------------------------------------
  14. function EntityGroupMgr:AddEntity(_group,_entity)
  15.     local group=self.groups[_group];
  16.     if(group == nil) then
  17.         self.groups[_group]={};
  18.     end
  19.     self.groups[_group][_entity.id]=_entity;
  20. end
  21.  
  22. -------------------------------------------------------
  23. function EntityGroupMgr:RemoveEntity(_group,_entity)
  24.     local group=self.groups[_group];
  25.     if(group ~= nil) then
  26.         group[_entity.id]=nil;
  27.     end
  28. end
  29.  
  30. -------------------------------------------------------
  31. function EntityGroupMgr:RemoveGroup(_group)
  32.     self.groups[_group]=nil
  33. end
  34.  
  35. -------------------------------------------------------
  36. function EntityGroupMgr:CallFunction(_group,_action,...)
  37.     local group=self.groups[_group];
  38.     
  39.     if(group ~= nil) then
  40.         for i,entity in group do
  41.             if(arg.n==0) then
  42.                 entity[_action](entity);
  43.             else
  44.                 tinsert(arg,1,entity);
  45.                 call(entity[_action],arg);
  46.             end 
  47.         end
  48.     end
  49. end
  50.  
  51. -------------------------------------------------------
  52. function EntityGroupMgr:GetElementsCount(_group)
  53.     local group=self.groups[_group];
  54.     if(group ~= nil) then
  55.         return getn(group);
  56.     end
  57. end
  58.  
  59. -------------------------------------------------------
  60. function EntityGroupMgr:GetGroup(_group)
  61.     return self.groups[_group];
  62. end
  63.