1#include "Project/Item/ActorScoreKeeper.h"
2
3#include "Library/Yaml/ByamlIter.h"
4
5namespace al {
6ActorScoreKeeper::ActorScoreKeeper() = default;
7
8// NON_MATCHING
9void ActorScoreKeeper::init(const ByamlIter& iter) {
10 if (iter.isTypeArray()) {
11 mSize = iter.getSize();
12 allocArray();
13 for (s32 i = 0; i < mSize; i++) {
14 ByamlIter subIter;
15 iter.tryGetIterByIndex(iter: &subIter, index: i);
16 putEntry(index: i, iter: subIter);
17 }
18 } else {
19 mSize = 1;
20 allocArray();
21 putEntry(index: 0, iter);
22 }
23}
24
25inline void ActorScoreKeeper::allocArray() {
26 Entry* local_array = new Entry[mSize]();
27 if (mSize)
28 memset(local_array, 0, sizeof(Entry) * mSize);
29 mArray = local_array;
30}
31
32inline void ActorScoreKeeper::putEntry(s32 index, const ByamlIter& iter) {
33 auto* entry = &mArray[index];
34 iter.tryGetStringByKey(string: &entry->factorName, key: "FactorName");
35 iter.tryGetStringByKey(string: &entry->categoryName, key: "CategoryName");
36}
37} // namespace al
38