#include "GlobalFunc.h" #include "T2Archive.h" #include "T2BitImage.h" #include "T2DateTime.h" #include "T2FloorInfo.h" #include "T2ImageObj.h" #include "T2MetroRailway.h" #include "T2Mover.h" #include "T2Name.h" #include "T2NameList.h" #include "T2People.h" #include "T2PeopleArrayList.h" #include "T2PeopleDef.h" #include "T2PeopleInfoDialog.h" #include "T2PeopleType.h" #include "T2Pool.h" #include "T2RegistedTenantDB.h" #include "T2Request.h" #include "T2ReturnStack.h" #include "T2RouteNavigator.h" #include "T2SilhouetteDef.h" #include "T2TemplatePluginList.h" #include "T2Tenant.h" #include "T2TenantDef.h" #include "T2TrafficInfo.h" #include "T2Transport.h" #include "T2TowerDoc.h" #include "T2TowerEvent.h" #include "T2TowerMainView.h" #include "T2TowerMessage.h" #include "T2WordDefArray.h" #include "T2WorldDef.h" #include "UT2Coordinate.h" static T2People *someGlobalPeople; // 100e3e4c T2People::T2People() { Initialize(); mPeopleType = new T2PeopleType; } void T2People::Initialize() { mSpecialFlag = 0; mWalk = false; mAttribute = 0; mStress = 0; m80 = 0; mEstimate = 0; mStatus = kStatus0; mColor = 1; mFiller = 0; mPrevTenantType = 0; mPeopleType = NULL; mStyle = kPeopleStyle0; for (unsigned int i = 0; i < 3; i++) mSilhouetteDef[i] = NULL; } /*virtual*/ T2People::~T2People() { if (mPeopleType) delete mPeopleType; } /*virtual*/ void T2People::SetUsed(BOOL used) { if (!used) { if (IsFavorite()) { GetCurrentT2TowerDoc()->RemoveFavoritePeople(this, true); } else if (IsNamed()) { T2NameList *nameDB = GetCurrentT2TowerDoc()->mNameDB; T2Name *name = nameDB->Search(this, false); if (name) { nameDB->RemoveName(name); delete name; } } } T2Matter::SetUsed(used); } void T2People::Initialize(T2PeopleDef* peopleDef, T2PeopleType* peopleType) { T2Matter::Initialize(peopleDef); mSpecialFlag = 0; mAttribute = peopleDef->GetAttribute(); mStress = 0; m80 = 0; mEstimate = 300; mStatus = kStatus0; mColor = 1; mFiller = 0; mPrevTenantType = 0; *mPeopleType = *peopleType; mStyle = kPeopleStyle0; SetSilhouetteDef(kPeopleStyle0, peopleDef->GetSilhouetteDef()); SetSilhouetteDef(kPeopleStyle1, NULL); SetSilhouetteDef(kPeopleStyle2, NULL); } BOOL T2People::IsMale() const { BOOL result = true; if (mPeopleType) result = mPeopleType->IsMale(); return result; } BOOL T2People::IsGeneral() const { return ( (mHomeTenant == 1 || mHomeTenant == 2) && (mWorkTenant == 1 || mWorkTenant == 2) ); } BOOL T2People::IsSpecialColor() const { return (mColor >= 11); } void T2People::ChangeStyle(int style) { if (style != mStyle && style >= kPeopleStyle0 && style <= kMaxPeopleStyle) { mStyle = style; ChangeSilhouette(); } } int T2People::GetWidth() const { int result = 1; T2SilhouetteDef *silhouetteDef = mSilhouetteDef[mStyle]; if (silhouetteDef) result = silhouetteDef->GetWidth(); return result; } int T2People::GetRouteType() { int theRouteType = kRouteType0; T2SilhouetteDef *silhouetteDef = mSilhouetteDef[mStyle]; if (!IsSetSpecialFlag(kSpecialFlag80)) { T2SilhouetteDef *silhouetteDef = mSilhouetteDef[mStyle]; if (silhouetteDef) theRouteType = silhouetteDef->GetRouteType(); } else { theRouteType = kRouteTypeNeg1; } return theRouteType; } BOOL T2People::CalcWaitPersonArea(T2FloorInfo* floorInfo, RECT& rect) { BOOL ok = false; T2Request *theRequest = floorInfo->GetRequest(mCurrEquipID); if (theRequest) ok = theRequest->CalcPersonArea(this, rect); return ok; } void T2People::CalcWalkingSilhouetteArea(RECT& rect) const { POINT curPosition = GetCurPosition(); rect.top = curPosition.y; rect.left = curPosition.x; rect.bottom = curPosition.y + 1; rect.right = curPosition.x + 2; if (mWalkStyle == 0 && GetWidth() < 2) { if (mDirection == 0) rect.left++; else rect.right--; } } unsigned int T2People::GetCurTenantID() const { unsigned int tenantID = 0; if (mStatus == kStatus11) tenantID = mCurrEquipID; return tenantID; } /*virtual*/ unsigned int T2People::Idle(T2TowerDoc* towerDoc) { unsigned int result = 0; switch (mStatus) { case kStatus1: if (IsStartTime(towerDoc->GetNow()->GetRawMinutes()) && IsSetDestination()) { towerDoc->GetPool()->Leave(this); MoveToTowerEntrance(towerDoc); if (towerDoc->IsToiletFlagOn()) SetSpecialFlag(kSpecialFlag2); } break; case kStatus11: if (IsStartTime(towerDoc->GetNow()->GetRawMinutes())) { T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theCurrTenant = theFloorInfo->GetTenant(mCurrEquipID); if (theCurrTenant) { if (IsSetDestination()) theCurrTenant->LeaveTenant(towerDoc, this); else theCurrTenant->PushOutPeople(towerDoc, this); } } break; case kStatus2: case kStatus3: case kStatus4: SolveNoRoute(towerDoc); break; case kStatus6: IdleWaitMover(towerDoc); break; case kStatus5: { int what; if (someGlobalPeople == this) what = 1; if (!IsWalk()) { if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) { if (!IsRegistRequest(towerDoc)) ChangeStatus(kStatus3); } } break; } case kStatus10: if (!IsWalk()) { if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) { T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = theFloorInfo->GetTenant(mDstTenant); if (theDstTenant) theDstTenant->EnterTenant(towerDoc, this); } } break; case kStatus12: if (!IsWalk()) { if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) GoOutTower(towerDoc); } break; case kStatus13: if (!IsWalk()) { if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) MoveByEStair(towerDoc); } break; case kStatus14: if (!IsWalk()) { if (IsReachDestination(towerDoc->GetFloorInfo()->GetGroundLine() - 1)) ChangeStatus(kStatus15); } break; } return result; } void T2People::IdleWaitMover(T2TowerDoc* towerDoc) { T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); BOOL didChange = IncStress(5); if (mStress >= 300) { T2Request *theRequest = theFloorInfo->GetRequest(mCurrEquipID); theRequest->Leave(this); JumpToDestination(towerDoc); IncEstimate(-50); didChange = false; } if (didChange) { RECT rect; CalcWaitPersonArea(theFloorInfo, rect); towerDoc->GetMainView()->InvalUnitRect(rect, false); } } void T2People::MoveToTowerEntrance(T2TowerDoc* towerDoc) { BOOL success = true; switch (mPeopleType->GetTransportType()) { case kTransportLobbyLeft: case kTransportLobbyRight: MoveToLobby(towerDoc); break; case kTransportParking: success = MoveToParking(towerDoc); break; case kTransportSubway: success = MoveToSubway(towerDoc); break; case kTransportShip: success = MoveToShip(towerDoc); break; } if (!success) { IncEstimate(-100); MoveToLobby(towerDoc); } } void T2People::MoveToLobby(T2TowerDoc* towerDoc) { T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); T2Tenant *lobby = floorInfo->GetTenant(1000); if (lobby) { lobby->Enter(this); RECT rect; lobby->GetEquipArea(rect); mCurPosition.y = rect.bottom - 1; if (mPeopleType->GetTransportType() == kTransportLobbyLeft) { mCurPosition.x = rect.left; mDirection = 0; } else { mCurPosition.x = rect.right - 2; mDirection = 1; } ChangeStatus(kStatus2); } } BOOL T2People::MoveToParking(T2TowerDoc* towerDoc) { BOOL ok = false; T2RegistedTenantDB *registedTenantDB = towerDoc->GetRegistedTenantDB(); if (registedTenantDB) { T2Tenant *parking = NULL; if (!IsGeneral()) parking = registedTenantDB->FindHisParking(this); if (!parking) parking = registedTenantDB->FindEmptyParking(); if (parking) { SetDestinationToReturn(); parking->EnterTenant(towerDoc, this); ok = true; } } return ok; } BOOL T2People::MoveToSubway(T2TowerDoc* towerDoc) { BOOL ok = false; T2TowerEvent *theEvent = towerDoc->mWorldDef->GetTowerEvent(); T2DateTime *theCurrTime = towerDoc->GetNow(); T2Transport *metro = theEvent->GetMetroRailway(); if (metro) { T2Transport *available = metro->GetAvailable(theCurrTime); if (available) { available->Enter(this); ok = true; } } return ok; } BOOL T2People::MoveToShip(T2TowerDoc* towerDoc) { BOOL ok = false; T2TowerEvent *event = towerDoc->mWorldDef->GetTowerEvent(); T2DateTime *now = towerDoc->GetNow(); T2Transport *cruise = event->GetCruise(); if (cruise) { T2Transport *available = cruise->GetAvailable(now); if (available) { available->Enter(this); ok = true; } } return ok; } void T2People::MoveByEStair(T2TowerDoc* towerDoc) { T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); if (floorInfo) { T2Tenant *theCurTenant = floorInfo->GetTenant(mCurrEquipID); T2Tenant *theDstFloor = floorInfo->GetFloor(mCurrDestPos.y, mCurrDestPos.x); if (theCurTenant && theDstFloor) { RECT dstRect; theDstFloor->GetEquipArea(dstRect); if (mCurrDestPos.x == dstRect.left) mDirection = 0; else if (mCurrDestPos.x == (dstRect.right - 2)) mDirection = 1; theCurTenant->Leave(this); theDstFloor->Enter(this); } else { ChangeStatus(kStatus3); } if (IsWalk()) { T2TowerMainView *towerMainView = towerDoc->GetMainView(); if (towerMainView) { RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); towerMainView->InvalUnitRect(rect, false); } } } } void T2People::SolveNoRoute(T2TowerDoc* towerDoc) { BOOL changed = false; int what; if (someGlobalPeople == this) what = 0; if (!FindRoute(towerDoc)) { changed = IncStress(30) && IsWalk(); if (mStress >= 300) { T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (IsWalk()) { // "道がないよ~" - there is no way CString theMessage = "\x93\xB9\x82\xAA\x82\xC8\x82\xA2\x82\xE6\x81\x60"; towerDoc->towerDoc_vf13C()->PeopleBalloonMessage(theMessage, this); RECT theRect; CalcWalkingSilhouetteArea(theRect); theFloorInfo->SetTenantDrawModeByRect(theRect, DrawMode1); towerDoc->GetMainView()->InvalUnitRect(theRect, false); } T2Tenant *theFloor = theFloorInfo->GetTenant(mCurrEquipID); theFloor->Leave(this); JumpToDestination(towerDoc); IncEstimate(-150); } } if (changed) { RECT rect; CalcWalkingSilhouetteArea(rect); towerDoc->GetMainView()->InvalUnitRect(rect, false); } } BOOL T2People::FindRoute(T2TowerDoc* towerDoc) { BOOL ok = false; int status = mStatus; T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); if (theFloorInfo) { mCurrDestPos = theFloorInfo->GetEntrancePt(mDstTenant); if (mCurPosition.y >= 0) { if (mCurrEquipID == theFloorInfo->GetEntranceFloorID(mDstTenant)) { if (mDstTenant == 1 || mDstTenant == 2) status = kStatus12; else if (!IsSetSpecialFlag(kSpecialFlag40)) status = kStatus10; else status = kStatus14; ok = true; } else { int routeType = GetRouteType(); if (towerDoc->GetRouteNavi()->GetNextRoute(mCurPosition, mCurrDestPos, routeType)) { if (routeType >= kRouteType0) status = kStatus5; else status = kStatus13; ok = true; } } } } if (ok) { if (mCurPosition.x < mCurrDestPos.x) mDirection = 0; else mDirection = 1; ChangeStatus(status); T2TrafficInfo *trafficInfo = towerDoc->GetTrafficInfo(); if (trafficInfo) trafficInfo->Pass(mCurPosition, mCurrDestPos, 1); } return ok; } void T2People::JumpToDestination(T2TowerDoc* towerDoc) { T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); POINT theDestPos = theFloorInfo->GetEntrancePt(mDstTenant); mCurPosition = theDestPos; T2Tenant *theFloor = theFloorInfo->GetFloor(mCurPosition.y, mCurPosition.x); theFloor->Enter(this); } void T2People::GoOutTower(T2TowerDoc* towerDoc) { T2Tenant *theFloor = towerDoc->GetFloorInfo()->GetTenant(mCurrEquipID); if (theFloor) theFloor->Leave(this); T2Pool *pool = towerDoc->GetPool(); pool->Enter(this); } void T2People::IdleSearchedPerson(T2TowerDoc* towerDoc) { BOOL changed = false; int varC; if (someGlobalPeople == this) varC = 2; switch (mStatus) { case kStatus5: case kStatus10: case kStatus12: case kStatus13: case kStatus14: if (mDirection != 1) changed = WalkSearchedPersonRight(towerDoc); else changed = WalkSearchedPersonLeft(towerDoc); break; case kStatus2: { T2TowerMainView *theView = towerDoc->GetMainView(); RECT area; CalcWalkingSilhouetteArea(area); theView->InvalUnitRect(area, false); mStatus = kStatus3; break; } } if (changed) { switch (mStatus) { case kStatus5: if (!IsRegistRequest(towerDoc)) ChangeStatus(kStatus4); break; case kStatus10: { T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = floorInfo->GetTenant(mDstTenant); if (theDstTenant) theDstTenant->EnterTenant(towerDoc, this); else ChangeStatus(kStatus4); break; } case kStatus12: GoOutTower(towerDoc); break; case kStatus13: MoveByEStair(towerDoc); break; case kStatus14: ChangeStatus(kStatus15); break; } } } BOOL T2People::WalkSearchedPersonRight(T2TowerDoc* towerDoc) { BOOL ok = false; T2FloorInfo *floorInfo = towerDoc->mFloorInfo; T2TowerMainView *theMainView = towerDoc->GetMainView(); RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); floorInfo->SetTenantDrawModeByRect(rect, DrawMode1); theMainView->InvalUnitRect(rect, false); int theWalkWidth = 2; if ((mCurPosition.x + theWalkWidth) < mCurrDestPos.x) { if (mWalkStyle != 1) ChangeWalkStyle(1); else ChangeWalkStyle(0); } else { theWalkWidth = mCurrDestPos.x - mCurPosition.x; ChangeWalkStyle(0); ok = true; } mCurPosition.x += theWalkWidth; OffsetRect(&rect, theWalkWidth, 0); theMainView->InvalUnitRect(rect, false); if (mCurPosition.y != (floorInfo->GetGroundLine() - 1)) IncStress(theWalkWidth / 4); return ok; } BOOL T2People::WalkSearchedPersonLeft(T2TowerDoc* towerDoc) { BOOL ok = false; T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); T2TowerMainView *theMainView = towerDoc->GetMainView(); RECT rect; SetRect(&rect, mCurPosition.x, mCurPosition.y, mCurPosition.x + 2, mCurPosition.y + 1); floorInfo->SetTenantDrawModeByRect(rect, DrawMode1); theMainView->InvalUnitRect(rect, false); int theWalkWidth = 2; if ((mCurPosition.x - theWalkWidth) > mCurrDestPos.x) { if (mWalkStyle != 1) ChangeWalkStyle(1); else ChangeWalkStyle(0); } else { theWalkWidth = mCurPosition.x - mCurrDestPos.x; ChangeWalkStyle(0); ok = true; } #line 809 _ASSERT(theWalkWidth >= 0); mCurPosition.x -= theWalkWidth; OffsetRect(&rect, -theWalkWidth, 0); theMainView->InvalUnitRect(rect, false); if (mCurPosition.y != (floorInfo->GetGroundLine() - 1)) IncStress(theWalkWidth / 4); return ok; } BOOL T2People::IsReachDestination(int y) { BOOL ok = false; int theWalkWidth = 16; if (mDirection != 1) { if ((mCurPosition.x + theWalkWidth) >= mCurrDestPos.x) { theWalkWidth = mCurrDestPos.x - mCurPosition.x; ok = true; } mCurPosition.x += theWalkWidth; } else { if ((mCurPosition.x - theWalkWidth) <= mCurrDestPos.x) { theWalkWidth = mCurPosition.x - mCurrDestPos.x; ok = true; } mCurPosition.x -= theWalkWidth; } if (mCurPosition.y != y) IncStress(theWalkWidth / 4); return ok; } BOOL T2People::IsRegistRequest(T2TowerDoc* towerDoc) { BOOL done = false; T2FloorInfo *theFloorInfo = towerDoc->mFloorInfo; T2Request *theRequest = theFloorInfo->GetRequest(mCurPosition.y, mCurPosition.x); if (theRequest) done = theRequest->Regist(towerDoc, this); return done; } void T2People::ChangeStatus(int status) { SetStatus(status); ChangeSilhouette(); } void T2People::ChangeSilhouette() { switch (mStatus) { case kStatus7: mWalkStyle = 1; break; case kStatus9: mWalkStyle = 2; break; default: mWalkStyle = 0; } SetSilhouette(); } void T2People::SetSilhouette() { T2SilhouetteDef *silhouetteDef = mSilhouetteDef[mStyle]; if (silhouetteDef) { int var; if (mDirection != -1) var = mDirection; else var = 0; m18 = silhouetteDef->GetSilhouette(var, mWalkStyle); } else { m18 = 0; } } void T2People::ChangeWalkStyle(int style) { mWalkStyle = style; SetSilhouette(); } void T2People::SetAnimePattern(int fillerStart, int fillerRange, int hStart, int hRange) { if (fillerRange > 1) mFiller = fillerStart + rand() % fillerRange; else mFiller = fillerStart; if (hRange > 1) mCurPosition.x = hStart + rand() % hRange; else mCurPosition.x = hStart; } BOOL T2People::StopOnHisWay(T2TenantMemberDef* tenantMemberDef, int econoType, int score, RECT rect, int bindTime, int tenantType, int tenantID, int startTime) { BOOL ok = false; BOOL negScoreFlag = false; if (score < 0) { score *= -1; negScoreFlag = true; } if (mCurPosition.x > (rect.left - score) && mCurPosition.x < (rect.right + score)) { if (negScoreFlag || CalcFreeTime(startTime) > bindTime) { if (mPrevTenantType != tenantType) { if (mPeopleType->CheckWithDemand(tenantMemberDef, econoType)) { if (SetDestinationToReturn()) { SetDestination(tenantID, startTime); ChangeStatus(kStatus3); ok = true; } } } } } return ok; } BOOL T2People::CalledInTenant(T2TenantMemberDef* tenantMemberDef, int econoType, int bindTime, int tenantType, unsigned int tenantID, unsigned int startTime) { BOOL ok = false; if (CalcFreeTime(startTime) > bindTime && mPrevTenantType != tenantType) { #line 992 _ASSERT(mPeopleType); if (mPeopleType->CheckWithDemand(tenantMemberDef, econoType)) { SetDestination(tenantID, startTime); ok = true; } } return ok; } int T2People::CalcFreeTime(unsigned int time) { int result = 0; if (IsSetDestination()) { if (mStartTime > (int) time) result = mStartTime - time; } else if (IsSetReturn()) { if (GetReturnTime() > time) result = GetReturnTime() - time; } else { result = 10000; } return result; } BOOL T2People::IsGoToPool() const { return mDstTenant <= 2 && mDstTenant >= 1; } void T2People::Return() { if (!SetReturnToDestination()) SetDestination(mHomeTenant); if (mStatus == kStatus10) ChangeStatus(kStatus3); } void T2People::SetDestinationToOutOfTower(T2TowerDoc* towerDoc) { unsigned int tenantID = 1; switch (mPeopleType->GetTransportType()) { case kTransportParking: { T2RegistedTenantDB *registedTenantDB = towerDoc->GetRegistedTenantDB(); if (registedTenantDB) { T2Tenant *parking = NULL; if (!IsGeneral()) { parking = registedTenantDB->FindHisParking(this); if (parking) tenantID = parking->GetEquipID(); } } } } SetDestination(tenantID); } void T2People::ChangeDestination(unsigned int tenant, unsigned int startTime) { if (mStatus == kStatus10 || mStatus == kStatus12) ChangeStatus(kStatus3); SetDestination(tenant, startTime); } int T2People::CalcCurrEstimate() const { int result; if (m80 > 0) { if (mStatus != kStatus11 && mStatus != kStatus1) { result = (mEstimate * m80 + (300 - mStress)) / (m80 + 1); } else { result = (mEstimate * m80 - mStress) / m80; } } else { result = mEstimate - mStress; } if (result < 1) result = 1; return result; } void T2People::IncEstimate(int value) { mEstimate += value; if (mEstimate < 1) mEstimate = 1; else if (mEstimate > 300) mEstimate = 300; } void T2People::UpdateEstimation() { mEstimate = CalcCurrEstimate(); mStress = 0; if (mStatus != kStatus11 && m80 < 4) m80++; StressChanged(); } int T2People::GetAverageStress() const { return 300 - CalcCurrEstimate(); } BOOL T2People::IncStress(int value) { mStress += value; if (mStress > 300) mStress = 300; else if (mStress < 0) mStress = 0; return StressChanged(); } BOOL T2People::StressChanged() { BOOL changed = false; if (!IsSpecialColor()) { int color = mColor; T2PeopleDef *def = (T2PeopleDef *) GetMatterDef(); if (!def) return false; if (mStress < def->GetStressBlueLimit()) color = 1; else if (mStress < def->GetStressYellowLimit()) color = 7; else if (mStress < (def->GetStressMax() - 10)) color = 9; else color = 9; if (mColor != color) { mColor = color; changed = true; } } return changed; } BOOL T2People::IsVIP() const { return (mColor == 14); } BOOL T2People::IsNamed() const { return (mColor == 13); } void T2People::SetColor(int col) { if (col > mColor) mColor = col; } void T2People::ClearColor() { if (mColor < 11) { mColor = 1; } else if (!IsVIP()) { if (IsSetSpecialFlag(kSpecialFlag20 | kSpecialFlag40)) mColor = 11; else mColor = 1; if (IsFavorite()) mColor = max(mColor, 13); if (IsSetSpecialFlag(kSpecialFlag4)) mColor = max(mColor, 17); if (mColor == 1) StressChanged(); } } /*virtual*/ void T2People::SetFavorite(BOOL fav) { T2Object::SetFavorite(fav); if (fav) SetColor(13); else ClearColor(); } BOOL T2People::VIPEstimation() { BOOL ok = false; if (IsVIP()) ok = CalcCurrEstimate() > 200; return ok; } BOOL T2People::SearchToilet(T2TowerDoc* towerDoc) { BOOL ok = false; if (SetDestinationToReturn()) { T2RegistedTenantDB *theDB = towerDoc->GetRegistedTenantDB(); T2RouteNavigator *theNavi = towerDoc->GetRouteNavi(); if (theDB && theNavi) { int toiletStatus; T2Tenant *theToilet = theDB->SearchToilet(theNavi, mCurPosition, toiletStatus); if (theToilet) { theToilet->IncReserveCount(1); SetDestination(theToilet->GetEquipID()); SetStatus(kStatus3); ok = true; } else { SetReturnToDestination(); T2TowerMessage *towerMessage = towerDoc->towerDoc_vf13C(); if (towerMessage) { // "トイレが混んでいる" - toilet is crowded CString msg = "\x83\x67\x83\x43\x83\x8C\x82\xAA\x8D\xAC\x82\xF1\x82\xC5\x82\xA2\x82\xE9"; switch (toiletStatus) { case -1: // "トイレが近くにない" - there is no toilet nearby msg = "\x83\x67\x83\x43\x83\x8C\x82\xAA\x8B\xDF\x82\xAD\x82\xC9\x82\xC8\x82\xA2"; case -2: towerMessage->PeopleBalloonMessage(msg, this); ClearSpecialFlag(kSpecialFlag2); IncEstimate(-30); } } } } } return ok; } void T2People::DrawSearchedPerson(T2TowerDoc* towerDoc) { switch (mStatus) { case kStatus3: case kStatus4: case kStatus5: case kStatus10: case kStatus12: case kStatus13: case kStatus14: case kStatus15: { RECT rect; rect.top = mCurPosition.y; rect.left = mCurPosition.x; rect.bottom = rect.top + 1; rect.right = rect.left + 2; Draw(towerDoc, rect); } } } /*virtual*/ void T2People::Draw(T2TowerDoc* towerDoc, const RECT& inRect) { if (towerDoc->GetZoomLevel() > 0) return; if (m18 != -1) { RECT rect = inRect; UT2Coordinate::UnitToQD(rect, 0, true); int objectID = mSilhouetteDef[mStyle]->mImageObj->FindObject(m18); #line 1380 _ASSERT(objectID != -1); mSilhouetteDef[mStyle]->mImageObj->DrawObject(towerDoc->GetImage(), objectID, rect, towerDoc->GetZoomLevel(), T2PaletteAnimeDef::GetCommonColor(mColor)); } } void T2People::Draw(T2BitImage* image, const RECT& inRect) { int objectID = mSilhouetteDef[mStyle]->mImageObj->FindObject(0); #line 1388 _ASSERT(objectID != -1); RECT rect = inRect; if (mSilhouetteDef[mStyle]->GetWidth() == 1) { rect.left -= 8; rect.right = rect.left + 16; } mSilhouetteDef[mStyle]->mImageObj->DrawObject(image, objectID, rect, 0, T2PaletteAnimeDef::GetCommonColor(mColor)); } void T2People::Draw(T2TowerDoc* towerDoc, T2Equip* equip) { if (!IsSleep() && (equip->IsMover() || !((T2Tenant *) equip)->IsFloor())) { RECT rect; POINT curPosition = GetCurPosition(); SetRect(&rect, curPosition.x, curPosition.y, curPosition.x + 2, curPosition.y + 1); UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); int theInd = equip->GetEquipDef()->mImageObj->FindObject(1003, mFiller); if (theInd >= 0) equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->GetImage(), theInd, rect, towerDoc->GetZoomLevel()); } } void T2People::DrawAt(T2TowerDoc* towerDoc, T2Equip* equip, POINT pt) { if (!IsSleep() && (equip->IsMover() || !((T2Tenant *) equip)->IsFloor())) { CRect rect; SetRect(&rect, 0, 0, 2, 1); rect.OffsetRect(mCurPosition.x - pt.x, mCurPosition.y - pt.y); UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); int theInd = equip->GetEquipDef()->mImageObj->FindObject(1003, mFiller); if (theInd >= 0) equip->GetEquipDef()->mImageObj->DrawObject(towerDoc->GetImage(), theInd, rect); } } void T2People::Duplicate(T2TowerDoc* inTowerDoc) { #line 1430 _ASSERT(inTowerDoc != NULL); T2Pool *pool = inTowerDoc->mPool; if (pool) pool->DuplicatePeople(mPeopleType); } void T2People::Remove(T2TowerDoc* inTowerDoc, unsigned int id) { BOOL flag = false; if (mHomeTenant == id) { mHomeTenant = 1; flag = true; } if (mWorkTenant == id) { mWorkTenant = 1; flag |= true; } if (flag && IsGeneral() && GetStatus() == kStatus1) { T2Pool *pool = inTowerDoc->GetPool(); if (pool) pool->RemovePeople(this); } } void T2People::TenantRemoved(unsigned int id) { if (GetDestination() == id) { Return(); IncEstimate(-100); } else if (RemoveReturn(id)) { IncEstimate(-200); } } void T2People::Interview(T2TowerDoc* towerDoc) { T2FloorInfo *floorInfo = towerDoc->GetFloorInfo(); if (floorInfo) { CString text; if (GetInterviewWords(towerDoc, text) && text.GetLength() != 0) { RECT rect; rect.left = 0; rect.top = 0; rect.right = 0; rect.bottom = 0; if (mStatus == kStatus6) { T2Request *request = floorInfo->GetRequest(mCurrEquipID); if (request) request->CalcPersonArea(this, rect); } else { CalcWalkingSilhouetteArea(rect); } if (!IsRectEmpty(&rect)) towerDoc->mTowerMessage->ObjectBalloonMessage(text, rect); } } } BOOL T2People::GetInterviewWords(T2TowerDoc* towerDoc, CString& outStr) { OptionEvent11Data optionEvent; optionEvent.people = this; optionEvent.str = &outStr; if (!DispatchOptionEvent(kPreInterviewWordsOptionEvent, &optionEvent)) return outStr != ""; unsigned int theFlags = 0; T2PeopleDef *thePeopleDef = (T2PeopleDef *) GetMatterDef(); T2FloorInfo *theFloorInfo = towerDoc->GetFloorInfo(); T2Tenant *theDstTenant = theFloorInfo->GetTenant(mDstTenant); T2Tenant *theWorkTenant = theFloorInfo->GetTenant(GetWorkTenant()); T2EquipDef *theEquipDef = NULL; if (mDstTenant != 1) { if (theDstTenant) { theEquipDef = theDstTenant->GetEquipDef(); if (theDstTenant == theWorkTenant) theFlags |= 1; } } else { theFlags |= 8; theEquipDef = towerDoc->mTenantTemplates->FindTenantDef(mPrevTenantType); if (theWorkTenant && theWorkTenant->GetEquipDef() == theEquipDef) theFlags |= 1; } if (mStyle == kPeopleStyle1) theFlags |= 2; else if (mStyle == kPeopleStyle2) theFlags |= 4; unsigned int level = 0; if (IsVIP()) { if (mDstTenant == 1 && VIPEstimation()) theFlags |= 0x10; switch (towerDoc->GetLevel()) { case 1: level = 3; break; case 2: level = 4; break; case 3: level = 5; break; } } else if (IsMaru()) { level = 6; theFlags &= ~1; } else if (IsReggae()) { level = 7; } else if (IsSetSpecialFlag(kSpecialFlag4) && (!theDstTenant || theDstTenant->GetRegistID() != kTenantRegistID4)) { level = 1; } else if (IsSetSpecialFlag(kSpecialFlag2) && (!theDstTenant || theDstTenant->GetRegistID() != kTenantRegistID7)) { level = 2; } T2WordDefArray *theWordDefArray = NULL; if (level != 0) { theWordDefArray = towerDoc->GetWorldDef()->mWordDefArray; } else { if (mStatus == kStatus6 && thePeopleDef && mStress >= thePeopleDef->GetStressYellowLimit()) { T2Request *request = theFloorInfo->GetRequest(mCurrEquipID); if (request) { unsigned int moverID = request->GetMoverID(); if (moverID) { T2Mover *mover = theFloorInfo->GetMover(moverID); theEquipDef = mover ? mover->GetEquipDef() : NULL; } } } theWordDefArray = theEquipDef ? theEquipDef->mWordDefArray : NULL; } if (theWordDefArray) theWordDefArray->GetWords(GetSex(), GetAge(), theFlags, level, outStr); optionEvent.people = this; optionEvent.str = &outStr; DispatchOptionEvent(kPostInterviewWordsOptionEvent, &optionEvent); return outStr != ""; } BOOL T2People::IsMaru() const { return mMatterDef && (mMatterDef->mSortKey == 4); } BOOL T2People::IsReggae() const { return mMatterDef && (mMatterDef->mSortKey == 5); } void T2People::BreakoutEmergency(T2TowerDoc* towerDoc) { mReturnStack->Init(); switch (mStatus) { case kStatus5: case kStatus10: ChangeStatus(kStatus3); case kStatus2: case kStatus3: case kStatus4: case kStatus8: SetSpecialFlag(kSpecialFlag80); SetDestination(1); break; case kStatus1: if (IsGeneral()) towerDoc->GetPool()->RemovePeople(this); break; } } /*virtual*/ void T2People::LoadSelf(T2Archive& archive, T2TowerDoc* towerDoc) { DWORD peopleCode; archive >> peopleCode; T2Matter::LoadSelf(archive, towerDoc); if (IsUsed()) { #pragma var_order(uc, s, us, i, peopleTypeCode, linkID, linkCode) unsigned char uc; short s; unsigned short us; archive >> uc; mSpecialFlag = uc; archive >> uc; mWalk = (uc != 0); archive >> s; mStress = s; archive >> us; m80 = us; archive >> s; mEstimate = s; archive >> s; mColor = s; archive >> s; mFiller = s; archive >> s; mPrevTenantType = s; archive >> mStyle; DWORD peopleTypeCode; archive >> peopleTypeCode; if (peopleTypeCode == 'PTYP') { mPeopleType->Read(archive); mMatterDef = towerDoc->mPeopleTemplates->FindPeopleDef(mPeopleType->GetSilhouetteType()); mAttribute = mMatterDef->GetAttribute(); } for (int i = 0; i < 3; i++) { short silhouetteType; archive >> silhouetteType; if (silhouetteType) mSilhouetteDef[i] = towerDoc->mSilhouetteTemplates->FindSilhouette(silhouetteType); else mSilhouetteDef[i] = NULL; } ChangeSilhouette(); DWORD linkCode; archive >> linkCode; #line 1727 _ASSERT(linkCode == 'pLk>'); unsigned int linkID; archive >> linkID; if (linkID) mNext = (CLink *) linkID; archive >> linkID; if (linkID) mPrev = (CLink *) linkID; } } /*virtual*/ void T2People::SaveSelf(T2Archive& archive) { DWORD peopleCode = ''; archive << peopleCode; T2Matter::SaveSelf(archive); if (IsUsed()) { #pragma var_order(linkPeople, uc, s, emptyLinkID, us, i, peopleTypeCode, linkCode) unsigned char uc; short s; unsigned short us; uc = mSpecialFlag; archive << uc; uc = (mWalk != 0); archive << uc; s = mStress; archive << s; us = m80; archive << us; s = mEstimate; archive << s; s = mColor; archive << s; s = mFiller; archive << s; s = mPrevTenantType; archive << s; archive << mStyle; DWORD peopleTypeCode; if (mPeopleType) peopleTypeCode = 'PTYP'; else peopleTypeCode = 'xPTP'; archive << peopleTypeCode; if (peopleTypeCode == 'PTYP') mPeopleType->Write(archive); for (int i = 0; i < 3; i++) { short silhouetteType = 0; if (mSilhouetteDef[i]) silhouetteType = mSilhouetteDef[i]->GetSilhouetteType(); archive << silhouetteType; } DWORD linkCode = 'pLk>'; archive << linkCode; unsigned int emptyLinkID = 0; T2People *linkPeople; if (mNext) { linkPeople = (T2People *) mNext; unsigned int linkID = linkPeople->GetPeopleID(); archive << linkID; } else { archive << emptyLinkID; } if (mPrev) { linkPeople = (T2People *) mPrev; unsigned int linkID = linkPeople->GetPeopleID(); archive << linkID; } else { archive << emptyLinkID; } } } void T2People::ResolveLink(T2PeopleArrayList* list) { if (mNext) { T2People *people = list->FindPeople((unsigned int) mNext); mNext = people; } if (mPrev) { T2People *people = list->FindPeople((unsigned int) mPrev); mPrev = people; } } /*virtual*/ T2InfoDialog* T2People::ShowInfoDialog(T2TowerDoc* towerDoc) { CRect rect; AfxGetMainWnd()->GetWindowRect(rect); T2DLGTEMPLATE tmpl; tmpl.pt = rect.CenterPoint(); tmpl.moduleHandle = GetWorldModuleHandle(); tmpl.resID = 2000; T2PeopleInfoDialog *dialog = new T2PeopleInfoDialog(this); dialog->Realize(this, &tmpl, towerDoc, NULL, NULL, true, NULL, 0, true); someGlobalPeople = this; return dialog; } void T2People::GetName(CString& outStr) { mSilhouetteDef[mStyle]->GetName(outStr); } /*virtual*/ BOOL T2People::GetSilhouetteRect(RECT& outRect) { if ( (mStatus == kStatus3) || (mStatus == kStatus5) || (mStatus == kStatus10) || (mStatus == kStatus12) || (mStatus == kStatus13) || (mStatus == kStatus4) || (mStatus == kStatus14) || (mStatus == kStatus15) ) { if (GetDirection() == 0) { outRect.left = mCurPosition.x + (2 - GetWidth()); outRect.top = mCurPosition.y; outRect.right = outRect.left + GetWidth(); outRect.bottom = outRect.top + 1; } else { outRect.left = mCurPosition.x; outRect.top = mCurPosition.y; outRect.right = outRect.left + GetWidth(); outRect.bottom = outRect.top + 1; } return true; } return false; } /*virtual*/ void T2People::DrawHitMask(T2TowerDoc* towerDoc) { if (IsWalk()) { CRect rect; if (GetSilhouetteRect(rect)) { UT2Coordinate::UnitToQD(rect, towerDoc->GetZoomLevel()); towerDoc->GetImage()->FillRect(rect, 1); } } } inline void T2People::ClearSpecialFlag(unsigned int flag) { mSpecialFlag &= ~flag; if ((flag & kSpecialFlag4) > 0) mColor = 1; } inline void T2People::SetSpecialFlag(unsigned int flag) { mSpecialFlag |= flag; if ((flag & kSpecialFlag4) > 0) mColor = 17; }