mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 02:37:12 +07:00
cleanup
This commit is contained in:
parent
dd68241d1f
commit
50e8586dc2
@ -0,0 +1 @@
|
||||
{fields:[{name:elevation,type:float,size:4},{name:health,type:float,size:4},{name:rotation,type:float,size:4},{name:shield,type:float,size:4},{name:team,type:mindustry.game.Team,size:-1},{name:type,type:mindustry.type.UnitType,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}
|
@ -7,17 +7,19 @@ import mindustry.game.EventType.*;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static mindustry.Vars.state;
|
||||
|
||||
public class AsyncLogic{
|
||||
//all processes to be executed each frame
|
||||
private Array<AsyncProcess> processes = Array.with(
|
||||
private final Array<AsyncProcess> processes = Array.with(
|
||||
new PhysicsProcess(),
|
||||
Vars.teamIndex = new TeamIndexProcess()
|
||||
);
|
||||
|
||||
//futures to be awaited
|
||||
private Array<Future<?>> futures = new Array<>();
|
||||
private final Array<Future<?>> futures = new Array<>();
|
||||
|
||||
private ExecutorService executor = Executors.newFixedThreadPool(processes.size, r -> {
|
||||
private final ExecutorService executor = Executors.newFixedThreadPool(processes.size, r -> {
|
||||
Thread thread = new Thread(r, "AsyncLogic-Thread");
|
||||
thread.setDaemon(true);
|
||||
thread.setUncaughtExceptionHandler((t, e) -> Core.app.post(() -> { throw new RuntimeException(e); }));
|
||||
@ -41,7 +43,7 @@ public class AsyncLogic{
|
||||
}
|
||||
|
||||
public void begin(){
|
||||
if(Vars.state.isPlaying()){
|
||||
if(state.isPlaying()){
|
||||
//sync begin
|
||||
for(AsyncProcess p : processes){
|
||||
p.begin();
|
||||
@ -59,7 +61,7 @@ public class AsyncLogic{
|
||||
}
|
||||
|
||||
public void end(){
|
||||
if(Vars.state.isPlaying()){
|
||||
if(state.isPlaying()){
|
||||
complete();
|
||||
|
||||
//sync end (flush data)
|
||||
|
Loading…
Reference in New Issue
Block a user