This commit is contained in:
Anuken
2020-05-02 23:15:36 -04:00
parent cb6920b8be
commit dd68241d1f
7 changed files with 40 additions and 21 deletions

View File

@@ -41,27 +41,31 @@ public class AsyncLogic{
} }
public void begin(){ public void begin(){
//sync begin if(Vars.state.isPlaying()){
for(AsyncProcess p : processes){ //sync begin
p.begin(); for(AsyncProcess p : processes){
} p.begin();
}
futures.clear(); futures.clear();
//submit all tasks //submit all tasks
for(AsyncProcess p : processes){ for(AsyncProcess p : processes){
if(p.shouldProcess()){ if(p.shouldProcess()){
futures.add(executor.submit(p::process)); futures.add(executor.submit(p::process));
}
} }
} }
} }
public void end(){ public void end(){
complete(); if(Vars.state.isPlaying()){
complete();
//sync end (flush data) //sync end (flush data)
for(AsyncProcess p : processes){ for(AsyncProcess p : processes){
p.end(); p.end();
}
} }
} }

View File

@@ -96,7 +96,7 @@ public class PhysicsProcess implements AsyncProcess{
ref.lastVelocity.set(ref.velocity); ref.lastVelocity.set(ref.velocity);
} }
physics.step(Core.graphics.getDeltaTime(), 8, 8); physics.step(Core.graphics.getDeltaTime(), 5, 8);
//get delta vectors //get delta vectors
for(PhysicRef ref : refs){ for(PhysicRef ref : refs){
@@ -121,7 +121,7 @@ public class PhysicsProcess implements AsyncProcess{
ref.position.set(entity); ref.position.set(entity);
//add delta velocity - this doesn't work very well yet //add delta velocity - this doesn't work very well yet
//entity.vel().add(ref.velocity).sub(ref.lastVelocity); entity.vel().add(ref.velocity).sub(ref.lastVelocity);
} }
} }

View File

@@ -61,6 +61,10 @@ public class GameState{
return (is(State.paused) && !net.active()) || (gameOver && !net.active()); return (is(State.paused) && !net.active()) || (gameOver && !net.active());
} }
public boolean isPlaying(){
return state == State.playing;
}
/** @return whether the current state is *not* the menu. */ /** @return whether the current state is *not* the menu. */
public boolean isGame(){ public boolean isGame(){
return state != State.menu; return state != State.menu;

View File

@@ -44,17 +44,26 @@ public class Units{
} }
/** Returns whether there are any entities on this tile. */ /** Returns whether there are any entities on this tile. */
public static boolean anyEntities(Tile tile){ public static boolean anyEntities(Tile tile, boolean ground){
float size = tile.block().size * tilesize; float size = tile.block().size * tilesize;
return anyEntities(tile.drawx() - size/2f, tile.drawy() - size/2f, size, size); return anyEntities(tile.drawx() - size/2f, tile.drawy() - size/2f, size, size, ground);
}
/** Returns whether there are any entities on this tile. */
public static boolean anyEntities(Tile tile){
return anyEntities(tile, true);
} }
public static boolean anyEntities(float x, float y, float width, float height){ public static boolean anyEntities(float x, float y, float width, float height){
return anyEntities(x, y, width, height, true);
}
public static boolean anyEntities(float x, float y, float width, float height, boolean ground){
boolResult = false; boolResult = false;
nearby(x, y, width, height, unit -> { nearby(x, y, width, height, unit -> {
if(boolResult) return; if(boolResult) return;
if(unit.isGrounded()){ if(unit.isGrounded() == ground){
unit.hitbox(hitrect); unit.hitbox(hitrect);
if(hitrect.overlaps(x, y, width, height)){ if(hitrect.overlaps(x, y, width, height)){

View File

@@ -39,7 +39,7 @@ abstract class CommanderComp implements Unitc{
//make sure to reset command state when the controller is switched //make sure to reset command state when the controller is switched
@Override @Override
public void controller(UnitController unitController){ public void controller(UnitController next){
clearCommand(); clearCommand();
} }

View File

@@ -222,13 +222,15 @@ public class UnitFactory extends Block{
if(currentPlan != -1){ if(currentPlan != -1){
UnitPlan plan = plans[currentPlan]; UnitPlan plan = plans[currentPlan];
if(progress >= plan.time){ if(progress >= plan.time/* && !Units.anyEntities(tile, !plan.unit.flying)*/){
progress = 0f; progress = 0f;
Call.onUnitFactorySpawn(tile); Call.onUnitFactorySpawn(tile);
useContent(plan.unit); useContent(plan.unit);
consume(); consume();
} }
progress = Mathf.clamp(progress, 0, plan.time);
}else{ }else{
progress = 0f; progress = 0f;
} }

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=98e63e76cb6b5c925531ae5518b5182522def509 archash=6069cba645e3d301a6bf4169182bb191f562b4da