v2.2.0: removed usages of negative values in Actor.addDelayed

This commit is contained in:
Evan Debenham
2023-08-14 17:28:14 -04:00
parent 7b6fed2acf
commit 345ddffd1b
17 changed files with 32 additions and 25 deletions

View File

@@ -321,7 +321,7 @@ public abstract class Actor implements Bundlable {
}
public static void addDelayed( Actor actor, float delay ) {
add( actor, now + delay );
add( actor, now + Math.max(delay, 0) );
}
private static synchronized void add( Actor actor, float time ) {

View File

@@ -147,7 +147,7 @@ public class WarpBeacon extends ArmorAbility {
if (!candidates.isEmpty()){
ScrollOfTeleportation.appear(hero, tracker.pos);
Actor.addDelayed( new Pushing( toPush, toPush.pos, candidates.get(0) ), -1 );
Actor.add( new Pushing( toPush, toPush.pos, candidates.get(0) ));
toPush.pos = candidates.get(0);
Dungeon.level.occupyCell(toPush);

View File

@@ -124,7 +124,7 @@ public class DemonSpawner extends Mob {
Dungeon.level.occupyCell(spawn);
if (sprite.visible) {
Actor.addDelayed(new Pushing(spawn, pos, spawn.pos), -1);
Actor.add(new Pushing(spawn, pos, spawn.pos));
}
spawnCooldown += 60;

View File

@@ -131,7 +131,7 @@ public class Ghoul extends Mob {
Dungeon.level.occupyCell(child);
if (sprite.visible) {
Actor.addDelayed( new Pushing( child, pos, child.pos ), -1 );
Actor.add( new Pushing( child, pos, child.pos ) );
}
for (Buff b : buffs(ChampionEnemy.class)){
@@ -277,7 +277,7 @@ public class Ghoul extends Mob {
}
if (candidates.size() > 0) {
int newPos = Random.element( candidates );
Actor.addDelayed( new Pushing( ghoul, ghoul.pos, newPos ), -1 );
Actor.add( new Pushing( ghoul, ghoul.pos, newPos ) );
ghoul.pos = newPos;
} else {

View File

@@ -101,11 +101,11 @@ public class Guard extends Mob {
Effects.Type.CHAIN,
new Callback() {
public void call() {
Actor.addDelayed(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {
Actor.add(new Pushing(enemy, enemy.pos, newPosFinal, new Callback() {
public void call() {
pullEnemy(enemy, newPosFinal);
}
}), -1);
}));
next();
}
}));

View File

@@ -202,7 +202,7 @@ public class Necromancer extends Mob {
//push enemy, or wait a turn if there is no valid pushing position
if (pushPos != pos) {
Char ch = Actor.findChar(summoningPos);
Actor.addDelayed( new Pushing( ch, ch.pos, pushPos ), -1 );
Actor.add( new Pushing( ch, ch.pos, pushPos ) );
ch.pos = pushPos;
Dungeon.level.occupyCell(ch );

View File

@@ -187,7 +187,7 @@ public class RipperDemon extends Mob {
}
if (endPos != leapPos){
Actor.addDelayed(new Pushing(RipperDemon.this, leapPos, endPos), -1);
Actor.add(new Pushing(RipperDemon.this, leapPos, endPos));
}
pos = endPos;

View File

@@ -125,7 +125,7 @@ public class SpectralNecromancer extends Necromancer {
//push enemy, or wait a turn if there is no valid pushing position
if (pushPos != pos) {
Char ch = Actor.findChar(summoningPos);
Actor.addDelayed( new Pushing( ch, ch.pos, pushPos ), -1 );
Actor.add( new Pushing( ch, ch.pos, pushPos ) );
ch.pos = pushPos;
Dungeon.level.occupyCell(ch );

View File

@@ -104,7 +104,7 @@ public class Swarm extends Mob {
GameScene.add( clone, SPLIT_DELAY ); //we add before assigning HP due to ascension
clone.HP = (HP - damage) / 2;
Actor.addDelayed( new Pushing( clone, pos, clone.pos ), -1 );
Actor.add( new Pushing( clone, pos, clone.pos ) );
Dungeon.level.occupyCell(clone);

View File

@@ -334,7 +334,7 @@ public class YogDzewa extends Mob {
if (spawnPos != -1) {
summon.pos = spawnPos;
GameScene.add( summon );
Actor.addDelayed( new Pushing( summon, pos, summon.pos ), -1 );
Actor.add( new Pushing( summon, pos, summon.pos ) );
summon.beckon(Dungeon.hero.pos);
Dungeon.level.occupyCell(summon);
@@ -453,7 +453,7 @@ public class YogDzewa extends Mob {
}
GameScene.add(fist, 4);
Actor.addDelayed( new Pushing( fist, Dungeon.level.exit(), fist.pos ), -1 );
Actor.add( new Pushing( fist, Dungeon.level.exit(), fist.pos ) );
Dungeon.level.occupyCell(fist);
}

View File

@@ -42,7 +42,7 @@ public class Pushing extends Actor {
private Callback callback;
{
actPriority = VFX_PRIO;
actPriority = VFX_PRIO+10;
}
public Pushing( Char ch, int from, int to ) {

View File

@@ -76,15 +76,20 @@ public class Amulet extends Item {
Statistics.amuletObtained = true;
hero.spend(-TIME_TO_PICK_UP);
//add a delayed actor here so pickup behaviour can fully process.
Actor.addDelayed(new Actor(){
//delay with an actor here so pickup behaviour can fully process.
Actor.add(new Actor(){
{
actPriority = VFX_PRIO;
}
@Override
protected boolean act() {
Actor.remove(this);
showAmuletScene( true );
return false;
}
}, -5);
});
}
return true;

View File

@@ -120,7 +120,7 @@ public class Honeypot extends Item {
bee.pos = newPos;
GameScene.add( bee );
if (newPos != pos) Actor.addDelayed( new Pushing( bee, pos, newPos ), -1f );
if (newPos != pos) Actor.add( new Pushing( bee, pos, newPos ) );
bee.sprite.alpha( 0 );
bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) );

View File

@@ -132,7 +132,7 @@ public class BeaconOfReturning extends Spell {
if (toPush == hero){
returnPos = candidates.get(0);
} else {
Actor.addDelayed( new Pushing( toPush, toPush.pos, candidates.get(0) ), -1 );
Actor.add( new Pushing( toPush, toPush.pos, candidates.get(0) ) );
toPush.pos = candidates.get(0);
Dungeon.level.occupyCell(toPush);
}

View File

@@ -149,7 +149,7 @@ public class WandOfBlastWave extends DamageWand {
final boolean finalCollided = collided && collideDmg;
final int initialpos = ch.pos;
Actor.addDelayed(new Pushing(ch, ch.pos, newPos, new Callback() {
Actor.add(new Pushing(ch, ch.pos, newPos, new Callback() {
public void call() {
if (initialpos != ch.pos || Actor.findChar(newPos) != null) {
//something caused movement or added chars before pushing resolved, cancel to be safe.
@@ -178,7 +178,7 @@ public class WandOfBlastWave extends DamageWand {
GameScene.updateFog();
}
}
}), -1);
}));
}
@Override
@@ -186,9 +186,9 @@ public class WandOfBlastWave extends DamageWand {
//acts like elastic enchantment
//we delay this with an actor to prevent conflicts with regular elastic
//so elastic always fully resolves first, then this effect activates
Actor.addDelayed(new Actor() {
Actor.add(new Actor() {
{
actPriority = VFX_PRIO-1; //act after pushing effects
actPriority = VFX_PRIO+9; //act after pushing effects
}
@Override
@@ -199,7 +199,7 @@ public class WandOfBlastWave extends DamageWand {
}
return true;
}
}, -1);
});
}
private static class BlastWaveOnHit extends Elastic{

View File

@@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FlockTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.GatewayTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.OozeTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PitfallTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ShockingTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.TeleportationTrap;
@@ -99,7 +100,7 @@ public class SewerLevel extends RegularLevel {
@Override
protected Class<?>[] trapClasses() {
return Dungeon.depth == 1 ?
new Class<?>[]{ WornDartTrap.class } :
new Class<?>[]{ PitfallTrap.class } :
new Class<?>[]{
ChillingTrap.class, ShockingTrap.class, ToxicTrap.class, WornDartTrap.class,
AlarmTrap.class, OozeTrap.class,

View File

@@ -55,6 +55,7 @@ public class PitfallTrap extends Trap {
DelayedPit p = Buff.append(Dungeon.hero, DelayedPit.class, 1);
p.depth = Dungeon.depth;
p.branch = Dungeon.branch;
p.pos = pos;
for (int i : PathFinder.NEIGHBOURS9){