From a732237005c06329cd777ee9016d1891af892fef Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 22 Oct 2020 09:43:21 -0400 Subject: [PATCH] Allowed enemy spawns on water --- core/src/mindustry/ai/types/FormationAI.java | 10 ++++++---- core/src/mindustry/content/Blocks.java | 1 + core/src/mindustry/editor/EditorTile.java | 4 ++-- core/src/mindustry/editor/EditorTool.java | 2 +- core/src/mindustry/editor/MapGenerateDialog.java | 2 +- core/src/mindustry/entities/comp/MinerComp.java | 4 ++-- core/src/mindustry/input/DesktopInput.java | 2 +- core/src/mindustry/input/MobileInput.java | 2 +- core/src/mindustry/world/blocks/environment/Floor.java | 2 ++ gradle.properties | 2 +- 10 files changed, 18 insertions(+), 13 deletions(-) diff --git a/core/src/mindustry/ai/types/FormationAI.java b/core/src/mindustry/ai/types/FormationAI.java index 3226fbc300..3c5a2b99b4 100644 --- a/core/src/mindustry/ai/types/FormationAI.java +++ b/core/src/mindustry/ai/types/FormationAI.java @@ -34,8 +34,8 @@ public class FormationAI extends AIController implements FormationMember{ return; } - if(unit.type.canBoost && unit.canPassOn()){ - unit.elevation = Mathf.approachDelta(unit.elevation, 0f, 0.08f); + if(unit.type.canBoost){ + unit.elevation = Mathf.approachDelta(unit.elevation, !unit.canPassOn() ? 1f : leader.type.canBoost ? leader.elevation : 0f, 0.08f); } unit.controlWeapons(true, leader.isShooting); @@ -53,10 +53,12 @@ public class FormationAI extends AIController implements FormationMember{ float margin = 3f; + float speed = unit.realSpeed(); + if(unit.dst(realtarget) <= margin){ - unit.vel.approachDelta(Vec2.ZERO, type.speed * type.accel / 2f); + unit.vel.approachDelta(Vec2.ZERO, speed * type.accel / 2f); }else{ - unit.moveAt(realtarget.sub(unit).limit(type.speed)); + unit.moveAt(realtarget.sub(unit).limit(speed)); } if(unit instanceof Minerc mine && leader instanceof Minerc com){ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index ad024618ab..1ab4e13252 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -121,6 +121,7 @@ public class Blocks implements ContentList{ spawn = new OverlayFloor("spawn"){ { variants = 0; + needsSurface = false; } @Override public void drawBase(Tile tile){} diff --git a/core/src/mindustry/editor/EditorTile.java b/core/src/mindustry/editor/EditorTile.java index 2d08b9d3d2..f735bd790c 100644 --- a/core/src/mindustry/editor/EditorTile.java +++ b/core/src/mindustry/editor/EditorTile.java @@ -26,7 +26,7 @@ public class EditorTile extends Tile{ if(type instanceof OverlayFloor){ //don't place on liquids - if(floor.hasSurface()){ + if(floor.hasSurface() || !type.needsSurface){ setOverlayID(type.id); } return; @@ -75,7 +75,7 @@ public class EditorTile extends Tile{ return; } - if(floor.isLiquid) return; + if(!floor.hasSurface() && overlay.asFloor().needsSurface) return; if(overlay() == overlay) return; op(OpType.overlay, this.overlay.id); super.setOverlay(overlay); diff --git a/core/src/mindustry/editor/EditorTool.java b/core/src/mindustry/editor/EditorTool.java index 194ec97e4c..cd4b63935e 100644 --- a/core/src/mindustry/editor/EditorTool.java +++ b/core/src/mindustry/editor/EditorTool.java @@ -118,7 +118,7 @@ public enum EditorTool{ if(editor.drawBlock.isOverlay()){ Block dest = tile.overlay(); if(dest == editor.drawBlock) return; - tester = t -> t.overlay() == dest && t.floor().hasSurface(); + tester = t -> t.overlay() == dest && (t.floor().hasSurface() || !t.floor().needsSurface); setter = t -> t.setOverlay(editor.drawBlock); }else if(editor.drawBlock.isFloor()){ Block dest = tile.floor(); diff --git a/core/src/mindustry/editor/MapGenerateDialog.java b/core/src/mindustry/editor/MapGenerateDialog.java index 6a06e0b966..c0292cbf74 100644 --- a/core/src/mindustry/editor/MapGenerateDialog.java +++ b/core/src/mindustry/editor/MapGenerateDialog.java @@ -417,7 +417,7 @@ public class MapGenerateDialog extends BaseDialog{ public void set(Block floor, Block wall, Block ore, Team team){ this.floor = floor.id; this.block = wall.id; - this.ore = !floor.asFloor().hasSurface() ? 0 : ore.id; + this.ore = (!floor.asFloor().hasSurface() && ore.asFloor().needsSurface) ? 0 : ore.id; this.team = (byte)team.id; } diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 6bac9dbd60..764e6ed4d3 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -54,7 +54,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ } } - if(core == null || !validMine(mineTile)){ + if(!validMine(mineTile)){ mineTile = null; mineTimer = 0f; }else if(mining()){ @@ -69,7 +69,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc, Unitc{ if(mineTimer >= 50f + item.hardness*15f){ mineTimer = 0; - if(within(core, mineTransferRange) && core.acceptStack(item, 1, this) == 1 && offloadImmediately()){ + if(core != null && within(core, mineTransferRange) && core.acceptStack(item, 1, this) == 1 && offloadImmediately()){ Call.transferItemTo(item, 1, mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), core); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 906d96d56e..049853c864 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -610,7 +610,7 @@ public class DesktopInput extends InputHandler{ baseSpeed = unit.minFormationSpeed * 0.95f; } - float speed = baseSpeed * Mathf.lerp(1f, unit.isCommanding() ? 1f : unit.type.canBoost ? unit.type.boostMultiplier : 1f, unit.elevation) * strafePenalty; + float speed = baseSpeed * Mathf.lerp(1f, unit.type.canBoost ? unit.type.boostMultiplier : 1f, unit.elevation) * strafePenalty; float xa = Core.input.axis(Binding.move_x); float ya = Core.input.axis(Binding.move_y); boolean boosted = (unit instanceof Mechc && unit.isFlying()); diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 981f55bd6f..63df6c151b 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -865,7 +865,7 @@ public class MobileInput extends InputHandler implements GestureListener{ baseSpeed = unit.minFormationSpeed * 0.98f; } - float speed = baseSpeed * Mathf.lerp(1f, unit.isCommanding() ? 1f : type.canBoost ? type.boostMultiplier : 1f, unit.elevation) * strafePenalty; + float speed = baseSpeed * Mathf.lerp(1f, type.canBoost ? type.boostMultiplier : 1f, unit.elevation) * strafePenalty; float range = unit.hasWeapons() ? unit.range() : 0f; float bulletSpeed = unit.hasWeapons() ? type.weapons.first().bullet.speed : 0f; float mouseAngle = unit.angleTo(unit.aimX(), unit.aimY()); diff --git a/core/src/mindustry/world/blocks/environment/Floor.java b/core/src/mindustry/world/blocks/environment/Floor.java index cacf375cef..113617cc63 100644 --- a/core/src/mindustry/world/blocks/environment/Floor.java +++ b/core/src/mindustry/world/blocks/environment/Floor.java @@ -64,6 +64,8 @@ public class Floor extends Block{ public Block wall = Blocks.air; /** Decoration block. Usually a rock. May be air. */ public Block decoration = Blocks.air; + /** Whether this overlay needs a surface to be on. False for floating blocks, like spawns. */ + public boolean needsSurface = true; protected TextureRegion[][] edges; protected Seq blenders = new Seq<>(); diff --git a/gradle.properties b/gradle.properties index fb827dd929..9506854088 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=b6e614dd1c272073a420aa946797118ea6b48324 +archash=3f883ca573d8b3132cab878c07487febecf1d4e2