1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef GROUP_H 4 #define GROUP_H 5 6 #include <vector> 7 8 #include "Sim/Units/CommandAI/Command.h" 9 #include "Sim/Units/UnitSet.h" 10 #include "System/creg/creg_cond.h" 11 #include "System/float3.h" 12 13 class CUnit; 14 class CFeature; 15 class CGroupHandler; 16 17 /** 18 * Logic group of units denoted by a number. 19 * A group-ID/-number is unique per team (-> per groupHandler). 20 */ 21 class CGroup 22 { 23 CR_DECLARE_STRUCT(CGroup) 24 25 public: 26 CGroup(int id, CGroupHandler* groupHandler); 27 ~CGroup(); 28 void PostLoad(); 29 30 void Update(); 31 32 /** 33 * Note: Call unit.SetGroup(NULL) instead of calling this directly. 34 */ 35 void RemoveUnit(CUnit* unit); 36 /** 37 * Note: Call unit.SetGroup(group) instead of calling this directly. 38 */ 39 bool AddUnit(CUnit* unit); 40 void ClearUnits(); 41 42 float3 CalculateCenter() const; 43 44 private: 45 void RemoveIfEmptySpecialGroup(); 46 47 public: 48 int id; 49 CUnitSet units; 50 51 private: 52 CGroupHandler* handler; 53 }; 54 55 #endif // GROUP_H 56