From 7c507ce2f4bd9702252d044e4b590246fdfee8d6 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 11 Feb 2022 15:24:34 -0500 Subject: [PATCH] Misc turret progress --- core/src/mindustry/content/Blocks.java | 24 +++++++++++++------ core/src/mindustry/core/Control.java | 2 +- core/src/mindustry/core/UI.java | 2 +- core/src/mindustry/editor/MapView.java | 3 +-- .../entities/bullet/BasicBulletType.java | 14 +++++++---- core/src/mindustry/input/DesktopInput.java | 11 ++++----- .../mindustry/ui/fragments/HudFragment.java | 2 +- 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 40fa50920f..978b3b0434 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -3319,23 +3319,31 @@ public class Blocks{ requirements(Category.turret, with(Items.carbide, 250, Items.surgeAlloy, 160, Items.silicon, 300, Items.beryllium, 400)); ammo(Items.scrap, new BasicBulletType(){{ - damage = 40; + damage = 50; speed = 8.5f; - width = 11f; - height = 16f; + //width = 11f; + //height = 19f; + width = height = 17; + backSprite = "large-bomb-back"; + sprite = "mine-bullet"; trailColor = Pal.bulletYellowBack; velocityInaccuracy = 0.11f; collidesGround = false; collidesTiles = false; shootEffect = Fx.shootBig2; smokeEffect = Fx.shootBigSmoke2; - frontColor = Color.white; + frontColor = trailColor = Color.white; backColor = Color.valueOf("869cbe"); + trailInterval = 3; lifetime = 34f; + rotationOffset = 90f; + //spin = 360f; + //controversial - homingDelay = 10f; - homingPower = 0.01f; + //homingDelay = 10f; + //homingPower = 0.01f; + hitEffect = despawnEffect = Fx.hitBulletColor; }}); //TODO bullet. @@ -3357,7 +3365,7 @@ public class Blocks{ widthSpread = true; targetGround = false; spread = 4.6f; - inaccuracy = 9f; + inaccuracy = 8f; restitution = 0.1f; shootWarmupSpeed = 0.08f; @@ -3368,6 +3376,8 @@ public class Blocks{ scaledHealth = 340; range = 270f; size = 4; + + limitRange(4f); }}; //endregion diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index b66b55d903..973b127ef1 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -589,7 +589,7 @@ public class Control implements ApplicationListener, Loadable{ } } - if(!mobile && Core.input.keyTap(Binding.screenshot) && !(scene.getKeyboardFocus() instanceof TextField) && !scene.hasKeyboard()){ + if(!mobile && Core.input.keyTap(Binding.screenshot) && !scene.hasField() && !scene.hasKeyboard()){ renderer.takeMapScreenshot(); } diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index c349be8982..4ef9d0883a 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -142,7 +142,7 @@ public class UI implements ApplicationListener, Loadable{ Core.scene.act(); Core.scene.draw(); - if(Core.input.keyTap(KeyCode.mouseLeft) && Core.scene.getKeyboardFocus() instanceof TextField){ + if(Core.input.keyTap(KeyCode.mouseLeft) && Core.scene.hasField()){ Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); if(!(e instanceof TextField)){ Core.scene.setKeyboardFocus(null); diff --git a/core/src/mindustry/editor/MapView.java b/core/src/mindustry/editor/MapView.java index a2502e4b8a..ae6b204997 100644 --- a/core/src/mindustry/editor/MapView.java +++ b/core/src/mindustry/editor/MapView.java @@ -9,7 +9,6 @@ import arc.math.*; import arc.math.geom.*; import arc.scene.*; import arc.scene.event.*; -import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.util.*; import mindustry.graphics.*; @@ -178,7 +177,7 @@ public class MapView extends Element implements GestureListener{ public void act(float delta){ super.act(delta); - if(Core.scene.getKeyboardFocus() == null || !(Core.scene.getKeyboardFocus() instanceof TextField) && !Core.input.keyDown(KeyCode.controlLeft)){ + if(Core.scene.getKeyboardFocus() == null || !Core.scene.hasField() && !Core.input.keyDown(KeyCode.controlLeft)){ float ax = Core.input.axis(Binding.move_x); float ay = Core.input.axis(Binding.move_y); offsetx -= ax * 15 * Time.delta / zoom; diff --git a/core/src/mindustry/entities/bullet/BasicBulletType.java b/core/src/mindustry/entities/bullet/BasicBulletType.java index 84cbca0e0a..b053f6960a 100644 --- a/core/src/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/mindustry/entities/bullet/BasicBulletType.java @@ -14,8 +14,9 @@ public class BasicBulletType extends BulletType{ public Color mixColorFrom = new Color(1f, 1f, 1f, 0f), mixColorTo = new Color(1f, 1f, 1f, 0f); public float width = 5f, height = 7f; public float shrinkX = 0f, shrinkY = 0.5f; - public float spin = 0; + public float spin = 0, rotationOffset = 0f; public String sprite; + public @Nullable String backSprite; public TextureRegion backRegion; public TextureRegion frontRegion; @@ -36,7 +37,7 @@ public class BasicBulletType extends BulletType{ @Override public void load(){ - backRegion = Core.atlas.find(sprite + "-back"); + backRegion = Core.atlas.find(backSprite == null ? (sprite + "-back") : backSprite); frontRegion = Core.atlas.find(sprite); } @@ -45,14 +46,17 @@ public class BasicBulletType extends BulletType{ super.draw(b); float height = this.height * ((1f - shrinkY) + shrinkY * b.fout()); float width = this.width * ((1f - shrinkX) + shrinkX * b.fout()); - float offset = -90 + (spin != 0 ? Mathf.randomSeed(b.id, 360f) + b.time * spin : 0f); + float offset = -90 + (spin != 0 ? Mathf.randomSeed(b.id, 360f) + b.time * spin : 0f) + rotationOffset; Color mix = Tmp.c1.set(mixColorFrom).lerp(mixColorTo, b.fin()); Draw.mixcol(mix, mix.a); - Draw.color(backColor); - Draw.rect(backRegion, b.x, b.y, width, height, b.rotation() + offset); + if(backRegion.found()){ + Draw.color(backColor); + Draw.rect(backRegion, b.x, b.y, width, height, b.rotation() + offset); + } + Draw.color(frontColor); Draw.rect(frontRegion, b.x, b.y, width, height, b.rotation() + offset); diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index ddcd3b26d3..75d8a31f91 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -9,7 +9,6 @@ import arc.input.*; import arc.math.*; import arc.math.geom.*; import arc.scene.*; -import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.util.*; import mindustry.*; @@ -277,10 +276,8 @@ public class DesktopInput extends InputHandler{ shouldShoot = !scene.hasMouse() && !locked; - if(!locked && state.rules.unitCommand && block == null){ - //if(input.keyTap(Binding.commandMode)){ - commandMode = input.keyDown(Binding.commandMode); - //} + if(!locked && state.rules.unitCommand && block == null && !scene.hasField()){ + commandMode = input.keyDown(Binding.commandMode); }else{ commandMode = false; } @@ -317,7 +314,7 @@ public class DesktopInput extends InputHandler{ player.shooting = false; } - if(state.isGame() && !scene.hasDialog() && !(scene.getKeyboardFocus() instanceof TextField)){ + if(state.isGame() && !scene.hasDialog() && !scene.hasField()){ if(Core.input.keyTap(Binding.minimap)) ui.minimapfrag.toggle(); if(Core.input.keyTap(Binding.planet_map) && state.isCampaign()) ui.planet.toggle(); if(Core.input.keyTap(Binding.research) && state.isCampaign()) ui.research.toggle(); @@ -450,7 +447,7 @@ public class DesktopInput extends InputHandler{ } void pollInput(){ - if(scene.getKeyboardFocus() instanceof TextField) return; + if(scene.hasField()) return; Tile selected = tileAt(Core.input.mouseX(), Core.input.mouseY()); int cursorX = tileX(Core.input.mouseX()); diff --git a/core/src/mindustry/ui/fragments/HudFragment.java b/core/src/mindustry/ui/fragments/HudFragment.java index d4fde989e5..307fa99ae5 100644 --- a/core/src/mindustry/ui/fragments/HudFragment.java +++ b/core/src/mindustry/ui/fragments/HudFragment.java @@ -179,7 +179,7 @@ public class HudFragment extends Fragment{ } cont.update(() -> { - if(Core.input.keyTap(Binding.toggle_menus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !(Core.scene.getKeyboardFocus() instanceof TextField)){ + if(Core.input.keyTap(Binding.toggle_menus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !Core.scene.hasField()){ Core.settings.getBoolOnce("ui-hidden", () -> { ui.announce(Core.bundle.format("showui", Core.keybinds.get(Binding.toggle_menus).key.toString(), 11)); });