This commit is contained in:
Anuken 2020-05-03 00:49:34 -04:00
parent dd68241d1f
commit 50e8586dc2
2 changed files with 8 additions and 5 deletions

View File

@ -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}]}

View File

@ -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)