-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDIDAddonsMLFeed.as
197 lines (172 loc) · 7.37 KB
/
DIDAddonsMLFeed.as
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#if DEPENDENCY_MLFEEDRACEDATA && DEPENDENCY_MLHOOK
namespace DID {
const MLFeed::PlayerCpInfo_V3@ plf = null;
const MLFeed::HookRaceStatsEventsBase_V3@ mlf = null;
void CacheLocalPlayerCoro() {
@mlf = MLFeed::GetRaceData_V3();
while (true) {
yield();
if (GetApp().CurrentPlayground is null)
@plf = null;
else if (plf is null)
@plf = mlf.GetPlayer_V3(MLFeed::LocalPlayersName);
}
}
Meta::PluginCoroutine@ MLFeedCacheLocalPlayerCoro = startnew(CacheLocalPlayerCoro);
class RaceTimeHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/RaceTime";
settings.friendlyName = "Current race time";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
c.content = (plf.CurrentRaceTime < 0) ? Time::Format(0) : Time::Format(plf.CurrentRaceTime);
return c;
}
}
class RaceTimeSplitHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/RaceTimeSplit";
settings.friendlyName = "Current race time (with freezes on checkpoint splits)";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
if (plf.cpCount > 0 && (plf.CurrentRaceTime - plf.LastCpTime) < int(deltaTimeDuration)) {
c.content = Time::Format(plf.lastCpTime);
} else {
c.content = (plf.CurrentRaceTime < 0) ? Time::Format(0) : Time::Format(plf.CurrentRaceTime);
}
return c;
}
}
void PrepareConfigCpSplitsTime(int cpMs, LaneConfig@ c) {
if (cpMs < 0) {
c.content = "+" + Time::Format(cpMs*-1, true, false);
} else {
c.content = "-" + Time::Format(cpMs, true, false);
}
if (deltaTimeColors) {
if (cpMs < 0) {
c.color = vec4(.869, 0.117, 0.117, .784);
} else {
c.color = vec4(0, .123, .822, .75);
}
}
}
class SplitDeltaHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/SplitDelta";
settings.friendlyName = "Checkpoint delta splits verus personal best";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
int cpMs;
if (plf.cpCount > 0 && (plf.CurrentRaceTime - plf.LastCpTime) < int(deltaTimeDuration) && plf.BestRaceTimes.Length > uint(plf.cpCount)) {
cpMs = plf.BestRaceTimes[plf.cpCount-1] - plf.LastCpTime;
PrepareConfigCpSplitsTime(cpMs, c);
} else {
c.content = "";
}
return c;
}
}
class CurrentLapHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/CurrentLap";
settings.friendlyName = "Lap counter (if multilap)";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
c.content = getTotLaps() == 1 ? "" : Text::Format("%d", (plf.CpCount / (mlf.CpCount+1))+1)+" / "+Text::Format("%d", mlf.LapCount);
return c;
}
}
class CurrentLapAlwaysHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/CurrentLapAlways";
settings.friendlyName = "Lap counter (always)";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
c.content = Text::Format("%d", (plf.CpCount / (mlf.CpCount+1))+1)+" / "+Text::Format("%d", mlf.LapCount);
return c;
}
}
class CurrentCheckpointHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "MisfitMaid";
settings.internalName = "DID/CurrentCheckpoint";
settings.friendlyName = "Checkpoint counter";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned) return defaults;
c.content = Text::Format("%d", plf.CpCount % (mlf.CpCount+1))+" / "+Text::Format("%d", mlf.CpCount);
return c;
}
}
class NoRespawnTimeHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "XertroV";
settings.internalName = "DID/NoRespawnTime";
settings.friendlyName = "No-Respawn Time";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned || plf.TimeLostToRespawns == 0) return defaults;
c.content = Time::Format(plf.TheoreticalRaceTime);
return c;
}
}
class NoRespawnSplitsHandler : LaneProvider {
LaneProviderSettings@ getProviderSetup() {
LaneProviderSettings settings;
settings.author = "XertroV";
settings.internalName = "DID/NoRespawnSplits";
settings.friendlyName = "No-Respawn Splits vs Personal Best";
return settings;
}
LaneConfig@ getLaneConfig(LaneConfig@ &in defaults) {
LaneConfig c = defaults;
if (plf is null) return c;
if (plf.spawnStatus == MLFeed::SpawnStatus::NotSpawned || plf.TimeLostToRespawns == 0) return c;
if (plf.BestRaceTimes.Length < uint(plf.cpCount)) return c;
auto cpMs = int(plf.BestRaceTimes[plf.cpCount-1]) - plf.LastTheoreticalCpTime;
if ((plf.TheoreticalRaceTime - plf.LastTheoreticalCpTime) < int(deltaTimeDuration))
PrepareConfigCpSplitsTime(cpMs, c);
return c;
}
}
}
#endif