UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_employee.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23*/
24
25#pragma once
26
38
40class Employee {
41private:
43 bool _assigned;
44 const struct nation_s* _nation;
45 const struct ugv_s* _ugv;
46
47public:
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
124Employee* E_CreateEmployee(employeeType_t type, const struct nation_s* nation, const struct ugv_s* ugvType = nullptr);
125bool E_DeleteEmployee(Employee* employee);
126
127/* count */
129int E_CountHired(const base_t* const base, employeeType_t type);
130int E_CountHiredRobotByType(const base_t* const base, const struct ugv_s* ugvType);
131int E_CountAllHired(const base_t* const base, const bool peopleOnly = false);
133int E_CountUnhiredRobotsByType(const struct ugv_s* ugvType);
134int E_CountUnassigned(const base_t* const base, employeeType_t type);
135
136bool E_HireEmployee(base_t* base, Employee* employee);
138bool E_HireRobot(base_t* base, const struct ugv_s* ugvType);
140
142extern const char* E_GetEmployeeString(employeeType_t type, int n);
143
145Employee* E_GetUnhiredRobot(const struct ugv_s* ugvType);
146
147int E_GetHiredEmployees(const base_t* const base, employeeType_t type, linkedList_t** hiredEmployees);
148Employee* E_GetHiredRobot(const base_t* const base, const struct ugv_s* ugvType);
149
152
153Employee* E_GetEmployeeFromChrUCN(int uniqueCharacterNumber);
154Employee* E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber);
155
157void E_DeleteAllEmployees(base_t* base);
158
159void E_HireForBuilding(base_t* base, building_t* building, int num);
160void E_InitialEmployees(const struct campaign_s* campaign);
161
162bool E_MoveIntoNewBase(Employee* employee, base_t* newBase);
164
165void E_InitStartup(void);
166void E_Shutdown(void);
bool isHiredInBase(const base_t *const base) const
Checks whether the given employee is in the given base.
Definition cp_employee.h:94
character_t chr
bool isAwayFromBase() const
Tells you if a employee is away from his home base (gone in mission).
bool isRobot() const
Definition cp_employee.h:70
const struct ugv_s * _ugv
Definition cp_employee.h:45
const employeeType_t _type
Definition cp_employee.h:42
bool unassign()
Removes the employee from buildings and aircraft.
int salary() const
Calculates the employee's actual salary.
virtual ~Employee()
Definition cp_employee.h:52
employeeType_t getType() const
Definition cp_employee.h:99
bool _assigned
Definition cp_employee.h:43
void setAssigned(bool assigned)
Definition cp_employee.h:62
bool transfer
bool isWorker() const
Definition cp_employee.h:78
bool isAssigned() const
Definition cp_employee.h:58
bool isScientist() const
Definition cp_employee.h:74
base_t * baseHired
bool isHired() const
Definition cp_employee.h:86
const struct ugv_s * getUGV() const
Employee(employeeType_t type, const struct nation_s *nation, const struct ugv_s *ugv)
Definition cp_employee.h:48
const struct nation_s * getNation() const
bool unhire()
Fires an employee.
bool isSoldier() const
Definition cp_employee.h:82
const struct nation_s * _nation
Definition cp_employee.h:44
void unequip()
Removes the equipment from an employee.
bool isPilot() const
Definition cp_employee.h:66
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id).
int E_CountAllHired(const base_t *const base, const bool peopleOnly=false)
Counts all hired employees of a given base.
Employee * E_GetHiredRobot(const base_t *const base, const struct ugv_s *ugvType)
Employee * E_GetUnassignedEmployee(const base_t *const base, employeeType_t type)
Gets an assigned employee of a given type from the given base.
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
int E_CountByType(employeeType_t type)
Returns number of employees of a type.
int E_CountHiredRobotByType(const base_t *const base, const struct ugv_s *ugvType)
void E_UnhireAllEmployees(base_t *base, employeeType_t type)
Reset the hired flag for all employees of a given type in a given base.
bool E_HireRobot(base_t *base, const struct ugv_s *ugvType)
Employee * E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber)
Searches employee from a type 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.
void E_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
void E_InitialEmployees(const struct campaign_s *campaign)
void E_Shutdown(void)
Closing actions for employee-subsystem.
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base.
void E_RemoveInventoryFromStorage(Employee *employee)
Removes the items of an employee (soldier) from the base storage (s)he is hired at.
employeeType_t
The types of employees.
Definition cp_employee.h:30
@ EMPL_SOLDIER
Definition cp_employee.h:31
@ MAX_EMPL
Definition cp_employee.h:36
@ EMPL_ROBOT
Definition cp_employee.h:35
@ EMPL_PILOT
Definition cp_employee.h:34
@ EMPL_WORKER
Definition cp_employee.h:33
@ EMPL_SCIENTIST
Definition cp_employee.h:32
Employee * E_GetUnhiredRobot(const struct ugv_s *ugvType)
Employee * E_CreateEmployee(employeeType_t type, const struct nation_s *nation, const struct ugv_s *ugvType=nullptr)
int E_CountUnhiredRobotsByType(const struct ugv_s *ugvType)
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
employeeType_t E_GetEmployeeType(const char *type)
Convert string to employeeType_t.
bool E_HireEmployee(base_t *base, Employee *employee)
Hires the employee in a base.
int E_CountUnhired(employeeType_t type)
Counts unhired 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.
Employee * E_GetAssignedEmployee(const base_t *const base, employeeType_t type)
Gets an unassigned employee of a given type from the given base.
Employee * E_GetUnhired(employeeType_t type)
Iterates through unhired employees.
int E_CountUnassigned(const base_t *const base, employeeType_t type)
Counts unassigned employees of a given type in a given base.
bool E_UnhireEmployee(Employee *employee)
#define nullptr
Definition cxx.h:53
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
A base with all it's data.
Definition cp_base.h:84
A building with all it's data.
Definition cp_building.h:73
Describes a character with all its attributes.
Definition chr_shared.h:388