v1.4.0: waiting now always takes exactly 1 turn, regardless of speed mod

This commit is contained in:
Evan Debenham
2022-08-02 13:13:28 -04:00
parent adc33890f8
commit 630bc0291d
2 changed files with 18 additions and 7 deletions
@@ -54,8 +54,9 @@ public abstract class Actor implements Bundlable {
protected int actPriority = DEFAULT; protected int actPriority = DEFAULT;
protected abstract boolean act(); protected abstract boolean act();
protected void spend( float time ) { //Always spends exactly one tick, regardless of time-influencing factors
protected final void spendConstant( float time ){
this.time += time; this.time += time;
//if time is very close to a whole number, round to a whole number to fix errors //if time is very close to a whole number, round to a whole number to fix errors
float ex = Math.abs(this.time % 1f); float ex = Math.abs(this.time % 1f);
@@ -64,6 +65,11 @@ public abstract class Actor implements Bundlable {
} }
} }
//can be overridden for time to be affected by various factors
protected void spend( float time ) {
spendConstant( time );
}
public void spendToWhole(){ public void spendToWhole(){
time = (float)Math.ceil(time); time = (float)Math.ceil(time);
} }
@@ -641,7 +641,13 @@ public class Hero extends Char {
super.spend(time); super.spend(time);
} }
public void spendAndNextConstant( float time ) {
busy();
spendConstant( time );
next();
}
public void spendAndNext( float time ) { public void spendAndNext( float time ) {
busy(); busy();
spend( time ); spend( time );
@@ -683,7 +689,7 @@ public class Hero extends Char {
if (curAction == null) { if (curAction == null) {
if (resting) { if (resting) {
spend( TIME_TO_REST ); spendConstant( TIME_TO_REST );
next(); next();
} else { } else {
ready(); ready();
@@ -893,9 +899,8 @@ public class Hero extends Char {
curAction = null; curAction = null;
} else { } else {
//
if (waitOrPickup) { if (waitOrPickup) {
spendAndNext(TIME_TO_REST); spendAndNextConstant(TIME_TO_REST);
//allow the hero to move between levels even if they can't collect the item //allow the hero to move between levels even if they can't collect the item
} else if (Dungeon.level.getTransition(pos) != null){ } else if (Dungeon.level.getTransition(pos) != null){
@@ -1140,7 +1145,7 @@ public class Hero extends Char {
} }
public void rest( boolean fullRest ) { public void rest( boolean fullRest ) {
spendAndNext( TIME_TO_REST ); spendAndNextConstant( TIME_TO_REST );
if (!fullRest) { if (!fullRest) {
if (hasTalent(Talent.HOLD_FAST)){ if (hasTalent(Talent.HOLD_FAST)){
Buff.affect(this, HoldFast.class); Buff.affect(this, HoldFast.class);