#include "StdAfx.h" #include "T2MoverArray.h" T2MoverArray::T2MoverArray(unsigned int inStartID) : T2ObjectArray(inStartID) { for (unsigned int i = 0; i < kGroupSize; i++) mMover[i].mEquipID = mStartID + i; } /*virtual*/ T2MoverArray::~T2MoverArray() { } T2Mover* T2MoverArray::FindUnusedMover() { for (int i = 0; i < kGroupSize; i++) { if (!mMover[i].IsUsed()) return &mMover[i]; } return NULL; } void T2MoverArray::DrawMoverAll(T2TowerDoc* inDoc, const RECT& inRect) { for (int i = 0; i < kGroupSize; i++) { T2Mover *theMover = &mMover[i]; if (theMover->IsUsed()) { RECT moverArea; RECT intersection; theMover->GetEquipArea(moverArea); if (IntersectRect(&intersection, &moverArea, &inRect)) theMover->Draw(inDoc, inRect); } } } /*virtual*/ void T2MoverArray::DispatchIdle(T2TowerDoc* inDoc, int) { for (int i = 0; i < kGroupSize; i++) { if (mMover[i].IsUsed()) mMover[i].Idle(inDoc); } } int T2MoverArray::CalcMentenanceCost(T2TowerDoc* inDoc) const { int cost = 0; for (int i = 0; i < kGroupSize; i++) { if (mMover[i].IsUsed()) cost += mMover[i].CalcMentenanceCost(inDoc); } return cost; } void T2MoverArray::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { for (int i = 0; i < kGroupSize; i++) mMover[i].Load(inArchive, inDoc); } void T2MoverArray::Write(T2Archive& inArchive) { for (int i = 0; i < kGroupSize; i++) mMover[i].Save(inArchive); }