blob: 079b5c721bd3f8883b3ee76ad880dd20f1d96b12 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#include "KingSystem/Physics/physDefines.h"
namespace ksys::phys {
ContactLayerType getContactLayerType(ContactLayer layer) {
if (layer > ContactLayer::EntityEnd)
return ContactLayerType::Sensor;
return ContactLayerType::Entity;
}
u32 makeContactLayerMask(ContactLayer layer) {
if (layer < FirstSensor)
return 1 << layer;
return 1 << (layer - FirstSensor);
}
u32 getContactLayerBase(ContactLayerType type) {
if (type == ContactLayerType::Entity)
return FirstEntity;
return FirstSensor;
}
int getContactLayerBaseRelativeValue(ContactLayer layer) {
return layer - (layer < FirstSensor ? FirstEntity : FirstSensor);
}
const char* contactLayerToText(ContactLayer layer) {
return layer.text();
}
ContactLayer contactLayerFromText(const sead::SafeString& text) {
for (auto layer : ContactLayer()) {
if (text == layer.text())
return layer;
}
return 0;
}
const char* materialToText(Material material) {
return material.text();
}
Material materialFromText(const sead::SafeString& text) {
for (auto material : Material()) {
if (text == material.text())
return material;
}
return 0;
}
const char* groundHitToText(GroundHit hit) {
return hit.text();
}
GroundHit groundHitFromText(const sead::SafeString& text) {
for (auto hit : GroundHit()) {
if (text == hit.text())
return hit;
}
return GroundHit::HitAll;
}
const char* floorCodeToText(FloorCode code) {
return code.text();
}
FloorCode floorCodeFromText(const sead::SafeString& text) {
for (auto code : FloorCode()) {
if (text == code.text())
return code;
}
return 0;
}
const char* wallCodeToText(WallCode code) {
return code.text();
}
WallCode wallCodeFromText(const sead::SafeString& text) {
for (auto code : WallCode()) {
if (text == code.text())
return code;
}
return 0;
}
MotionType motionTypeFromText(const sead::SafeString& text) {
static constexpr const char* texts[] = {
"Dynamic",
"Fixed",
"Keyframed",
};
static_assert(int(MotionType::Dynamic) == 0);
static_assert(int(MotionType::Fixed) == 1);
static_assert(int(MotionType::Keyframed) == 2);
int type = 0;
for (const char* type_text : texts) {
if (text == type_text)
return static_cast<MotionType>(type);
++type;
}
return MotionType::Unknown;
}
} // namespace ksys::phys
|