#include "StdAfx.h" #include "T2Archive.h" #include "T2PeopleArray.h" #include "T2PeopleArrayList.h" T2PeopleArrayList::T2PeopleArrayList() { mCounter = 0; T2PeopleArray *peopleArray = new T2PeopleArray; Add(peopleArray); } /*virtual*/ T2PeopleArrayList::~T2PeopleArrayList() { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) delete peopleArray; } void T2PeopleArrayList::Add(T2PeopleArray* peopleArray) { LArray::Add(&peopleArray); } unsigned int T2PeopleArrayList::GetItemCount() { return GetCount(); } T2PeopleArray* T2PeopleArrayList::GetItemAt(int index) { T2PeopleArray *peopleArray; FetchItemAt(index, &peopleArray); return peopleArray; } T2People* T2PeopleArrayList::FindPeople(unsigned int peopleID) { LArrayIterator iterator(*this); T2People *people; T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) { people = peopleArray->FindPeople(peopleID); if (people) return people; } return NULL; } T2People* T2PeopleArrayList::FindUnusedPeople() { T2People *result = NULL; LArrayIterator iterator(*this); T2PeopleArray *peopleArray = NULL; while (!result && iterator.Next(&peopleArray)) { result = peopleArray->FindUnusedPeople(); } if (!result) { unsigned int newStartID = 1; if (peopleArray) newStartID = peopleArray->GetStartID() + 256; peopleArray = new T2PeopleArray(newStartID); if (peopleArray) { Add(peopleArray); result = peopleArray->FindUnusedPeople(); } } return result; } void T2PeopleArrayList::DispatchIdle(T2TowerDoc* towerDoc) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->DispatchIdle(towerDoc, mCounter); mCounter++; if (mCounter >= 8) mCounter = 0; } void T2PeopleArrayList::DrawSearchedPerson(T2TowerDoc* towerDoc) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->DrawSearchedPerson(towerDoc); } void T2PeopleArrayList::SetWalkPeople(int v) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->SetWalkPeople(v); } void T2PeopleArrayList::TenantRemoved(unsigned int v) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->TenantRemoved(v); } void T2PeopleArrayList::AddStress(int v) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->AddStress(v); } void T2PeopleArrayList::Read(T2Archive& archive, T2TowerDoc* towerDoc) { int numOfPeopleArrays; archive >> numOfPeopleArrays; RemoveItemsAt(GetCount(), 1); unsigned int startID = 1; for (int i = 0; i < numOfPeopleArrays; i++) { Add(new T2PeopleArray(startID)); startID += 256; } T2PeopleArray *thePeopleArray; LArrayIterator iter(*this); while (iter.Next(&thePeopleArray)) thePeopleArray->Read(archive, towerDoc); LArrayIterator iter2(*this); while (iter2.Next(&thePeopleArray)) thePeopleArray->ResolveLink(this); } void T2PeopleArrayList::Write(T2Archive& archive) { int numOfPeopleArrays = GetItemCount(); archive << numOfPeopleArrays; LArrayIterator iterator(*this); T2PeopleArray *thePeopleArray; while (iterator.Next(&thePeopleArray)) thePeopleArray->Write(archive); } void T2PeopleArrayList::BreakoutEmergency(T2TowerDoc* towerDoc) { LArrayIterator iterator(*this); T2PeopleArray *peopleArray; while (iterator.Next(&peopleArray)) peopleArray->BreakoutEmergency(towerDoc); }