diff options
Diffstat (limited to 'src/Plugins/Food/Common/Trash.cpp')
-rw-r--r-- | src/Plugins/Food/Common/Trash.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/Plugins/Food/Common/Trash.cpp b/src/Plugins/Food/Common/Trash.cpp new file mode 100644 index 0000000..15e7c6c --- /dev/null +++ b/src/Plugins/Food/Common/Trash.cpp @@ -0,0 +1,103 @@ +// actual name unknown +#include "T2EquipPtrList.h" +#include "T2People.h" +#include "T2RegistedTenantDB.h" +#include "T2RouteNavigator.h" +#include "T2Tenant.h" +#include "T2TowerDoc.h" +#include "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->SetRelatedTenant(theList); + } + } + + return theList; +} |