Commit a5558e9e authored by moonbase420's avatar moonbase420

possible fix for powered deterioration

parent 375d0379
......@@ -43,7 +43,7 @@ public class DegradeSystem extends IteratingSystem {
@Wire
GameMode mode;
private GameMode mode;
@Wire
private NetSys netSys;
@Wire
......@@ -61,10 +61,9 @@ public class DegradeSystem extends IteratingSystem {
@Wire
private ComponentMapper<DegradeComponent> mDegrade;
float timer = 0, poweredTimer = 0;
float deteriorationTimer;
float poweredDeteriorationTimer;
float deteriorationRateThisTick = 0;
private float deteriorationTimer;
private float poweredDeteriorationTimer;
private float deteriorationRateThisTick = 0;
public DegradeSystem() {
super(Aspect.all(Ship.class));
......@@ -75,16 +74,7 @@ public class DegradeSystem extends IteratingSystem {
Ship ship = mShip.get(entityId);
ArrayList<Tile> tiles = ship.getTiles().getListUnsafe();
boolean powered = false;
for (Tile t : tiles) {
if (t.getDef().getPrefab() != null) {
Prefab p = prefabSys.getPrefabManager().get(TileTypes.get(t.getDef().getId()).getPrefab());
if (p.getPower() != null) {
powered = true;
break;
}
}
}
boolean powered = checkIfShipHasPower(tiles);
if (powered) {
mDegrade.create(entityId).setTimer(poweredDeteriorationTimer);
......@@ -94,18 +84,14 @@ public class DegradeSystem extends IteratingSystem {
@Override
protected void removed(int entityId) {
super.removed(entityId);
mDegrade.remove(entityId);
}
@Override
protected void begin() {
super.begin();
deteriorationRateThisTick = mode.data.deteriorateDamage;
deteriorationTimer = mode.data.deteriorateTimer;
poweredDeteriorationTimer = mode.data.poweredDeteriorateTimer;
// timer = 0;
// poweredTimer = 0;
}
@Override
......@@ -136,23 +122,12 @@ public class DegradeSystem extends IteratingSystem {
private void deteriorateShip(int entityId, boolean override) {
Ship ship = mShip.get(entityId);
boolean powered = false;
boolean powered = checkIfShipHasPower(ship.getTiles().getListUnsafe());
boolean playerOnShip = noPlayersOnShip(entityId);
if (override || !playerOnShip) {
ArrayList<Tile> tiles = ship.getTiles().getListUnsafe();
//initial check for any powered tile to use alternative timer
for (Tile t : tiles) {
if (t.getDef().getPrefab() != null) {
Prefab p = prefabSys.getPrefabManager().get(TileTypes.get(t.getDef().getId()).getPrefab());
if (p.getPower() != null) {
powered = true;
break;
}
}
}
float timer = mDegrade.get(entityId).getTimer();
if (timer <= 0) {
......@@ -164,8 +139,7 @@ public class DegradeSystem extends IteratingSystem {
mDegrade.get(entityId).setTimer(deteriorationTimer);
}
}
}
if(playerOnShip) {
} else {
if(powered)
mDegrade.get(entityId).setTimer(poweredDeteriorationTimer);
else mDegrade.get(entityId).setTimer(deteriorationTimer);
......@@ -173,6 +147,18 @@ public class DegradeSystem extends IteratingSystem {
}
private boolean checkIfShipHasPower(ArrayList<Tile> tiles) {
for (Tile t : tiles) {
if (t.getDef().getPrefab() != null) {
Prefab p = prefabSys.getPrefabManager().get(TileTypes.get(t.getDef().getId()).getPrefab());
if (p.getPower() != null) {
return true;
}
}
}
return false;
}
private boolean noPlayersOnShip(int eShip) {
boolean playerFound = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment