#include "StdAfx.h" #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); }