Sparks now properly check against how much space is left on the target block and don't try to put in more mana than available, actually making spark networks viable. Closes #433

This commit is contained in:
Lizbeth Rika committed 2014-12-23 21:46:42 +00:00
1 parent 26e6e70b7e
commit b8a4b0c282
6 files changed
+28 -3

No files matched your search

@@ -185,6 +185,8 @@ public class EntitySpark extends Entity implements ISparkEntity {
if(!transfers.isEmpty()) {
int manaTotal = Math.min(TRANSFER_RATE * transfers.size(), tile.getCurrentMana());
int manaForEach = manaTotal / transfers.size();
int manaSpent = 0;
if(manaForEach > transfers.size()) {
for(ISparkEntity spark : transfers) {
if(spark.getAttachedTile() == null || spark.getAttachedTile().isFull() || spark.areIncomingTransfersDone()) {
@@ -193,11 +195,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
}
ISparkAttachable attached = spark.getAttachedTile();
attached.recieveMana(manaForEach);
int spend = Math.min(attached.getAvailableSpaceForMana(), manaForEach);
attached.recieveMana(spend);
manaSpent += spend;
particlesTowards((Entity) spark);
}
tile.recieveMana(-manaTotal);
tile.recieveMana(-manaSpent);
}
}