1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#pragma once
#include <container/seadBuffer.h>
#include <container/seadOffsetList.h>
#include <container/seadSafeArray.h>
#include <heap/seadDisposer.h>
#include <thread/seadCriticalSection.h>
#include "KingSystem/ActorSystem/actBaseProcLink.h"
#include "KingSystem/Utils/Types.h"
namespace ksys::act {
class ActorLimiter {
SEAD_SINGLETON_DISPOSER(ActorLimiter)
ActorLimiter() : mLists() {}
~ActorLimiter() = default;
public:
enum class Category {
LumberjackTreeDrops = 0,
DroppedItems = 1,
PlayerTrash = 2,
Drops = 3,
SandSeal = 4,
Bullets = 5,
AmiiboDrops = 6,
_7 = 7,
};
static constexpr int NumCategories = 8;
class List {
public:
List() { mActorList.initOffset(offsetof(Node, node)); }
~List() { mNodes.freeBuffer(); }
bool init(sead::Heap* heap, int capacity);
bool addActor(BaseProc* proc, bool allow_evicting_old_actors);
private:
struct Node {
sead::ListNode node;
BaseProcLink proc_link;
};
sead::Buffer<Node> mNodes;
sead::OffsetList<Node> mActorList;
sead::CriticalSection mCritSection;
};
KSYS_CHECK_SIZE_NX150(List, 0x68);
bool init(sead::Heap* heap, const sead::SafeArray<int, NumCategories>& capacities);
List& get(Category category) { return mLists[s32(category)]; }
const List& get(Category category) const { return mLists[s32(category)]; }
private:
sead::SafeArray<List, NumCategories> mLists{};
};
KSYS_CHECK_SIZE_NX150(ActorLimiter, 0x360);
} // namespace ksys::act
|