From 611115e55b7ccf2c0cd6fc90cf31ac136ef4a1a6 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 19 May 2020 21:19:04 -0400 Subject: [PATCH] Better flying unit support --- core/src/mindustry/content/UnitTypes.java | 8 ++- core/src/mindustry/graphics/Layer.java | 2 +- core/src/mindustry/input/DesktopInput.java | 64 +--------------------- 3 files changed, 8 insertions(+), 66 deletions(-) diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index f912639f1d..6d2d1e4a08 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -133,10 +133,12 @@ public class UnitTypes implements ContentList{ mass = 1.5f; flying = true; health = 75; + faceTarget = false; engineOffset = 5.5f; range = 140f; weapons.add(new Weapon(){{ - y = 1.5f; + y = 0f; + x = 2f; reload = 15f; alternate = true; ejectEffect = Fx.shellEjectSmall; @@ -157,13 +159,13 @@ public class UnitTypes implements ContentList{ range = 140f; faceTarget = false; weapons.add(new Weapon(){{ + x = 3f; shootY = 0f; - shootX = 0f; reload = 6f; shootCone = 180f; alternate = true; ejectEffect = Fx.none; - inaccuracy = 40f; + inaccuracy = 15f; ignoreRotation = true; bullet = Bullets.bombExplosive; shootSound = Sounds.none; diff --git a/core/src/mindustry/graphics/Layer.java b/core/src/mindustry/graphics/Layer.java index 8e40b8ffa8..92a4e8268d 100644 --- a/core/src/mindustry/graphics/Layer.java +++ b/core/src/mindustry/graphics/Layer.java @@ -42,7 +42,7 @@ public class Layer{ plans = 85, //flying units - flyingUnit = 90, + flyingUnit = 115, //bullets *bloom begin* bullet = 100, diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index fdf1cb6a95..df9ced7d8a 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -587,68 +587,8 @@ public class DesktopInput extends InputHandler{ } } - unit.aim(Core.input.mouseWorld()); + unit.aim(unit.type().faceTarget ? Core.input.mouseWorld() : Tmp.v1.trns(unit.rotation(), Core.input.mouseWorld().dst(unit)).add(unit.x(), unit.y())); + unit.controlWeapons(true, isShooting); - /* - Tile tile = unit.tileOn(); - boolean canMove = !Core.scene.hasKeyboard() || ui.minimapfrag.shown(); - - //TODO implement - boolean isBoosting = Core.input.keyDown(Binding.dash) && !mech.flying; - - //if player is in solid block - if(tile != null && tile.solid()){ - isBoosting = true; - } - - float speed = isBoosting && unit.type().flying ? mech.boostSpeed : mech.speed; - - if(mech.flying){ - //prevent strafing backwards, have a penalty for doing so - float penalty = 0.2f; //when going 180 degrees backwards, reduce speed to 0.2x - speed *= Mathf.lerp(1f, penalty, Angles.angleDist(rotation, velocity.angle()) / 180f); - } - - movement.setZero(); - - float xa = Core.input.axis(Binding.move_x); - float ya = Core.input.axis(Binding.move_y); - if(!(Core.scene.getKeyboardFocus() instanceof TextField)){ - movement.y += ya * speed; - movement.x += xa * speed; - } - - if(Core.input.keyDown(Binding.mouse_move)){ - movement.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * speed; - movement.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * speed; - } - - Vec2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY()); - pointerX = vec.x; - pointerY = vec.y; - updateShooting(); - - movement.limit(speed).scl(Time.delta()); - - if(canMove){ - velocity.add(movement.x, movement.y); - }else{ - isShooting = false; - } - float prex = x, prey = y; - updateVelocityStatus(); - moved = dst(prex, prey) > 0.001f; - - if(canMove){ - float baseLerp = mech.getRotationAlpha(this); - if(!isShooting() || !mech.faceTarget){ - if(!movement.isZero()){ - rotation = Mathf.slerpDelta(rotation, mech.flying ? velocity.angle() : movement.angle(), 0.13f * baseLerp); - } - }else{ - float angle = control.input.mouseAngle(x, y); - this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f * baseLerp); - } - }*/ } }