#include "StdAfx.h" #include "T2OutObjArray.h" T2OutObjArray::T2OutObjArray(unsigned int inStartID) : T2ObjectArray(inStartID) { for (unsigned int i = 0; i < kGroupSize; i++) mOutObj[i].mID = mStartID + i; } /*virtual*/ T2OutObjArray::~T2OutObjArray() { } T2OutObj* T2OutObjArray::FindUnusedOutObj() const { for (int i = 0; i < kGroupSize; i++) { if (!mOutObj[i].IsUsed()) return (T2OutObj *) &mOutObj[i]; } return NULL; } /*virtual*/ void T2OutObjArray::DispatchIdle(T2TowerDoc* inDoc, int) { for (int i = 0; i < kGroupSize; i++) { if (mOutObj[i].IsUsed()) mOutObj[i].Idle(inDoc); } } int T2OutObjArray::CalcMentenanceCost(T2TowerDoc* inDoc) const { int cost = 0; const T2OutObj *theOutObj = &mOutObj[0]; for (unsigned int i = 0; i < kGroupSize; i++, theOutObj++) { if (theOutObj->IsUsed()) cost += theOutObj->CalcMentenanceCost(inDoc); } return cost; } void T2OutObjArray::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { for (int i = 0; i < kGroupSize; i++) mOutObj[i].Load(inArchive, inDoc); } void T2OutObjArray::Write(T2Archive& inArchive) { for (int i = 0; i < kGroupSize; i++) mOutObj[i].Save(inArchive); }