diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2MoverArray.cpp | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-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); } |