-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerUser.h
More file actions
42 lines (34 loc) · 1.29 KB
/
ServerUser.h
File metadata and controls
42 lines (34 loc) · 1.29 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
/// @file ServerUser.h
#pragma once
/// 包含 ServerUser 依赖的外部定义。
/// 包含 EProperty 和 PropArray。
#include "props.h"
/// 包含 FeatureManager 类定义。
#include "FeatureManager.h"
/// 转发宏:在 ServerUser 内快速注册 Feature facade。
#define REGISTER_FEATURE_FACADE(FeatName) \
FeatName& get##FeatName() { \
return featureManager.getFeatureByClz<FeatName>(); \
} \
const FeatName& get##FeatName() const { \
return featureManager.getFeatureByClz<FeatName>(); \
}
/// ServerUser 玩家类。
class ServerUser {
public:
ServerUser() = default;
int GetTotalProperty(EProperty prop) const;
void userOnline();
void userOffline();
void logAllProps() const;
private:
/// 玩家属性。
PropArray baseProps = {0};
FeatureManager featureManager;
public:
/// 注册 feature 相关的 facade 转发函数。
REGISTER_FEATURE_FACADE(Inventory);
REGISTER_FEATURE_FACADE(Achievement);
REGISTER_FEATURE_FACADE(SelfSystem);
};
#undef REGISTER_FEATURE_FACADE