Universe time + Progress on solar system framework

This commit is contained in:
Anuken
2020-02-28 20:21:00 -05:00
10 changed files with 184 additions and 17 deletions

View File

@@ -0,0 +1,48 @@
package mindustry.game;
import arc.*;
import arc.util.*;
public class Universe{
private long seconds;
private float secondCounter;
public Universe(){
load();
}
public void update(){
secondCounter += Time.delta() / 60f;
if(secondCounter >= 1){
seconds += (int)secondCounter;
secondCounter %= 1f;
//save every few seconds
if(seconds % 10 == 1){
save();
}
}
}
public float secondsMod(float mod, float scale){
return (seconds / scale) % mod;
}
public long seconds(){
return seconds;
}
public float secondsf(){
return seconds + secondCounter;
}
private void save(){
Core.settings.put("utime", seconds);
Core.settings.save();
}
private void load(){
seconds = Core.settings.getLong("utime");
}
}