blob: c5f37df84f17f3afefb280702483c6f4efc32037 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#include "T2PeopleArray.h"
#include "T2TowerDoc.h"
T2PeopleArray::T2PeopleArray(unsigned int startID)
: T2ObjectArray(startID)
{
for (unsigned int i = 0; i < kGroupSize; i++)
mPeople[i].mMatterID = mStartID + i;
}
T2People* T2PeopleArray::FindPeople(unsigned int peopleID) {
unsigned int firstID = mPeople[0].GetPeopleID();
if (firstID > peopleID || (firstID + kGroupSize) < peopleID)
return NULL;
for (int i = 0; i < kGroupSize; i++) {
if (mPeople[i].GetPeopleID() == peopleID)
return &mPeople[i];
}
return NULL;
}
void T2PeopleArray::ResolveLink(T2PeopleArrayList* list) {
for (int i = 0; i < kGroupSize; i++) {
if (mPeople[i].IsUsed())
mPeople[i].ResolveLink(list);
}
}
T2People* T2PeopleArray::FindUnusedPeople() {
T2People *result = NULL;
for (unsigned int i = 0; i < kGroupSize; i++) {
if (!mPeople[i].IsUsed()) {
result = &mPeople[i];
break;
}
}
return result;
}
/*virtual*/ void T2PeopleArray::DispatchIdle(T2TowerDoc* towerDoc, int startIndex) {
int i;
T2People *thePeople;
thePeople = &mPeople[startIndex];
for (i = startIndex; i < kGroupSize; i += 8) {
if (thePeople->mUsed)
thePeople->Idle(towerDoc);
thePeople += 8;
}
thePeople = mPeople;
int theWalkRate = towerDoc->GetWalkRate();
for (i = 0; i < kGroupSize; i++) {
if (thePeople->mUsed) {
if ((theWalkRate > 0 && !(i % theWalkRate)) || thePeople->IsSetSpecialFlag(kSpecialFlag20))
thePeople->IdleSearchedPerson(towerDoc);
}
thePeople++;
}
}
void T2PeopleArray::DrawSearchedPerson(T2TowerDoc* towerDoc) {
T2People *people = mPeople;
for (int i = 0; i < kGroupSize; i++) {
if (people->mUsed && people->IsWalk())
people->DrawSearchedPerson(towerDoc);
people++;
}
}
void T2PeopleArray::SetWalkPeople(int v) {
for (int i = 0; i < kGroupSize; i++)
mPeople[i].SetWalk(false);
if (v != -1) {
for (int i = 0; i < kGroupSize; i += v)
mPeople[i].SetWalk(true);
}
}
void T2PeopleArray::DayChanged() {
for (int i = 0; i < kGroupSize; i++) {
if (mPeople[i].IsUsed())
mPeople[i].DayChanged();
}
}
void T2PeopleArray::TenantRemoved(unsigned int v) {
for (int i = 0; i < kGroupSize; i++) {
if (mPeople[i].IsUsed())
mPeople[i].TenantRemoved(v);
}
}
void T2PeopleArray::AddStress(int v) {
for (int i = 0; i < kGroupSize; i++) {
if (mPeople[i].IsUsed())
mPeople[i].IncStress(v);
}
}
void T2PeopleArray::BreakoutEmergency(T2TowerDoc* towerDoc) {
for (int i = 0; i < kGroupSize; i++) {
T2People *people = &mPeople[i];
if (people->IsUsed())
people->BreakoutEmergency(towerDoc);
}
}
void T2PeopleArray::Read(T2Archive& archive, T2TowerDoc* towerDoc) {
for (int i = 0; i < kGroupSize; i++)
mPeople[i].Load(archive, towerDoc);
}
void T2PeopleArray::Write(T2Archive& archive) {
for (int i = 0; i < kGroupSize; i++)
mPeople[i].Save(archive);
}
|