Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathBoostManager.java
More file actions
Latest commit
72 lines (58 loc) · 2.24 KB
/
Copy pathBoostManager.java
File metadata and controls
72 lines (58 loc) · 2.24 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
packagerlbotexample.boost;
importrlbot.cppinterop.RLBotDll;
importrlbot.flat.BoostPadState;
importrlbot.flat.FieldInfo;
importrlbot.flat.GameTickPacket;
importrlbotexample.vector.Vector3;
importjava.io.IOException;
importjava.util.ArrayList;
importjava.util.List;
/**
* Information about where boost pads are located on the field and what status they have.
*
* This class is here for your convenience, it is NOT part of the framework. You can change it as much
* as you want, or delete it.
*/
publicclassBoostManager {
privatestaticfinalList<BoostPad> orderedBoosts = newArrayList<>();
privatestaticfinalList<BoostPad> fullBoosts = newArrayList<>();
privatestaticfinalList<BoostPad> smallBoosts = newArrayList<>();
publicstaticList<BoostPad> getFullBoosts() {
returnfullBoosts;
}
publicstaticList<BoostPad> getSmallBoosts() {
returnsmallBoosts;
}
privatestaticvoidloadFieldInfo(FieldInfofieldInfo) {
synchronized (orderedBoosts) {
orderedBoosts.clear();
fullBoosts.clear();
smallBoosts.clear();
for (inti = 0; i < fieldInfo.boostPadsLength(); i++) {
rlbot.flat.BoostPadflatPad = fieldInfo.boostPads(i);
BoostPadourPad = newBoostPad(newVector3(flatPad.location()), flatPad.isFullBoost());
orderedBoosts.add(ourPad);
if (ourPad.isFullBoost()) {
fullBoosts.add(ourPad);
} else {
smallBoosts.add(ourPad);
}
}
}
}
publicstaticvoidloadGameTickPacket(GameTickPacketpacket) {
if (packet.boostPadStatesLength() > orderedBoosts.size()) {
try {
loadFieldInfo(RLBotDll.getFieldInfo());
} catch (IOExceptione) {
e.printStackTrace();
return;
}
}
for (inti = 0; i < packet.boostPadStatesLength(); i++) {
BoostPadStateboost = packet.boostPadStates(i);
BoostPadexistingPad = orderedBoosts.get(i); // existingPad is also referenced from the fullBoosts and smallBoosts lists
existingPad.setActive(boost.isActive());
}
}
}