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
|
#include "CFilePluginList.h"
#include "CProgramPlugin.h"
#include "CResFile.h"
#include "T2Archive.h"
#include "T2BlackOut.h"
#include "T2DateTime.h"
#include "T2MainWindow.h"
#include "T2PeopleArrayList.h"
#include "T2TemplatePlugin.h"
#include "T2ToolWindow.h"
#include "T2TowerDoc.h"
#include "T2TowerEvent.h"
#include "T2TowerMainView.h"
#include "T2TowerMessage.h"
T2BlackOut::T2BlackOut(T2TowerEvent* inTowerEvent, CResFile* inResFile, int inSubID)
: T2EventItem(inTowerEvent, inResFile, inSubID)
{
*inResFile >> mDefSupply;
*inResFile >> mAddSupply;
*inResFile >> mTransforPrice;
mConsumptionPower = 0;
mSupplyPower = mDefSupply;
m44 = 0;
m48 = 0;
mAttach = NULL;
}
/*virtual*/ T2BlackOut::~T2BlackOut() {
}
static int anims[] = {2, 8400, 8401};
/*virtual*/ BOOL T2BlackOut::Start(T2TowerDoc* inDoc) {
mStatus = kBlackOutStatus0;
if (mConsumptionPower > mSupplyPower) {
mStatus = kBlackOutStatus1;
T2TowerMainView *theView = inDoc->GetMainView();
if (theView) {
inDoc->towerDoc_vf284();
mAttach = new T2BlackOutAttach(this, 0, true);
theView->AddAttachment(mAttach, NULL, true);
}
// "停電です\r\n" - Blackout
CString text = "\x92\xE2\x93\x64\x82\xC5\x82\xB7\r\n";
if (mSupplyPower == mDefSupply) {
// "ビル内の電力供給がこのままでは間に合いません。"
// The power supply in the building will not be in time as it is.
text += "\x83\x72\x83\x8B\x93\xE0\x82\xCC\x93\x64\x97\xCD\x8B\x9F\x8B\x8B\x82\xAA\x82\xB1\x82\xCC\x82\xDC\x82\xDC\x82\xC5\x82\xCD\x8A\xD4\x82\xC9\x8D\x87\x82\xA2\x82\xDC\x82\xB9\x82\xF1\x81\x42";
// "至急変電室を設置"
// Set up an emergency substation room
text += "\x8E\x8A\x8B\x7D\x95\xCF\x93\x64\x8E\xBA\x82\xF0\x90\xDD\x92\x75";
} else {
// "変電室にあるブレーカーを全てオンにすれば一時的に停電は回復しますが、"
// If you turn on all the breakers in the substation room, the power
// outage will be restored temporarily,
text += "\x95\xCF\x93\x64\x8E\xBA\x82\xC9\x82\xA0\x82\xE9\x83\x75\x83\x8C\x81\x5B\x83\x4A\x81\x5B\x82\xF0\x91\x53\x82\xC4\x83\x49\x83\x93\x82\xC9\x82\xB7\x82\xEA\x82\xCE\x88\xEA\x8E\x9E\x93\x49\x82\xC9\x92\xE2\x93\x64\x82\xCD\x89\xF1\x95\x9C\x82\xB5\x82\xDC\x82\xB7\x82\xAA\x81\x41";
// "変圧器を増設"
// Add a transformer
text += "\x95\xCF\x88\xB3\x8A\xED\x82\xF0\x91\x9D\x90\xDD";
}
// "するかテナントを撤去する等の対処が必要です。"
// It is necessary to take measures such as removing the tenant
// or removing the tenant.
text += "\x82\xB7\x82\xE9\x82\xA9\x83\x65\x83\x69\x83\x93\x83\x67\x82\xF0\x93\x50\x8B\x8E\x82\xB7\x82\xE9\x93\x99\x82\xCC\x91\xCE\x8F\x88\x82\xAA\x95\x4B\x97\x76\x82\xC5\x82\xB7\x81\x42";
DoDialog(inDoc, 8400, 8400, 2, text);
inDoc->mPeopleArrayList->AddStress(30);
}
return (mStatus != kBlackOutStatus0);
}
/*virtual*/ int T2BlackOut::Exec(T2TowerDoc* inDoc) {
int resultCode = IsExclusive() ? 1 : 0;
T2DateTime *theNow = inDoc->GetNow();
unsigned int theNowMinutes = theNow->GetRawMinutes();
T2TowerMainView *theMainView;
T2TowerMessage *theTowerMsg;
if (m44 != theNowMinutes) {
switch (mStatus) {
case kBlackOutStatus1:
if (theNowMinutes == mEndTime)
mStatus = kBlackOutStatus2;
case kBlackOutStatus3:
if (mConsumptionPower < mSupplyPower)
mStatus = kBlackOutStatus4;
break;
case kBlackOutStatus2:
inDoc->towerDoc_vf284();
theTowerMsg = inDoc->mTowerMessage;
if (theTowerMsg) {
// "住人は全て非常階段で避難しました。エレーベーターに閉じ込められた人も救出されました。"
// All residents evacuated using emergency stairs.
// People trapped in elevators were also rescued.
CString text = "\x8F\x5A\x90\x6C\x82\xCD\x91\x53\x82\xC4\x94\xF1\x8F\xED\x8A\x4B\x92\x69\x82\xC5\x94\xF0\x93\xEF\x82\xB5\x82\xDC\x82\xB5\x82\xBD\x81\x42\x83\x47\x83\x8C\x81\x5B\x83\x78\x81\x5B\x83\x5E\x81\x5B\x82\xC9\x95\xC2\x82\xB6\x8D\x9E\x82\xDF\x82\xE7\x82\xEA\x82\xBD\x90\x6C\x82\xE0\x8B\x7E\x8F\x6F\x82\xB3\x82\xEA\x82\xDC\x82\xB5\x82\xBD\x81\x42";
theTowerMsg->AleatMessage(text, kAlertType1);
}
inDoc->mPeopleArrayList->AddStress(300);
mStatus = kBlackOutStatus3;
break;
case kBlackOutStatus4:
mStatus = kBlackOutStatus0;
theMainView = inDoc->GetMainView();
if (theMainView) {
inDoc->towerDoc_vf284();
if (mAttach) {
theMainView->RemoveAttachment(mAttach);
delete mAttach;
mAttach = NULL;
}
}
resultCode = 3;
break;
}
m44 = theNowMinutes;
}
return resultCode;
}
void T2BlackOut::AddConsumptionPower(int inPower) {
mConsumptionPower += inPower;
T2TowerDoc *theDoc;
int shortfall = mSupplyPower - mConsumptionPower - 50;
if (shortfall < 0) {
// "電力が不足しています。至急" - Insufficient power. Urgent
CString text = "\x93\x64\x97\xCD\x82\xAA\x95\x73\x91\xAB\x82\xB5\x82\xC4\x82\xA2\x82\xDC\x82\xB7\x81\x42\x8E\x8A\x8B\x7D";
theDoc = mTowerEvent->mDocument;
T2TowerMessage *theTowerMsg = theDoc ? theDoc->mTowerMessage : NULL;
if (mSupplyPower > mDefSupply) {
// "変圧器を増設" - Add a transformer
text += "\x95\xCF\x88\xB3\x8A\xED\x82\xF0\x91\x9D\x90\xDD";
} else {
CFilePlugin *plugin = theDoc->mTenantPlugins->GetItem('HEND');
if (plugin) {
// "変電室を設置" - Install substation room
text += "\x95\xCF\x93\x64\x8E\xBA\x82\xF0\x90\xDD\x92\x75";
} else {
// "不要なテナントを撤去" - Remove unnecessary tenants
text += "\x95\x73\x97\x76\x82\xC8\x83\x65\x83\x69\x83\x93\x83\x67\x82\xF0\x93\x50\x8B\x8E";
}
}
// "してください。" - please.
text += "\x82\xB5\x82\xC4\x82\xAD\x82\xBE\x82\xB3\x82\xA2\x81\x42";
if (theTowerMsg && (m48 + 360) < GetTickCount()) {
theTowerMsg->InfoBarMessage(text, 360, NULL);
m48 = GetTickCount();
}
}
}
void T2BlackOut::SubConsumptionPower(int inPower) {
mConsumptionPower -= inPower;
}
void T2BlackOut::AddSupplyPower(int inPower) {
mSupplyPower = mDefSupply + mAddSupply * inPower;
}
void T2BlackOut::SubSupplyPower() {
mSupplyPower = mDefSupply;
}
void T2BlackOut::BreakerOn() {
if (mStatus != kBlackOutStatus0)
mStatus = kBlackOutStatus4;
}
int T2BlackOut::GetConsumptionPower() {
return mConsumptionPower;
}
int T2BlackOut::GetSupplyPower() {
return mSupplyPower;
}
int T2BlackOut::GetDefSupply() {
return mDefSupply;
}
int T2BlackOut::GetAddSupply() {
return mAddSupply;
}
int T2BlackOut::GetTransforPrice() {
return mTransforPrice;
}
/*virtual*/ void T2BlackOut::Write(T2Archive& inArchive) {
unsigned int len = 6;
inArchive << len;
inArchive << (short) mStatus;
inArchive << (short) mConsumptionPower;
inArchive << (short) mSupplyPower;
}
/*virtual*/ void T2BlackOut::Read(T2Archive& inArchive) {
unsigned int len;
inArchive >> len;
short v;
inArchive >> v;
mStatus = v;
inArchive >> v;
mConsumptionPower = v;
inArchive >> v;
mSupplyPower = v;
}
T2BlackOutAttach::T2BlackOutAttach(T2BlackOut *inBlackOut, unsigned int inMessage, BOOL inExecuteHost)
: LAttachment(inMessage, inExecuteHost)
{
mBlackOut = inBlackOut;
}
T2BlackOutAttach::~T2BlackOutAttach() {
}
void T2BlackOutAttach::ExecuteSelf(unsigned int inMessage, void *ioData) {
BOOL newExecuteHost = true;
if (inMessage == WM_LBUTTONDOWN) {
int sel = T2_MAIN_WINDOW->mToolWindow->GetSel();
CString *theToolName = T2_MAIN_WINDOW->mToolWindow->GetIconName(sel);
T2TemplatePlugin *theDef = T2_MAIN_WINDOW->mToolWindow->GetIconPlugin(sel);
CProgramPlugin *thePlugin = theDef->GetPlugin();
unsigned int theValiation = T2_MAIN_WINDOW->mToolWindow->GetIconValiation(sel);
DWORD theOption = T2_MAIN_WINDOW->mToolWindow->GetIconOption(sel);
if (theOption == kToolOption0)
newExecuteHost = true;
else
newExecuteHost = (thePlugin && thePlugin->GetID() == 'HEND');
}
SetExecuteHost(newExecuteHost);
}
|