From fbddc0abc94d65be49f5c7275a96b766416d79fc Mon Sep 17 00:00:00 2001 From: MEEP of Faith <54301439+MEEPofFaith@users.noreply.github.com> Date: Fri, 16 Apr 2021 17:57:40 -0700 Subject: [PATCH] Turn MiningRange into a UnitType variable. (#5112) * Turn MiningRange into a UnitType variable. Long range mining go brrrrr * Anuke Approved --- core/src/mindustry/Vars.java | 2 -- core/src/mindustry/ai/types/MinerAI.java | 6 +++--- core/src/mindustry/entities/comp/MinerComp.java | 2 +- core/src/mindustry/type/UnitType.java | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 45e3606c8e..d9a2632c42 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -82,8 +82,6 @@ public class Vars implements Loadable{ public static final float itemSize = 5f; /** units outside of this bound will die instantly */ public static final float finalWorldBounds = 500; - /** mining range for manual miners */ - public static final float miningRange = 70f; /** range for building */ public static final float buildingRange = 220f; /** range for moving items */ diff --git a/core/src/mindustry/ai/types/MinerAI.java b/core/src/mindustry/ai/types/MinerAI.java index 28306deb84..fbf7cf5526 100644 --- a/core/src/mindustry/ai/types/MinerAI.java +++ b/core/src/mindustry/ai/types/MinerAI.java @@ -19,7 +19,7 @@ public class MinerAI extends AIController{ if(!(unit.canMine()) || core == null) return; - if(unit.mineTile != null && !unit.mineTile.within(unit, unit.type.range)){ + if(unit.mineTile != null && !unit.mineTile.within(unit, unit.type.miningRange)){ unit.mineTile(null); } @@ -44,9 +44,9 @@ public class MinerAI extends AIController{ } if(ore != null){ - moveTo(ore, unit.type.range / 2f, 20f); + moveTo(ore, unit.type.miningRange / 2f, 20f); - if(unit.within(ore, unit.type.range)){ + if(unit.within(ore, unit.type.miningRange)){ unit.mineTile = ore; } diff --git a/core/src/mindustry/entities/comp/MinerComp.java b/core/src/mindustry/entities/comp/MinerComp.java index 1faabadef8..83b4b2a709 100644 --- a/core/src/mindustry/entities/comp/MinerComp.java +++ b/core/src/mindustry/entities/comp/MinerComp.java @@ -36,7 +36,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{ } public boolean validMine(Tile tile, boolean checkDst){ - return !(tile == null || tile.block() != Blocks.air || (!within(tile.worldx(), tile.worldy(), miningRange) && checkDst) + return !(tile == null || tile.block() != Blocks.air || (!within(tile.worldx(), tile.worldy(), type.miningRange) && checkDst) || tile.drop() == null || !canMine(tile.drop())); } diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 6fed083de9..f3a511b539 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -44,7 +44,7 @@ public class UnitType extends UnlockableContent{ public Prov defaultController = () -> !flying ? new GroundAI() : new FlyingAI(); public float speed = 1.1f, boostMultiplier = 1f, rotateSpeed = 5f, baseRotateSpeed = 5f; public float drag = 0.3f, accel = 0.5f, landShake = 0f, rippleScale = 1f, riseSpeed = 0.08f, fallSpeed = 0.018f; - public float health = 200f, range = -1, armor = 0f, maxRange = -1f; + public float health = 200f, range = -1, miningRange = 70f, armor = 0f, maxRange = -1f; public float crashDamageMultiplier = 1f; public boolean targetAir = true, targetGround = true; public boolean faceTarget = true, rotateShooting = true, isCounted = true, lowAltitude = false, circleTarget = false;