🔥🔥🔥🔥🔥🔥maximum breakage
This commit is contained in:
@@ -1,20 +1,28 @@
|
||||
package io.anuke.mindustry;
|
||||
|
||||
import io.anuke.arc.ApplicationListener;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.Settings;
|
||||
import io.anuke.arc.utils.Log;
|
||||
import io.anuke.arc.utils.Time;
|
||||
import io.anuke.arc.utils.TimeUtils;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.EventType.GameLoadEvent;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.modules.ModuleCore;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mindustry extends ModuleCore{
|
||||
public class Mindustry implements ApplicationListener{
|
||||
private long lastFrameTime;
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
Timers.mark();
|
||||
public Mindustry(){
|
||||
Time.setDeltaProvider(() -> {
|
||||
float result = Core.graphics.getDeltaTime() * 60f;
|
||||
return Float.isNaN(result) || Float.isInfinite(result) ? 1f : Math.min(result, 60f / 10f);
|
||||
});
|
||||
|
||||
Time.mark();
|
||||
|
||||
Vars.init();
|
||||
|
||||
@@ -22,26 +30,40 @@ public class Mindustry extends ModuleCore{
|
||||
BundleLoader.load();
|
||||
content.load();
|
||||
|
||||
module(logic = new Logic());
|
||||
module(world = new World());
|
||||
module(control = new Control());
|
||||
module(renderer = new Renderer());
|
||||
module(ui = new UI());
|
||||
module(netServer = new NetServer());
|
||||
module(netClient = new NetClient());
|
||||
Core.app.addListener(logic = new Logic());
|
||||
Core.app.addListener(world = new World());
|
||||
Core.app.addListener(control = new Control());
|
||||
Core.app.addListener(renderer = new Renderer());
|
||||
Core.app.addListener(ui = new UI());
|
||||
Core.app.addListener(netServer = new NetServer());
|
||||
Core.app.addListener(netClient = new NetClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(){
|
||||
Log.info("Time to load [total]: {0}", Timers.elapsed());
|
||||
public void init(){
|
||||
Log.info("Time to load [total]: {0}", Time.elapsed());
|
||||
Events.fire(new GameLoadEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(){
|
||||
threads.handleBeginRender();
|
||||
super.render();
|
||||
threads.handleEndRender();
|
||||
public void update(){
|
||||
lastFrameTime = TimeUtils.millis();
|
||||
|
||||
//TODO ??render it all??
|
||||
|
||||
int fpsCap = Core.settings.getInt("fpscap", 125);
|
||||
|
||||
if(fpsCap <= 120){
|
||||
long target = 1000/fpsCap;
|
||||
long elapsed = TimeUtils.timeSinceMillis(lastFrameTime);
|
||||
if(elapsed < target){
|
||||
try{
|
||||
Thread.sleep(target - elapsed);
|
||||
}catch(InterruptedException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user