v0.9.1b: code improvements to timing when blobs are added

This commit is contained in:
Evan Debenham
2020-12-28 18:22:58 -05:00
parent 9a27edf1e4
commit 2feeaad42a
5 changed files with 9 additions and 5 deletions
@@ -118,6 +118,7 @@ public abstract class Actor implements Bundlable {
// ********************** // **********************
// *** Static members *** // *** Static members ***
// **********************
private static HashSet<Actor> all = new HashSet<>(); private static HashSet<Actor> all = new HashSet<>();
private static HashSet<Char> chars = new HashSet<>(); private static HashSet<Char> chars = new HashSet<>();
@@ -204,6 +205,10 @@ public abstract class Actor implements Bundlable {
return current != null; return current != null;
} }
public static int curActorPriority() {
return current != null ? current.actPriority : DEFAULT;
}
public static boolean keepActorThreadAlive = true; public static boolean keepActorThreadAlive = true;
public static void process() { public static void process() {
@@ -234,6 +234,10 @@ public class Blob extends Actor {
if (gas == null) { if (gas == null) {
gas = Reflection.newInstance(type); gas = Reflection.newInstance(type);
//this ensures that gasses do not get an 'extra turn' if they are added by a mob or buff
if (Actor.curActorPriority() < gas.actPriority) {
gas.spend(1f);
}
} }
if (gas != null){ if (gas != null){
@@ -106,9 +106,6 @@ public class DM200 extends Mob {
@Override @Override
protected boolean act() { protected boolean act() {
//ensures toxic gas acts at the appropriate time when added
//TODO we have this check in 2 places now, can we just ensure that blobs spend an extra turn when added?
GameScene.add(Blob.seed(pos, 0, ToxicGas.class));
ventCooldown--; ventCooldown--;
return super.act(); return super.act();
} }
@@ -63,7 +63,6 @@ public class DM201 extends DM200 {
Dungeon.level.updateFieldOfView( this, fieldOfView ); Dungeon.level.updateFieldOfView( this, fieldOfView );
} }
GameScene.add(Blob.seed(pos, 0, CorrosiveGas.class));
if (paralysed <= 0 && state == HUNTING && enemy != null && enemySeen if (paralysed <= 0 && state == HUNTING && enemy != null && enemySeen
&& threatened && !Dungeon.level.adjacent(pos, enemy.pos) && fieldOfView[enemy.pos]){ && threatened && !Dungeon.level.adjacent(pos, enemy.pos) && fieldOfView[enemy.pos]){
enemySeen = enemy.isAlive() && fieldOfView[enemy.pos] && enemy.invisible <= 0; enemySeen = enemy.isAlive() && fieldOfView[enemy.pos] && enemy.invisible <= 0;
@@ -153,7 +153,6 @@ public class NewDM300 extends Mob {
@Override @Override
protected boolean act() { protected boolean act() {
GameScene.add(Blob.seed(pos, 0, FallingRocks.class)); GameScene.add(Blob.seed(pos, 0, FallingRocks.class));
GameScene.add(Blob.seed(pos, 0, ToxicGas.class));
//ability logic only triggers if DM is not supercharged //ability logic only triggers if DM is not supercharged
if (!supercharged){ if (!supercharged){