Skip to content

Commit 7ea1139

Browse files
committed
apply energy difference
1 parent deab9e5 commit 7ea1139

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/java/bwapi/Unit.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,11 @@ public int getShields() {
337337
* @see UnitType#maxEnergy
338338
*/
339339
public int getEnergy() {
340+
int energy = unitData.getEnergy();
340341
if (game.isLatComEnabled() && self().energy.valid(game.getFrameCount())) {
341-
return self().energy.get();
342+
return energy + self().energy.get();
342343
}
343-
return unitData.getEnergy();
344+
return energy;
344345
}
345346

346347
/**

src/main/java/bwapi/UnitSelf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class UnitSelf {
2424
IntegerCache remainingTrainTime = new IntegerCache();
2525
UpgradeTypeCache upgrade = new UpgradeTypeCache();
2626
IntegerCache remainingUpgradeTime = new IntegerCache();
27-
IntegerCache energy = new IntegerCache();
2827
BooleanCache isMoving = new BooleanCache();
2928
BooleanCache isGathering = new BooleanCache();
3029
IntegerCache rallyPositionX = new IntegerCache();
@@ -37,6 +36,7 @@ class UnitSelf {
3736

3837
IntegerCache hitPoints = new IntegerCache();
3938
IntegerCache trainingQueueCount = new IntegerCache();
39+
IntegerCache energy = new IntegerCache();
4040

4141

4242
UnitSelf() {

0 commit comments

Comments
 (0)