You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/bwapi/Bullet.java
+20-22Lines changed: 20 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,24 @@
6
6
7
7
/**
8
8
* An object representing a bullet or missile spawned from an attack.
9
-
*
9
+
* <p>
10
10
* The Bullet interface allows you to detect bullets, missiles, and other types
11
11
* of non-melee attacks or special abilities that would normally be visible through
12
12
* human eyes (A lurker spike or a Queen's flying parasite), allowing quicker reaction
13
13
* to unavoidable consequences.
14
-
*
14
+
* <p>
15
15
* For example, ordering medics to restore units that are about to receive a lockdown
16
16
* to compensate for latency and minimize its effects. You can't know entirely which unit
17
17
* will be receiving a lockdown unless you can detect the lockdown missile using the
18
18
* {@link Bullet} class.
19
-
*
19
+
* <p>
20
20
* {@link Bullet} objects are re-used after they are destroyed, however their ID is updated when it
21
21
* represents a new Bullet.
22
-
*
22
+
* <p>
23
23
* If {@link Flag#CompleteMapInformation} is disabled, then a {@link Bullet} is accessible if and only if
24
24
* it is visible. Otherwise if {@link Flag#CompleteMapInformation} is enabled, then all Bullets
25
25
* in the game are accessible.
26
+
*
26
27
* @see Game#getBullets
27
28
* @see Bullet#exists
28
29
*/
@@ -40,22 +41,22 @@ public class Bullet implements Comparable<Bullet> {
40
41
/**
41
42
* Retrieves a unique identifier for the current {@link Bullet}.
42
43
*
43
-
* @return An integer value containing the identifier.
44
+
* @return An integer value containing the identifier.
44
45
*/
45
46
publicintgetID() {
46
47
returnid;
47
48
}
48
49
49
50
/**
50
51
* Checks if the {@link Bullet} exists in the view of the BWAPI player.
51
-
*
52
+
* <p>
52
53
* If {@link Flag#CompleteMapInformation} is disabled, and a {@link Bullet} is not visible, then the
53
54
* return value will be false regardless of the Bullet's true existence. This is because
54
55
* absolutely no state information on invisible enemy bullets is made available to the AI.
55
-
*
56
+
* <p>
56
57
* If {@link Flag#CompleteMapInformation} is enabled, then this function is accurate for all
57
58
* {@link Bullet} information.
58
-
*
59
+
*
59
60
* @return true if the bullet exists or is visible, false if the bullet was destroyed or has gone out of scope.
60
61
* @see #isVisible
61
62
* @see Unit#exists
@@ -67,7 +68,7 @@ public boolean exists() {
67
68
/**
68
69
* Retrieves the {@link Player} interface that owns the Bullet.
69
70
*
70
-
* @return The owning {@link Player} object. Returns null if the {@link Player} object for this {@link Bullet} is inaccessible.
71
+
* @return The owning {@link Player} object. Returns null if the {@link Player} object for this {@link Bullet} is inaccessible.
71
72
*/
72
73
publicPlayergetPlayer() {
73
74
returngame.getPlayer(bulletData.getPlayer());
@@ -76,7 +77,7 @@ public Player getPlayer() {
76
77
/**
77
78
* Retrieves the type of this {@link Bullet}.
78
79
*
79
-
* @return A {@link BulletType} representing the Bullet's type. Returns {@link BulletType#Unknown} if the {@link Bullet} is inaccessible.
80
+
* @return A {@link BulletType} representing the Bullet's type. Returns {@link BulletType#Unknown} if the {@link Bullet} is inaccessible.
80
81
*/
81
82
publicBulletTypegetType() {
82
83
returnBulletType.idToEnum[bulletData.getType()];
@@ -85,7 +86,7 @@ public BulletType getType() {
85
86
/**
86
87
* Retrieves the {@link Unit} that the {@link Bullet} spawned from.
87
88
*
88
-
* @return The owning {@link Unit} object. Returns null if the source can not be identified or is inaccessible.
89
+
* @return The owning {@link Unit} object. Returns null if the source can not be identified or is inaccessible.
89
90
* @see #getTarget
90
91
*/
91
92
publicUnitgetSource() {
@@ -95,7 +96,7 @@ public Unit getSource() {
95
96
/**
96
97
* Retrieves the Bullet's current position.
97
98
*
98
-
* @return A {@link Position} containing the Bullet's current coordinates. Returns {@link Position#Unknown} if the {@link Bullet} is inaccessible.
99
+
* @return A {@link Position} containing the Bullet's current coordinates. Returns {@link Position#Unknown} if the {@link Bullet} is inaccessible.
99
100
* @see #getTargetPosition
100
101
*/
101
102
publicPositiongetPosition() {
@@ -106,7 +107,7 @@ public Position getPosition() {
106
107
* Retrieve's the direction the {@link Bullet} is facing. If the angle is 0, then
107
108
* the {@link Bullet} is facing right.
108
109
*
109
-
* @return A double representing the direction the {@link Bullet} is facing. Returns 0.0 if the bullet is inaccessible.
110
+
* @return A double representing the direction the {@link Bullet} is facing. Returns 0.0 if the bullet is inaccessible.
110
111
*/
111
112
publicdoublegetAngle() {
112
113
returnbulletData.getAngle();
@@ -115,8 +116,7 @@ public double getAngle() {
115
116
/**
116
117
* Retrieves the X component of the Bullet's velocity, measured in pixels per frame.
117
118
*
118
-
* @return A double representing the number of pixels moved on the X axis per frame. Returns 0.0 if the {@link Bullet} is inaccessible.
119
-
*
119
+
* @return A double representing the number of pixels moved on the X axis per frame. Returns 0.0 if the {@link Bullet} is inaccessible.
120
120
* @see #getVelocityY
121
121
* @see #getAngle
122
122
*/
@@ -127,8 +127,7 @@ public double getVelocityX() {
127
127
/**
128
128
* Retrieves the Y component of the Bullet's velocity, measured in pixels per frame.
129
129
*
130
-
* @return A double representing the number of pixels moved on the Y axis per frame. Returns 0.0 if the {@link Bullet} is inaccessible.
131
-
*
130
+
* @return A double representing the number of pixels moved on the Y axis per frame. Returns 0.0 if the {@link Bullet} is inaccessible.
132
131
* @see #getVelocityX
133
132
* @see #getAngle
134
133
*/
@@ -139,7 +138,7 @@ public double getVelocityY() {
139
138
/**
140
139
* Retrieves the Unit interface that the {@link Bullet} is heading to.
141
140
*
142
-
* @return The target Unit object, if one exists. Returns null if the Bullet's target {@link Unit} is inaccessible, the {@link Bullet} is targetting the ground, or if the {@link Bullet} itself is inaccessible.
141
+
* @return The target Unit object, if one exists. Returns null if the Bullet's target {@link Unit} is inaccessible, the {@link Bullet} is targetting the ground, or if the {@link Bullet} itself is inaccessible.
143
142
* @see #getTargetPosition
144
143
* @see #getSource
145
144
*/
@@ -150,7 +149,7 @@ public Unit getTarget() {
150
149
/**
151
150
* Retrieves the target position that the {@link Bullet} is heading to.
152
151
*
153
-
* @return A {@link Position} indicating where the {@link Bullet} is headed. Returns {@link Position#Unknown} if the bullet is inaccessible.
152
+
* @return A {@link Position} indicating where the {@link Bullet} is headed. Returns {@link Position#Unknown} if the bullet is inaccessible.
154
153
* @see #getTarget
155
154
* @see #getPosition
156
155
*/
@@ -160,12 +159,12 @@ public Position getTargetPosition() {
160
159
161
160
/**
162
161
* Retrieves the timer that indicates the Bullet's life span.
163
-
*
162
+
* <p>
164
163
* Bullets are not permanent objects, so they will often have a limited life span.
165
164
* This life span is measured in frames. Normally a Bullet will reach its target
166
165
* before being removed.
167
166
*
168
-
* @return An integer representing the remaining number of frames until the {@link Bullet} self-destructs. Returns 0 if the {@link Bullet} is inaccessible.
167
+
* @return An integer representing the remaining number of frames until the {@link Bullet} self-destructs. Returns 0 if the {@link Bullet} is inaccessible.
169
168
*/
170
169
publicintgetRemoveTimer() {
171
170
returnbulletData.getRemoveTimer();
@@ -179,7 +178,6 @@ public boolean isVisible() {
179
178
* Retrieves the visibility state of the Bullet.
180
179
*
181
180
* @param player If this parameter is specified, then the Bullet's visibility to the given player is checked. If this parameter is omitted, then a default value of null is used, which will check if the BWAPI player has vision of the {@link Bullet}.
182
-
*
183
181
* @return true if the {@link Bullet} is visible to the specified player, false if the {@link Bullet} is not visible to the specified player.
0 commit comments