From c0c336500955a23e344651e5412c9d9d441ef4ee Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 28 Jun 2023 22:22:32 +0100 Subject: first pass of T2DLL --- src/T2DLL/T2MoverArray.cpp | 48 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/T2DLL/T2MoverArray.cpp') 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); } -- cgit v1.2.3