v0.7.1: adjusted some specific elements of how the game handles time

This commit is contained in:
Evan Debenham 2018-12-15 14:03:32 -05:00 committed by Evan Debenham
parent 738a0e91e3
commit bf5e12e9d3

View File

@ -59,11 +59,21 @@ public abstract class Actor implements Bundlable {
protected void spend( float time ) {
this.time += time;
//if time is very close to a whole number, round to a whole number to fix errors
float ex = Math.abs(this.time % 1f);
if (ex < .001f){
this.time = Math.round(this.time);
}
}
protected void postpone( float time ) {
if (this.time < now + time) {
this.time = now + time;
//if time is very close to a whole number, round to a whole number to fix errors
float ex = Math.abs(this.time % 1f);
if (ex < .001f){
this.time = Math.round(this.time);
}
}
}
@ -126,19 +136,23 @@ public abstract class Actor implements Bundlable {
public static synchronized void fixTime() {
if (Dungeon.hero != null && all.contains( Dungeon.hero )) {
Statistics.duration += now;
}
float min = Float.MAX_VALUE;
for (Actor a : all) {
if (a.time < min) {
min = a.time;
}
}
//Only pull everything back by whole numbers
//So that turns always align with a whole number
min = (int)min;
for (Actor a : all) {
a.time -= min;
}
if (Dungeon.hero != null && all.contains( Dungeon.hero )) {
Statistics.duration += (int)now;
}
now = 0;
}
@ -320,8 +334,8 @@ public abstract class Actor implements Bundlable {
}
public static synchronized HashSet<Actor> all() {
return new HashSet<Actor>(all);
return new HashSet<>(all);
}
public static synchronized HashSet<Char> chars() { return new HashSet<Char>(chars); }
public static synchronized HashSet<Char> chars() { return new HashSet<>(chars); }
}