diff options
Diffstat (limited to 'src/Plugins/Food/Common')
| -rw-r--r-- | src/Plugins/Food/Common/FoodDef.cpp | 291 | ||||
| -rw-r--r-- | src/Plugins/Food/Common/FoodDef.h | 14 | ||||
| -rw-r--r-- | src/Plugins/Food/Common/FoodPlugin.cpp | 8 | ||||
| -rw-r--r-- | src/Plugins/Food/Common/FoodPlugin.h | 6 | ||||
| -rw-r--r-- | src/Plugins/Food/Common/Trash.cpp | 103 | ||||
| -rw-r--r-- | src/Plugins/Food/Common/Trash.h | 6 | 
6 files changed, 426 insertions, 2 deletions
| diff --git a/src/Plugins/Food/Common/FoodDef.cpp b/src/Plugins/Food/Common/FoodDef.cpp index 821a063..dfc84ad 100644 --- a/src/Plugins/Food/Common/FoodDef.cpp +++ b/src/Plugins/Food/Common/FoodDef.cpp @@ -1,7 +1,298 @@  #include "FoodDef.h" +#include "../../Common/StdFoodInfoDialog.h" +#include "Trash.h" +#include "T2DateTime.h" +#include "T2People.h" +#include "T2SoundPlayer.h" +#include "T2TemplatePluginList.h" +#include "T2Tenant.h" +#include "T2TowerDoc.h" +#include "T2TowerMainView.h" +#include "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); +} diff --git a/src/Plugins/Food/Common/FoodDef.h b/src/Plugins/Food/Common/FoodDef.h index 93bbe62..f425270 100644 --- a/src/Plugins/Food/Common/FoodDef.h +++ b/src/Plugins/Food/Common/FoodDef.h @@ -1,5 +1,17 @@  #pragma once  #include "common.h" +#include "T2TenantDef.h" -class FoodDef { +class FoodDef : public T2TenantDef { +public: +    FoodDef(DWORD inType, T2PluginSpecifier &inSpecifier, CResFile *inResFile, T2WorldDef *inWorldDef, T2TenantPlugin *inPlugin); +    virtual ~FoodDef(); + +    virtual void LoadSound(T2TowerDoc *inDoc); +    virtual BOOL ChangeStatusOnIdle(T2TowerDoc *inDoc, T2Tenant *inTenant, int inStatus); +    virtual void EnterTenant(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople); +    virtual void LeaveTenant(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople); +    virtual int EmergencyProc(T2TowerDoc *inDoc, T2Equip *inEquip); +    virtual void UnkVF(T2TowerDoc *inDoc, T2Tenant *inTenant); +    virtual T2InfoDialog *ConstructInfoDialog(T2Equip *inEquip);  }; diff --git a/src/Plugins/Food/Common/FoodPlugin.cpp b/src/Plugins/Food/Common/FoodPlugin.cpp index 2b5d041..22e72fe 100644 --- a/src/Plugins/Food/Common/FoodPlugin.cpp +++ b/src/Plugins/Food/Common/FoodPlugin.cpp @@ -5,3 +5,11 @@  #undef THIS_FILE  static char THIS_FILE[] = __FILE__;  #endif + +FoodPlugin::FoodPlugin(DWORD inType, T2PluginSpecifier &inSpecifier) +    : T2TenantPlugin(inType, inSpecifier) +{ +} + +/*virtual*/ FoodPlugin::~FoodPlugin() { +} diff --git a/src/Plugins/Food/Common/FoodPlugin.h b/src/Plugins/Food/Common/FoodPlugin.h index 157d64c..5cd0a5a 100644 --- a/src/Plugins/Food/Common/FoodPlugin.h +++ b/src/Plugins/Food/Common/FoodPlugin.h @@ -1,5 +1,9 @@  #pragma once  #include "common.h" +#include "T2TenantPlugin.h" -class FoodPlugin { +class FoodPlugin : public T2TenantPlugin { +public: +    FoodPlugin(DWORD inType, T2PluginSpecifier &inSpecifier); +    virtual ~FoodPlugin();  }; 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; +} diff --git a/src/Plugins/Food/Common/Trash.h b/src/Plugins/Food/Common/Trash.h new file mode 100644 index 0000000..59b7fdd --- /dev/null +++ b/src/Plugins/Food/Common/Trash.h @@ -0,0 +1,6 @@ +#pragma once +#include "common.h" + +void TakeOutTrash(T2TowerDoc *inDoc, T2Tenant *inTenant, unsigned int inTime); +T2Tenant *SelectTrashFacility(T2TowerDoc *inDoc, T2Tenant *inTenant, T2People *inPeople); +T2EquipPtrList *GetTrashFacilities(T2TowerDoc *inDoc, T2Tenant *inTenant); | 
