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
|
// actual name unknown
#include "StdAfx.h"
#include "../../../T2DLL/T2EquipPtrList.h"
#include "../../../T2DLL/T2People.h"
#include "../../../T2DLL/T2RegistedTenantDB.h"
#include "../../../T2DLL/T2RouteNavigator.h"
#include "../../../T2DLL/T2Tenant.h"
#include "../../../T2TowerDoc.h"
#include "../../../T2DLL/T2TowerMessage.h"
#include "Trash.h"
void TakeOutTrash(T2TowerDoc *inDoc, T2Tenant *inTenant, unsigned int inTime) {
unsigned int numBelong = inTenant->GetBelongCapacity();
for (unsigned int i = 1; inTenant->GetWorkCount() > 0 && i <= numBelong; i++) {
T2People *thePeople = inTenant->GetBelongPeopleIn(i);
if (thePeople) {
T2Tenant *theFacility = SelectTrashFacility(inDoc, inTenant, thePeople);
if (theFacility) {
inTenant->DecWorkCount();
thePeople->ChangeStyle(kPeopleStyle2);
thePeople->SetDestination(theFacility->GetEquipID(), inTime);
thePeople->SetReturn(inTenant->GetEquipID(), inTime);
theFacility->IncReserveCount(1);
} else {
break;
}
}
}
}
T2Tenant *SelectTrashFacility(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople) {
BOOL isConnectedRoute = false;
BOOL isFacilityBuildFinish = false;
BOOL isFacilityRegisted = false;
T2Tenant *theTrashFacility = NULL;
T2EquipPtrList *theTrashFacilityList = GetTrashFacilities(inDoc, inTenant);
if (theTrashFacilityList && theTrashFacilityList->GetCount() > 0) {
T2RouteNavigator *theNavi = inDoc->GetRouteNavi();
if (theNavi) {
POINT exitPt = inTenant->GetExitPt();
LArrayIterator iterator(*theTrashFacilityList);
T2Tenant *tenant;
while (!theTrashFacility && iterator.Next(&tenant)) {
if (tenant->IsBuildFinish()) {
POINT entrancePt = tenant->GetEntrancePt();
if (theNavi->CheckRoute(exitPt, entrancePt, 1000, kRouteType1)) {
if ((tenant->GetTotalCustomer() + tenant->GetReserveCount()) < tenant->GetCapacity())
theTrashFacility = tenant;
isConnectedRoute = true;
}
isFacilityBuildFinish = true;
}
}
}
isFacilityRegisted = true;
}
if (!theTrashFacility) {
if (isConnectedRoute) {
inDoc->GetTowerMessage()->PassiveInfoBarMessage(
// We need to expand the garbage collection area.
// "ゴミ回収場の拡張が必要です。"
"\x83\x53\x83\x7E\x89\xF1\x8E\xFB\x8F\xEA\x82\xCC\x8A\x67\x92\xA3\x82\xAA\x95\x4B\x97\x76\x82\xC5\x82\xB7\x81\x42",
180);
} else if (isFacilityBuildFinish) {
inDoc->GetTowerMessage()->PeopleBalloonMessage(
// Where is the garbage collection point?
// "ゴミ回収場はどこにあるのかな?"
"\x83\x53\x83\x7E\x89\xF1\x8E\xFB\x8F\xEA\x82\xCD\x82\xC7\x82\xB1\x82\xC9\x82\xA0\x82\xE9\x82\xCC\x82\xA9\x82\xC8\x81\x48",
inPeople);
} else if (!isFacilityRegisted) {
inDoc->GetTowerMessage()->PassiveInfoBarMessage(
// A garbage collection point is required in the building.
// "ビル内にゴミ回収場が必要です。"
"\x83\x72\x83\x8B\x93\xE0\x82\xC9\x83\x53\x83\x7E\x89\xF1\x8E\xFB\x8F\xEA\x82\xAA\x95\x4B\x97\x76\x82\xC5\x82\xB7\x81\x42",
180);
}
}
return theTrashFacility;
}
T2EquipPtrList *GetTrashFacilities(T2TowerDoc *inDoc, T2Tenant *inTenant) {
T2EquipPtrList *theList = inTenant->GetRelatedTenantList();
if (!theList) {
T2RegistedTenantDB *theDB = inDoc->GetRegistedTenantDB();
if (theDB) {
theList = theDB->GetList(kTenantRegistID2);
inTenant->SetRelatedTenantList(theList);
}
}
return theList;
}
|