From 56e5705ed6b2fb1d62619a0aabe4d811ca48d31e Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 22 Oct 2019 20:17:43 -0400 Subject: [PATCH] Bugfixes --- .../src/io/anuke/mindustry/content/Mechs.java | 16 ++++----- .../io/anuke/mindustry/content/UnitTypes.java | 36 +++++++++---------- .../anuke/mindustry/entities/type/Player.java | 2 +- .../entities/type/base/FlyingUnit.java | 8 ++++- .../anuke/mindustry/input/InputHandler.java | 7 ++++ .../io/anuke/mindustry/mod/ContentParser.java | 6 +++- core/src/io/anuke/mindustry/type/Weapon.java | 6 ++-- 7 files changed, 49 insertions(+), 32 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index 182cb358d6..f738a1c083 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -38,7 +38,7 @@ public class Mechs implements ContentList{ weapon = new Weapon("blaster"){{ length = 1.5f; reload = 14f; - roundrobin = true; + alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardMechSmall; }}; @@ -71,7 +71,7 @@ public class Mechs implements ContentList{ length = 1f; reload = 55f; shotDelay = 3f; - roundrobin = true; + alternate = true; shots = 2; inaccuracy = 0f; ejectEffect = Fx.none; @@ -116,7 +116,7 @@ public class Mechs implements ContentList{ weapon = new Weapon("heal-blaster"){{ length = 1.5f; reload = 24f; - roundrobin = false; + alternate = false; ejectEffect = Fx.none; recoil = 2f; bullet = Bullets.healBullet; @@ -168,7 +168,7 @@ public class Mechs implements ContentList{ shots = 4; spacing = 8f; inaccuracy = 8f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; shake = 3f; bullet = Bullets.missileSwarm; @@ -232,7 +232,7 @@ public class Mechs implements ContentList{ weapon = new Weapon("blaster"){{ length = 1.5f; reload = 15f; - roundrobin = true; + alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; }}; @@ -262,7 +262,7 @@ public class Mechs implements ContentList{ reload = 70f; shots = 4; inaccuracy = 2f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; velocityRnd = 0.2f; spacing = 1f; @@ -327,7 +327,7 @@ public class Mechs implements ContentList{ shots = 2; shotDelay = 1f; shots = 8; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; velocityRnd = 1f; inaccuracy = 20f; @@ -365,7 +365,7 @@ public class Mechs implements ContentList{ weapon = new Weapon("bomber"){{ length = 1.5f; reload = 13f; - roundrobin = true; + alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardGlaive; shootSound = Sounds.shootSnap; diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index ae19123328..35eb9890bd 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -41,11 +41,11 @@ public class UnitTypes implements ContentList{ health = 100; engineSize = 1.8f; engineOffset = 5.7f; - weapon = new Weapon("heal-blaster"){{ + weapon = new Weapon(){{ length = 1.5f; reload = 40f; width = 0.5f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; recoil = 2f; bullet = Bullets.healBulletBig; @@ -65,11 +65,11 @@ public class UnitTypes implements ContentList{ buildPower = 0.4f; engineOffset = 6.5f; toMine = ObjectSet.with(Items.lead, Items.copper, Items.titanium); - weapon = new Weapon("heal-blaster"){{ + weapon = new Weapon(){{ length = 1.5f; reload = 20f; width = 0.5f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; recoil = 2f; bullet = Bullets.healBullet; @@ -86,7 +86,7 @@ public class UnitTypes implements ContentList{ weapon = new Weapon("chain-blaster"){{ length = 1.5f; reload = 28f; - roundrobin = true; + alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; }}; @@ -99,7 +99,7 @@ public class UnitTypes implements ContentList{ hitsize = 8f; mass = 1.75f; health = 120; - weapon = new Weapon("bomber"){{ + weapon = new Weapon(){{ reload = 12f; ejectEffect = Fx.none; shootSound = Sounds.explosion; @@ -138,7 +138,7 @@ public class UnitTypes implements ContentList{ length = 1f; reload = 14f; range = 30f; - roundrobin = true; + alternate = true; recoil = 1f; ejectEffect = Fx.none; bullet = Bullets.basicFlame; @@ -158,7 +158,7 @@ public class UnitTypes implements ContentList{ length = 1f; reload = 60f; width = 10f; - roundrobin = true; + alternate = true; recoil = 4f; shake = 2f; ejectEffect = Fx.shellEjectMedium; @@ -180,7 +180,7 @@ public class UnitTypes implements ContentList{ weapon = new Weapon("eruption"){{ length = 3f; reload = 10f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; bullet = Bullets.eruptorShot; recoil = 1f; @@ -201,7 +201,7 @@ public class UnitTypes implements ContentList{ length = 8f; reload = 50f; width = 17f; - roundrobin = true; + alternate = true; recoil = 3f; shake = 2f; shots = 4; @@ -225,7 +225,7 @@ public class UnitTypes implements ContentList{ length = 13f; reload = 30f; width = 22f; - roundrobin = true; + alternate = true; recoil = 3f; shake = 2f; inaccuracy = 3f; @@ -247,10 +247,10 @@ public class UnitTypes implements ContentList{ health = 75; engineOffset = 5.5f; range = 140f; - weapon = new Weapon("chain-blaster"){{ + weapon = new Weapon(){{ length = 1.5f; reload = 28f; - roundrobin = true; + alternate = true; ejectEffect = Fx.shellEjectSmall; bullet = Bullets.standardCopper; shootSound = Sounds.shoot; @@ -267,11 +267,11 @@ public class UnitTypes implements ContentList{ targetAir = false; engineOffset = 7.8f; range = 140f; - weapon = new Weapon("bomber"){{ + weapon = new Weapon(){{ length = 0f; width = 2f; reload = 12f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; velocityRnd = 1f; inaccuracy = 40f; @@ -303,7 +303,7 @@ public class UnitTypes implements ContentList{ width = 10f; shots = 2; inaccuracy = 2f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; velocityRnd = 0.2f; spacing = 1f; @@ -336,7 +336,7 @@ public class UnitTypes implements ContentList{ shootCone = 100f; shotDelay = 2; inaccuracy = 10f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; velocityRnd = 0.2f; spacing = 1f; @@ -369,7 +369,7 @@ public class UnitTypes implements ContentList{ shake = 1f; inaccuracy = 3f; - roundrobin = true; + alternate = true; ejectEffect = Fx.none; bullet = new BasicBulletType(7f, 42, "bullet"){ { diff --git a/core/src/io/anuke/mindustry/entities/type/Player.java b/core/src/io/anuke/mindustry/entities/type/Player.java index b2d8fb0035..eeaebc5fef 100644 --- a/core/src/io/anuke/mindustry/entities/type/Player.java +++ b/core/src/io/anuke/mindustry/entities/type/Player.java @@ -440,7 +440,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ control.input.drawBreaking(request); }else{ request.block.drawRequest(request, control.input.allRequests(), - Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation)); + Build.validPlace(getTeam(), request.x, request.y, request.block, request.rotation) || control.input.requestMatches(request)); } } diff --git a/core/src/io/anuke/mindustry/entities/type/base/FlyingUnit.java b/core/src/io/anuke/mindustry/entities/type/base/FlyingUnit.java index 8a7e04dbcf..017ebad34f 100644 --- a/core/src/io/anuke/mindustry/entities/type/base/FlyingUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/base/FlyingUnit.java @@ -151,7 +151,13 @@ public class FlyingUnit extends BaseUnit{ } public void drawWeapons(){ - + for(int i : Mathf.signs){ + float tra = rotation - 90, trY = -type.weapon.getRecoil(this, i > 0) + type.weaponOffsetY; + float w = -i * type.weapon.region.getWidth() * Draw.scl; + Draw.rect(type.weapon.region, + x + Angles.trnsx(tra, getWeapon().width * i, trY), + y + Angles.trnsy(tra, getWeapon().width * i, trY), w, type.weapon.region.getHeight() * Draw.scl, rotation - 90); + } } public void drawEngine(){ diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 72a5f1a4cc..9d38b20592 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -30,6 +30,8 @@ import io.anuke.mindustry.net.*; import io.anuke.mindustry.type.*; import io.anuke.mindustry.ui.fragments.*; import io.anuke.mindustry.world.*; +import io.anuke.mindustry.world.blocks.*; +import io.anuke.mindustry.world.blocks.BuildBlock.*; import java.util.*; @@ -214,6 +216,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } + public boolean requestMatches(BuildRequest request){ + Tile tile = world.tile(request.x, request.y); + return tile != null && tile.block() instanceof BuildBlock && tile.entity().cblock == request.block; + } + public void drawBreaking(int x, int y){ Tile tile = world.ltile(x, y); if(tile == null) return; diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index ea2a656ae3..e7b8c26b3c 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -78,6 +78,7 @@ public class ContentParser{ * This is done to accomodate binding of content names first.*/ private Array reads = new Array<>(); private Array postreads = new Array<>(); + private ObjectSet toBeParsed = new ObjectSet<>(); private LoadedMod currentMod; private Content currentContent; @@ -298,6 +299,7 @@ public class ContentParser{ } reads.clear(); postreads.clear(); + toBeParsed.clear(); } /** @@ -321,6 +323,7 @@ public class ContentParser{ currentMod = mod; boolean exists = Vars.content.getByName(type, name) != null; Content c = parsers.get(type).parse(mod.name, name, value); + toBeParsed.add(c); if(!exists){ c.sourceFile = file; c.mod = mod; @@ -387,7 +390,7 @@ public class ContentParser{ } private void checkNullFields(Object object){ - if(object instanceof Number || object instanceof String) return; + if(object instanceof Number || object instanceof String || toBeParsed.contains(object)) return; parser.getFields(object.getClass()).values().toArray().each(field -> { try{ @@ -408,6 +411,7 @@ public class ContentParser{ } private void readFields(Object object, JsonValue jsonMap){ + toBeParsed.remove(object); Class type = object.getClass(); ObjectMap fields = parser.getFields(type); for(JsonValue child = jsonMap.child; child != null; child = child.next){ diff --git a/core/src/io/anuke/mindustry/type/Weapon.java b/core/src/io/anuke/mindustry/type/Weapon.java index 2163cb8c23..cd467238d9 100644 --- a/core/src/io/anuke/mindustry/type/Weapon.java +++ b/core/src/io/anuke/mindustry/type/Weapon.java @@ -48,7 +48,7 @@ public class Weapon{ /** fraction of velocity that is random */ public float velocityRnd = 0f; /** whether to shoot the weapons in different arms one after another, rather than all at once */ - public boolean roundrobin = false; + public boolean alternate = false; /** randomization of shot length */ public float lengthRand = 0f; /** delay in ticks between shots */ @@ -124,7 +124,7 @@ public class Weapon{ } public void load(){ - region = Core.atlas.find(name + "-equip", Core.atlas.find("clear")); + region = Core.atlas.find(name + "-equip", Core.atlas.find(name, Core.atlas.find("clear"))); } public void update(ShooterTrait shooter, float pointerX, float pointerY){ @@ -143,7 +143,7 @@ public class Weapon{ public void update(ShooterTrait shooter, float mountX, float mountY, float angle, boolean left){ if(shooter.getTimer().get(shooter.getShootTimer(left), reload)){ - if(roundrobin){ + if(alternate){ shooter.getTimer().reset(shooter.getShootTimer(!left), reload / 2f); }