-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatureManager.cpp
More file actions
55 lines (46 loc) · 1.77 KB
/
FeatureManager.cpp
File metadata and controls
55 lines (46 loc) · 1.77 KB
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
#include "FeatureManager.h"
/// 完成 Feature 模块静态检查。
static_assert(GET_ROW(Inventory) == 0, "Inventory 模块映射错误!");
static_assert(GET_ROW(Achievement) == -1, "Achievement 模块映射错误!");
static_assert(GET_ROW(SelfSystem) == 1, "SelfSystem 模块映射错误!");
/// FeatureManager 构造函数。
FeatureManager::FeatureManager() {
std::apply([this](auto&... f) {
((bindPropCallback(f)), ...);
}, features);
/// 首次计算。
recalculateTotalProps();
}
void FeatureManager::recalculateTotalProps() {
/// 💥 更新所有的属性值。
std::fill(newTotalProps.begin(), newTotalProps.end(), 0);
/// 💥 假设全量重算时也更新了 cachedFeatProps。
std::fill(cachedFeatProps.begin(), cachedFeatProps.end(), PropArray{ 0 });
std::apply([this](auto&... f) {
/// 通知所有功能去重算。
((dispatchRecompute(f)), ...);
/// 计算并缓存所有的属性。
((accumulateProp(f)), ...);
}, features);
}
const PropArray& FeatureManager::getNewTotalProps() const {
return newTotalProps;
}
void FeatureManager::DispatchRecalculateProps() {
std::cout << " [FeatureManager::DispatchRecalculateProps] 属性重算...\n";
std::apply([this](auto&... f) {
((dispatchRecompute(f)), ...);
}, features);
}
void FeatureManager::DispatchLoadAll() {
std::cout << " [FeatureManager::DispatchLoadAll] load all...\n";
std::apply([this](auto&... f) {
((load(f)), ...);
}, features);
}
void FeatureManager::DispatchSaveAll() {
std::cout << " [FeatureManager::DispatchSaveAll] save all...\n";
std::apply([this](auto&... f) {
((save(f)), ...);
}, features);
}