UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_employee.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 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 
30 typedef enum {
38 
40 class Employee {
41 private:
43  bool _assigned;
44  const struct nation_s* _nation;
45  const struct ugv_s* _ugv;
47 public:
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 
52  virtual ~Employee () {
53  }
54 
58  inline bool isAssigned () const {
59  return _assigned;
60  }
61 
62  inline void setAssigned(bool assigned) {
63  _assigned = assigned;
64  }
65 
66  inline bool isPilot () const {
67  return _type == EMPL_PILOT;
68  }
69 
70  inline bool isRobot () const {
71  return _type == EMPL_ROBOT;
72  }
73 
74  inline bool isScientist () const {
75  return _type == EMPL_SCIENTIST;
76  }
77 
78  inline bool isWorker () const {
79  return _type == EMPL_WORKER;
80  }
81 
82  inline bool isSoldier () const {
83  return _type == EMPL_SOLDIER;
84  }
85 
86  inline bool isHired () const {
87  return baseHired != nullptr;
88  }
89 
94  inline bool isHiredInBase (const base_t* const base) const {
95  assert(base != nullptr);
96  return baseHired == base;
97  }
98 
99  inline employeeType_t getType() const {
100  return _type;
101  }
102 
103  inline const struct nation_s* getNation() const {
104  return _nation;
105  }
106 
107  inline const struct ugv_s* getUGV() const {
108  return _ugv;
109  }
110 
111  int salary() const;
112  bool isAwayFromBase() const;
113  bool unassign();
114  bool unhire();
115  void unequip();
116 
118  bool transfer;
120 };
121 
122 #define E_Foreach(employeeType, var) LIST_Foreach(ccs.employees[employeeType], Employee, var)
123 
124 Employee* E_CreateEmployee(employeeType_t type, const struct nation_s* nation, const struct ugv_s* ugvType = nullptr);
125 bool E_DeleteEmployee(Employee* employee);
126 
127 /* count */
129 int E_CountHired(const base_t* const base, employeeType_t type);
130 int E_CountHiredRobotByType(const base_t* const base, const struct ugv_s* ugvType);
131 int E_CountAllHired(const base_t* const base, const bool peopleOnly = false);
133 int E_CountUnhiredRobotsByType(const struct ugv_s* ugvType);
134 int E_CountUnassigned(const base_t* const base, employeeType_t type);
135 
136 bool E_HireEmployee(base_t* base, Employee* employee);
138 bool E_HireRobot(base_t* base, const struct ugv_s* ugvType);
139 bool E_UnhireEmployee(Employee* employee);
140 
142 extern const char* E_GetEmployeeString(employeeType_t type, int n);
143 
145 Employee* E_GetUnhiredRobot(const struct ugv_s* ugvType);
146 
147 int E_GetHiredEmployees(const base_t* const base, employeeType_t type, linkedList_t** hiredEmployees);
148 Employee* E_GetHiredRobot(const base_t* const base, const struct ugv_s* ugvType);
149 
152 
153 Employee* E_GetEmployeeFromChrUCN(int uniqueCharacterNumber);
154 Employee* E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber);
155 
157 void E_DeleteAllEmployees(base_t* base);
158 
159 void E_HireForBuilding(base_t* base, building_t* building, int num);
160 void E_InitialEmployees(const struct campaign_s* campaign);
161 
162 bool E_MoveIntoNewBase(Employee* employee, base_t* newBase);
163 void E_RemoveInventoryFromStorage(Employee* employee);
164 
165 void E_InitStartup(void);
166 void E_Shutdown(void);
Employee * E_GetHiredRobot(const base_t *const base, const struct ugv_s *ugvType)
bool isSoldier() const
Definition: cp_employee.h:82
int salary() const
Calculates the employee's actual salary.
Definition: cp_employee.cpp:63
A building with all it's data.
Definition: cp_building.h:73
Nation definition.
Definition: cp_nation.h:44
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
bool isAwayFromBase() const
Tells you if a employee is away from his home base (gone in mission).
Definition: cp_employee.cpp:75
const struct nation_s * _nation
Definition: cp_employee.h:44
int E_CountByType(employeeType_t type)
Returns number of employees of a type.
Definition: cp_employee.cpp:39
const employeeType_t _type
Definition: cp_employee.h:42
bool isWorker() const
Definition: cp_employee.h:78
void E_InitialEmployees(const struct campaign_s *campaign)
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
Employee * E_GetAssignedEmployee(const base_t *const base, employeeType_t type)
Gets an unassigned employee of a given type from the given base.
Defines a type of UGV/Robot.
Definition: chr_shared.h:234
int E_CountHiredRobotByType(const base_t *const base, const struct ugv_s *ugvType)
employeeType_t E_GetEmployeeType(const char *type)
Convert string to employeeType_t.
int E_CountAllHired(const base_t *const base, const bool peopleOnly=false)
Counts all hired employees of a given base.
character_t chr
Definition: cp_employee.h:119
bool isScientist() const
Definition: cp_employee.h:74
void E_UnhireAllEmployees(base_t *base, employeeType_t type)
Reset the hired flag for all employees of a given type in a given base.
const struct ugv_s * getUGV() const
Definition: cp_employee.h:107
int E_CountUnhiredRobotsByType(const struct ugv_s *ugvType)
#define nullptr
Definition: cxx.h:53
employeeType_t getType() const
Definition: cp_employee.h:99
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base...
bool isAssigned() const
Definition: cp_employee.h:58
A base with all it's data.
Definition: cp_base.h:84
Employee * E_CreateEmployee(employeeType_t type, const struct nation_s *nation, const struct ugv_s *ugvType=nullptr)
bool E_HireRobot(base_t *base, const struct ugv_s *ugvType)
const struct ugv_s * _ugv
Definition: cp_employee.h:45
Employee * E_GetUnhiredRobot(const struct ugv_s *ugvType)
Employee * E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber)
Searches employee from a type for the ucn (character id)
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
base_t * baseHired
Definition: cp_employee.h:117
void setAssigned(bool assigned)
Definition: cp_employee.h:62
employeeType_t
The types of employees.
Definition: cp_employee.h:30
bool isRobot() const
Definition: cp_employee.h:70
bool E_HireEmployee(base_t *base, Employee *employee)
Hires the employee in a base.
void E_Shutdown(void)
Closing actions for employee-subsystem.
const struct nation_s * getNation() const
Definition: cp_employee.h:103
Employee(employeeType_t type, const struct nation_s *nation, const struct ugv_s *ugv)
Definition: cp_employee.h:48
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
bool isHired() const
Definition: cp_employee.h:86
Employee * E_GetUnassignedEmployee(const base_t *const base, employeeType_t type)
Gets an assigned employee of a given type from the given base.
bool unassign()
Removes the employee from buildings and aircraft.
bool E_UnhireEmployee(Employee *employee)
void E_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
int E_GetHiredEmployees(const base_t *const base, employeeType_t type, linkedList_t **hiredEmployees)
Return a list of hired employees in the given base of a given type.
bool unhire()
Fires an employee.
bool _assigned
Definition: cp_employee.h:43
int E_CountUnhired(employeeType_t type)
Counts unhired employees of a given type in a given base.
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
int E_CountUnassigned(const base_t *const base, employeeType_t type)
Counts unassigned employees of a given type in a given base.
bool isPilot() const
Definition: cp_employee.h:66
virtual ~Employee()
Definition: cp_employee.h:52
Employee * E_GetUnhired(employeeType_t type)
Iterates through unhired employees.
Definition: cp_employee.cpp:49
void E_RemoveInventoryFromStorage(Employee *employee)
Removes the items of an employee (soldier) from the base storage (s)he is hired at.
bool transfer
Definition: cp_employee.h:118
void unequip()
Removes the equipment from an employee.
bool isHiredInBase(const base_t *const base) const
Checks whether the given employee is in the given base.
Definition: cp_employee.h:94
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
void E_HireForBuilding(base_t *base, building_t *building, int num)
Hires some employees of appropriate type for a building.
Describes a character with all its attributes.
Definition: chr_shared.h:369