2023-12-13 00:40:16 -05:00
|
|
|
#include "Game/LiveActor/ActiveActorList.hpp"
|
|
|
|
|
#include "Game/LiveActor/LiveActor.hpp"
|
2021-12-22 03:49:52 -05:00
|
|
|
|
|
|
|
|
ActiveActorList::ActiveActorList(int max) {
|
|
|
|
|
mCurCount = max;
|
|
|
|
|
mActorList = 0;
|
|
|
|
|
mMaxCount = 0;
|
|
|
|
|
mActorList = new LiveActor*[max];
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ActiveActorList::isFull() const {
|
|
|
|
|
return mCurCount >= mMaxCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActiveActorList::addActor(LiveActor *pActor) {
|
2022-02-12 02:39:47 -05:00
|
|
|
if (!hasTooMany()) {
|
2021-12-22 03:49:52 -05:00
|
|
|
mActorList[mCurCount] = pActor;
|
|
|
|
|
mCurCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActiveActorList::removeDeadActor() {
|
|
|
|
|
s32 cur = 0;
|
|
|
|
|
s32 idx = 0;
|
|
|
|
|
|
|
|
|
|
while (cur < mCurCount) {
|
|
|
|
|
if (MR::isDead(mActorList[idx])) {
|
|
|
|
|
mActorList[idx] = mActorList[mCurCount - 1];
|
|
|
|
|
s32 newCount = mCurCount - 1;
|
|
|
|
|
mActorList[newCount] = 0;
|
|
|
|
|
mCurCount--;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
++cur;
|
|
|
|
|
++idx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActiveActorList::clear() {
|
|
|
|
|
for (s32 i = 0; i < mMaxCount; i++) {
|
|
|
|
|
mActorList[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCurCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ActiveActorList::killAll() {
|
|
|
|
|
for (s32 i = 0; i < mCurCount; i++) {
|
|
|
|
|
if (!MR::isDead(mActorList[i])) {
|
|
|
|
|
mActorList[i]->kill();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mActorList[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mCurCount = 0;
|
|
|
|
|
}
|