diff options
Diffstat (limited to 'src/T2DLL/T2MoverArray.cpp')
-rw-r--r-- | src/T2DLL/T2MoverArray.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/T2DLL/T2MoverArray.cpp b/src/T2DLL/T2MoverArray.cpp index 9ecffac..4f98a81 100644 --- a/src/T2DLL/T2MoverArray.cpp +++ b/src/T2DLL/T2MoverArray.cpp @@ -1,25 +1,61 @@ #include "T2MoverArray.h" -T2MoverArray::T2MoverArray(unsigned int) { +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*, const RECT&) { +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*, int) { +/*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*) const { +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&, T2TowerDoc*) { +void T2MoverArray::Read(T2Archive& inArchive, T2TowerDoc* inDoc) { + for (int i = 0; i < kGroupSize; i++) + mMover[i].Load(inArchive, inDoc); } -void T2MoverArray::Write(T2Archive&) { +void T2MoverArray::Write(T2Archive& inArchive) { + for (int i = 0; i < kGroupSize; i++) + mMover[i].Save(inArchive); } |