From dd68241d1f351f3e7f5206d1687d199e1347e1d2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 2 May 2020 23:15:36 -0400 Subject: [PATCH] Bugfixes --- core/src/mindustry/async/AsyncLogic.java | 30 +++++++++++-------- core/src/mindustry/async/PhysicsProcess.java | 4 +-- core/src/mindustry/core/GameState.java | 4 +++ core/src/mindustry/entities/Units.java | 15 ++++++++-- .../mindustry/entities/def/CommanderComp.java | 2 +- .../world/blocks/units/UnitFactory.java | 4 ++- gradle.properties | 2 +- 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/core/src/mindustry/async/AsyncLogic.java b/core/src/mindustry/async/AsyncLogic.java index fac5784cc9..7820f86061 100644 --- a/core/src/mindustry/async/AsyncLogic.java +++ b/core/src/mindustry/async/AsyncLogic.java @@ -41,27 +41,31 @@ public class AsyncLogic{ } public void begin(){ - //sync begin - for(AsyncProcess p : processes){ - p.begin(); - } + if(Vars.state.isPlaying()){ + //sync begin + for(AsyncProcess p : processes){ + p.begin(); + } - futures.clear(); + futures.clear(); - //submit all tasks - for(AsyncProcess p : processes){ - if(p.shouldProcess()){ - futures.add(executor.submit(p::process)); + //submit all tasks + for(AsyncProcess p : processes){ + if(p.shouldProcess()){ + futures.add(executor.submit(p::process)); + } } } } public void end(){ - complete(); + if(Vars.state.isPlaying()){ + complete(); - //sync end (flush data) - for(AsyncProcess p : processes){ - p.end(); + //sync end (flush data) + for(AsyncProcess p : processes){ + p.end(); + } } } diff --git a/core/src/mindustry/async/PhysicsProcess.java b/core/src/mindustry/async/PhysicsProcess.java index c01007d3af..a4e38b3ea8 100644 --- a/core/src/mindustry/async/PhysicsProcess.java +++ b/core/src/mindustry/async/PhysicsProcess.java @@ -96,7 +96,7 @@ public class PhysicsProcess implements AsyncProcess{ ref.lastVelocity.set(ref.velocity); } - physics.step(Core.graphics.getDeltaTime(), 8, 8); + physics.step(Core.graphics.getDeltaTime(), 5, 8); //get delta vectors for(PhysicRef ref : refs){ @@ -121,7 +121,7 @@ public class PhysicsProcess implements AsyncProcess{ ref.position.set(entity); //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); } } diff --git a/core/src/mindustry/core/GameState.java b/core/src/mindustry/core/GameState.java index 6cd548ab6c..82c7d5142f 100644 --- a/core/src/mindustry/core/GameState.java +++ b/core/src/mindustry/core/GameState.java @@ -61,6 +61,10 @@ public class GameState{ 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. */ public boolean isGame(){ return state != State.menu; diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index c931c0f44f..fc6d297390 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -44,17 +44,26 @@ public class Units{ } /** 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; - 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){ + return anyEntities(x, y, width, height, true); + } + + public static boolean anyEntities(float x, float y, float width, float height, boolean ground){ boolResult = false; nearby(x, y, width, height, unit -> { if(boolResult) return; - if(unit.isGrounded()){ + if(unit.isGrounded() == ground){ unit.hitbox(hitrect); if(hitrect.overlaps(x, y, width, height)){ diff --git a/core/src/mindustry/entities/def/CommanderComp.java b/core/src/mindustry/entities/def/CommanderComp.java index 33390d490f..60e65980ce 100644 --- a/core/src/mindustry/entities/def/CommanderComp.java +++ b/core/src/mindustry/entities/def/CommanderComp.java @@ -39,7 +39,7 @@ abstract class CommanderComp implements Unitc{ //make sure to reset command state when the controller is switched @Override - public void controller(UnitController unitController){ + public void controller(UnitController next){ clearCommand(); } diff --git a/core/src/mindustry/world/blocks/units/UnitFactory.java b/core/src/mindustry/world/blocks/units/UnitFactory.java index cc3a264f77..ffac8638eb 100644 --- a/core/src/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/mindustry/world/blocks/units/UnitFactory.java @@ -222,13 +222,15 @@ public class UnitFactory extends Block{ if(currentPlan != -1){ UnitPlan plan = plans[currentPlan]; - if(progress >= plan.time){ + if(progress >= plan.time/* && !Units.anyEntities(tile, !plan.unit.flying)*/){ progress = 0f; Call.onUnitFactorySpawn(tile); useContent(plan.unit); consume(); } + + progress = Mathf.clamp(progress, 0, plan.time); }else{ progress = 0f; } diff --git a/gradle.properties b/gradle.properties index 5eae5fee32..68d4c5cf20 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=98e63e76cb6b5c925531ae5518b5182522def509 +archash=6069cba645e3d301a6bf4169182bb191f562b4da