1 /** 2 * @file 3 * @brief Header for employee related stuff. 4 */ 5 6 /* 7 Copyright (C) 2002-2013 UFO: Alien Invasion. 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2 12 of the License, or (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 18 See the GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 */ 24 25 #pragma once 26 27 /** 28 * @brief The types of employees. 29 */ 30 typedef enum { 31 EMPL_SOLDIER, 32 EMPL_SCIENTIST, 33 EMPL_WORKER, 34 EMPL_PILOT, 35 EMPL_ROBOT, 36 MAX_EMPL /**< For counting over all available enums. */ 37 } employeeType_t; 38 39 /** The definition of an employee */ 40 class Employee { 41 private: 42 const employeeType_t _type; /**< employee type */ 43 bool _assigned; /**< Assigned to a building - currently only used for scientists */ 44 const struct nation_s* _nation; /**< What nation this employee came from. This is nullptr if the nation is unknown for some (code-related) reason. */ 45 const struct ugv_s* _ugv; /**< if this is an employee of type EMPL_ROBOT then this is a pointer to the matching ugv_t struct. For normal employees this is nullptr. */ 46 47 public: Employee(employeeType_t type,const struct nation_s * nation,const struct ugv_s * ugv)48 Employee (employeeType_t type, const struct nation_s* nation, const struct ugv_s* ugv) : 49 _type(type), _assigned(false), _nation(nation), _ugv(ugv), baseHired(nullptr), transfer(false) { 50 } 51 ~Employee()52 virtual ~Employee () { 53 } 54 55 /** 56 * @return @c true if the employee is not yet assigned to a building 57 */ isAssigned()58 inline bool isAssigned () const { 59 return _assigned; 60 } 61 setAssigned(bool assigned)62 inline void setAssigned(bool assigned) { 63 _assigned = assigned; 64 } 65 isPilot()66 inline bool isPilot () const { 67 return _type == EMPL_PILOT; 68 } 69 isRobot()70 inline bool isRobot () const { 71 return _type == EMPL_ROBOT; 72 } 73 isScientist()74 inline bool isScientist () const { 75 return _type == EMPL_SCIENTIST; 76 } 77 isWorker()78 inline bool isWorker () const { 79 return _type == EMPL_WORKER; 80 } 81 isSoldier()82 inline bool isSoldier () const { 83 return _type == EMPL_SOLDIER; 84 } 85 isHired()86 inline bool isHired () const { 87 return baseHired != nullptr; 88 } 89 90 /** 91 * @brief Checks whether the given employee is in the given base 92 * @param[in] base The base the employee must be hired in for this function to return @c true. 93 */ isHiredInBase(const base_t * const base)94 inline bool isHiredInBase (const base_t* const base) const { 95 assert(base != nullptr); 96 return baseHired == base; 97 } 98 getType()99 inline employeeType_t getType() const { 100 return _type; 101 } 102 getNation()103 inline const struct nation_s* getNation() const { 104 return _nation; 105 } 106 getUGV()107 inline const struct ugv_s* getUGV() const { 108 return _ugv; 109 } 110 111 bool isAwayFromBase () const; 112 base_t* unassign (); 113 bool unhire (); 114 115 base_t* baseHired; /**< Base where the soldier is hired it atm. */ 116 bool transfer; /**< Is this employee currently transferred? */ 117 character_t chr; /**< employee stats */ 118 }; 119 120 #define E_Foreach(employeeType, var) LIST_Foreach(ccs.employees[employeeType], Employee, var) 121 122 Employee* E_CreateEmployee(employeeType_t type, const struct nation_s* nation, const struct ugv_s* ugvType = nullptr); 123 bool E_DeleteEmployee(Employee* employee); 124 125 /* count */ 126 int E_CountByType(employeeType_t type); 127 int E_CountHired(const base_t* const base, employeeType_t type); 128 int E_CountHiredRobotByType(const base_t* const base, const struct ugv_s* ugvType); 129 int E_CountAllHired(const base_t* const base); 130 int E_CountUnhired(employeeType_t type); 131 int E_CountUnhiredRobotsByType(const struct ugv_s* ugvType); 132 int E_CountUnassigned(const base_t* const base, employeeType_t type); 133 134 bool E_HireEmployee(base_t* base, Employee* employee); 135 bool E_HireEmployeeByType(base_t* base, employeeType_t type); 136 bool E_HireRobot(base_t* base, const struct ugv_s* ugvType); 137 bool E_UnhireEmployee(Employee* employee); 138 139 int E_RefreshUnhiredEmployeeGlobalList(const employeeType_t type, const bool excludeUnhappyNations); 140 141 base_t* E_Unassign(Employee* employee); 142 int E_GenerateHiredEmployeesList(const base_t* base); 143 144 employeeType_t E_GetEmployeeType(const char* type); 145 extern const char* E_GetEmployeeString(employeeType_t type, int n); 146 147 Employee* E_GetUnhired(employeeType_t type); 148 Employee* E_GetUnhiredRobot(const struct ugv_s* ugvType); 149 150 int E_GetHiredEmployees(const base_t* const base, employeeType_t type, linkedList_t** hiredEmployees); 151 Employee* E_GetHiredRobot(const base_t* const base, const struct ugv_s* ugvType); 152 153 Employee* E_GetUnassignedEmployee(const base_t* const base, employeeType_t type); 154 Employee* E_GetAssignedEmployee(const base_t* const base, employeeType_t type); 155 156 Employee* E_GetEmployeeFromChrUCN(int uniqueCharacterNumber); 157 Employee* E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber); 158 159 Employee* E_GetEmployeeByMenuIndex(int num); 160 void E_UnhireAllEmployees(base_t* base, employeeType_t type); 161 void E_DeleteAllEmployees(base_t* base); 162 163 void E_DeleteEmployeesExceedingCapacity(base_t* base); 164 165 void E_HireForBuilding(base_t* base, building_t* building, int num); 166 void E_InitialEmployees(const struct campaign_s* campaign); 167 168 bool E_MoveIntoNewBase(Employee* employee, base_t* newBase); 169 void E_RemoveInventoryFromStorage(Employee* employee); 170 171 void E_InitStartup(void); 172 void E_Shutdown(void); 173