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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
#include "StdAfx.h"
#include "FoodDef.h"
#include "../../Common/StdFoodInfoDialog.h"
#include "Trash.h"
#include "../../../T2DLL/T2DateTime.h"
#include "../../../T2DLL/T2People.h"
#include "../../../T2DLL/T2SoundPlayer.h"
#include "../../../T2DLL/T2TemplatePluginList.h"
#include "../../../T2DLL/T2Tenant.h"
#include "../../../T2TowerDoc.h"
#include "../../../T2TowerMainView.h"
#include "../../../T2DLL/UT2Utils.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
FoodDef::FoodDef(DWORD inType, T2PluginSpecifier &inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin)
: T2TenantDef(inType, inSpecifier, inResFile, inWorldDef, inPlugin)
{
}
/*virtual*/ FoodDef::~FoodDef() {
}
/*virtual*/ void FoodDef::LoadSound(T2TowerDoc *inDoc) {
inDoc->mSoundPlayer->AddSound(CalcSoundID(1000), SoundPriority_3, 165, mModuleHandle);
}
/*virtual*/ BOOL FoodDef::ChangeStatusOnIdle(T2TowerDoc *inDoc, T2Tenant *inTenant, int inStatus) {
BOOL isChange = false;
T2DateTime *theNow = inDoc->GetNow();
if (inTenant->IsOpen()) {
unsigned int closeTime = inTenant->GetCloseTime();
if (!theNow->WithinMinutes(closeTime, closeTime + 8)) {
inTenant->CollectCustomer(inDoc);
if (inTenant->SetPeopleAnime())
isChange = true;
if (theNow->GetMinutes() < 8) {
BOOL estimateChanged = inTenant->UpdateCommercialEstimate();
isChange |= (inDoc->GetViewMode() == kEvalView) && estimateChanged;
}
if (UT2Utils::Randomize(7) == 0)
inTenant->PlaySound(inDoc, 1000, SoundMask_2, SoundFlags_1);
} else {
if (inDoc->IsDustOn())
inTenant->IncWorkCount();
inDoc->DoPayTool(
-inTenant->CalcInMoney(),
kFundGroup3,
inTenant->GetEquipDef(),
// I got money from the restaurant.
// "レストランの売上金が入りました。"
"\x83\x8C\x83\x58\x83\x67\x83\x89\x83\x93\x82\xCC\x94\x84\x8F\xE3\x8B\xE0\x82\xAA\x93\xFC\x82\xE8\x82\xDC\x82\xB5\x82\xBD\x81\x42",
kTimeLimitLength30Min,
kTimeLimitTypeCategory);
if (inTenant->GetOpenTime() != closeTime) {
inTenant->PushOutAllCustomer(inDoc);
inTenant->SetStatus(kTenantStatus15);
inTenant->SetPatIndex(0);
inTenant->SetAllPeopleToSleep();
isChange = true;
} else {
inTenant->ClearTotalCustomer();
TakeOutTrash(inDoc, inTenant, theNow->GetRawMinutes());
if (inTenant->GetWorkCount() > 2) {
inTenant->SetMark(1);
inTenant->PushOutAll(inDoc);
inTenant->SetStatus(kTenantStatus13);
inTenant->SetPatIndex(0);
isChange = true;
}
}
BOOL estimateChanged = inTenant->UpdateCommercialEstimate();
isChange |= (inDoc->GetViewMode() == kEvalView) && estimateChanged;
}
} else {
if (inStatus == kTenantStatus13 || inStatus == kTenantStatus12) {
unsigned int threshold = inTenant->GetOpenTime() - 60;
if (!theNow->WithinMinutes(threshold, threshold + 8)) {
inTenant->PushOutAll(inDoc);
} else {
inTenant->CallBelongPeople(theNow->GetRawMinutes());
inTenant->SetStatus(kTenantStatus14);
inTenant->ClearTotalCustomer();
inTenant->ClearReserveCount();
inTenant->UpdateCommercialEstimate();
isChange = true;
}
} else if (inStatus == kTenantStatus14) {
unsigned int theOpenTime = inTenant->GetOpenTime();
unsigned int theCloseTime = inTenant->GetCloseTime();
if (theNow->WithinMinutes(theOpenTime, theCloseTime)) {
if (inTenant->GetMark() != 1) {
if (inTenant->GetBelongCount() == inTenant->GetBelongCapacity()) {
inTenant->SetStatus(kTenantStatus30);
inTenant->SetPatIndex(1);
inTenant->SetPeopleAnime();
isChange = true;
}
} else {
TakeOutTrash(inDoc, inTenant, theNow->GetRawMinutes());
if (inTenant->GetWorkCount() < 3) {
inTenant->SetMark(-1);
isChange = true;
}
}
} else if (theNow->WithinMinutes(theCloseTime, theCloseTime + 8)) {
inTenant->SetStatus(kTenantStatus13);
}
} else if (inStatus == kTenantStatus15) {
TakeOutTrash(inDoc, inTenant, theNow->GetRawMinutes());
if (inTenant->GetWorkCount() > 2) {
inTenant->SetMark(1);
isChange = true;
}
inTenant->SetStatus(kTenantStatus13);
} else if (inStatus == kTenantStatus11) {
if (theNow->GetRawMinutes() < 8)
inTenant->SetStatus(kTenantStatus12);
} else if (inStatus == kTenantStatus10) {
if (theNow->GetMinutes() < 8 && inTenant->CollectEmployee(inDoc)) {
UnkVF(inDoc, inTenant);
int newStatus;
if (theNow->GetRawMinutes() >= (inTenant->GetOpenTime() - 60))
newStatus = kTenantStatus11;
else
newStatus = kTenantStatus12;
inTenant->SetStatus(newStatus);
}
} else if (inStatus == kTenantStatus9) {
int newStatus;
if (inTenant->GetBelongCapacity() > 0)
newStatus = kTenantStatus10;
else if (theNow->GetRawMinutes() >= inTenant->GetOpenTime())
newStatus = kTenantStatus11;
else
newStatus = kTenantStatus12;
inTenant->SetStatus(newStatus);
inTenant->SetPatIndex(0);
isChange = true;
}
}
return isChange;
}
/*virtual*/ void FoodDef::EnterTenant(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople) {
BOOL changed = false;
if (inTenant->IsBelongPeople(inPeople)) {
if (inPeople->GetStyle() == kPeopleStyle0) {
inPeople->ChangeStyle(kPeopleStyle1);
} else if (inPeople->GetStyle() == kPeopleStyle2) {
inPeople->ChangeStyle(kPeopleStyle1);
inTenant->IncWorkCount();
if (inTenant->GetWorkCount() > 2) {
inTenant->SetMark(1);
changed = true;
}
}
if (!inTenant->IsOpen()) {
inPeople->SetToSleep();
} else {
inTenant->SetPeopleAnime();
changed = true;
}
} else {
T2DateTime *theNow = inDoc->GetNow();
#line 273
_ASSERT(theNow != NULL);
inTenant->EnterCustomer(inPeople, theNow->GetRawMinutes());
int numCustomer = inTenant->GetCustomerCount();
if (numCustomer == 1) {
inTenant->SetStatus(kTenantStatus31);
inTenant->UpdatePatternIndex(2);
changed = true;
} else if (numCustomer == (inTenant->GetCapacity() / 2)) {
inTenant->SetStatus(kTenantStatus32);
inTenant->UpdatePatternIndex(3);
changed = true;
}
}
if (changed) {
inTenant->SetDrawMode(DrawMode1);
T2TowerMainView *theMainView = inDoc->GetMainView();
if (theMainView) {
RECT area;
inTenant->GetEquipArea(area);
theMainView->InvalUnitRect(area);
}
}
}
/*virtual*/ void FoodDef::LeaveTenant(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople) {
BOOL changed = false;
if (inTenant->IsBelongPeople(inPeople)) {
if (inPeople->GetStyle() == kPeopleStyle1)
inPeople->ChangeStyle(kPeopleStyle0);
if (inTenant->IsOpen()) {
inTenant->SetPeopleAnime();
changed = true;
}
} else {
int numCustomer = inTenant->GetCustomerCount();
if (numCustomer == 0) {
inTenant->SetStatus(kTenantStatus30);
inTenant->UpdatePatternIndex(1);
changed = true;
} else if (numCustomer == (inTenant->GetCapacity() / 2 - 1)) {
inTenant->SetStatus(kTenantStatus31);
inTenant->UpdatePatternIndex(2);
changed = true;
}
}
if (changed) {
inTenant->SetDrawMode(DrawMode1);
T2TowerMainView *theMainView = inDoc->GetMainView();
if (theMainView) {
RECT area;
inTenant->GetEquipArea(area);
theMainView->InvalUnitRect(area);
}
}
}
/*virtual*/ int FoodDef::EmergencyProc(T2TowerDoc *inDoc, T2Equip *inEquip) {
T2Tenant *theTenant = (T2Tenant *) inEquip;
theTenant->PushOutAll(inDoc);
theTenant->ClearReserveCount();
if (theTenant->GetStatus() == kTenantStatus14)
theTenant->SetStatus(kTenantStatus13);
if (theTenant->GetOpenTime() == theTenant->GetCloseTime() && theTenant->IsOpen())
theTenant->SetStatus(kTenantStatus13);
return 0;
}
/*virtual*/ void FoodDef::UnkVF(T2TowerDoc *inDoc, T2Tenant *inTenant) {
T2TemplatePluginList *silhouetteTemplates = inDoc->GetSilhouetteTemplates();
if (silhouetteTemplates) {
BOOL done = false;
for (int i = 0; !done; i++) {
T2People *thePeople = inTenant->GetBelongPeople(i);
if (thePeople) {
int theType1, theType2;
if (thePeople->IsMale()) {
theType1 = 1004;
theType2 = 1008;
} else {
theType1 = 1005;
theType2 = 1009;
}
T2SilhouetteDef *theSilhouetteDef = silhouetteTemplates->FindSilhouette(theType1);
thePeople->SetSilhouetteDef(kPeopleStyle1, theSilhouetteDef);
theSilhouetteDef = silhouetteTemplates->FindSilhouette(theType2);
thePeople->SetSilhouetteDef(kPeopleStyle2, theSilhouetteDef);
} else {
done = true;
}
}
}
}
/*virtual*/ T2InfoDialog *FoodDef::ConstructInfoDialog(T2Equip *inEquip) {
return new StdFoodInfoDialog((T2Tenant *) inEquip);
}
|