v0.7.1: adjusted some specific elements of how the game handles time
This commit is contained in:
parent
738a0e91e3
commit
bf5e12e9d3
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,22 +133,26 @@ public abstract class Actor implements Bundlable {
|
|||
|
||||
ids.clear();
|
||||
}
|
||||
|
||||
|
||||
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); }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user