From de02061b5e48fa18a9a37c3c54f8b1a5be73778f Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 7 Jan 2019 12:25:54 -0500 Subject: [PATCH] Removed dependency on old BulletEntity/BaseBulletType classes --- .gitignore | 2 - .../src/io/anuke/mindustry/content/Mechs.java | 8 +- .../content/bullets/ArtilleryBullets.java | 14 +- .../content/bullets/FlakBullets.java | 2 +- .../content/bullets/MissileBullets.java | 22 +-- .../content/bullets/StandardBullets.java | 2 +- .../content/bullets/TurretBullets.java | 93 ++++++----- .../content/bullets/WeaponBullets.java | 8 +- .../io/anuke/mindustry/core/NetClient.java | 2 +- .../io/anuke/mindustry/core/NetServer.java | 2 +- .../io/anuke/mindustry/entities/Damage.java | 6 +- .../io/anuke/mindustry/entities/Player.java | 16 +- .../anuke/mindustry/entities/TileEntity.java | 2 +- .../src/io/anuke/mindustry/entities/Unit.java | 12 +- .../io/anuke/mindustry/entities/Units.java | 4 +- .../entities/bullet/ArtilleryBulletType.java | 4 +- .../entities/bullet/BasicBulletType.java | 6 +- .../mindustry/entities/bullet/Bullet.java | 149 +++++++++++++----- .../mindustry/entities/bullet/BulletType.java | 82 +++------- .../entities/bullet/FlakBulletType.java | 2 +- .../entities/bullet/LiquidBulletType.java | 6 +- .../mindustry/entities/effect/Puddle.java | 8 +- .../entities/traits/AbsorbTrait.java | 2 +- .../entities/traits/TargetTrait.java | 4 +- .../mindustry/entities/units/BaseUnit.java | 10 +- .../io/anuke/mindustry/input/MobileInput.java | 2 +- .../io/anuke/mindustry/type/AmmoEntry.java | 3 +- core/src/io/anuke/mindustry/type/Weapon.java | 2 +- core/src/io/anuke/mindustry/world/Block.java | 2 +- core/src/io/anuke/mindustry/world/Tile.java | 2 +- .../world/blocks/defense/DeflectorWall.java | 10 +- .../world/blocks/defense/SurgeWall.java | 2 +- .../blocks/defense/turrets/LaserTurret.java | 4 +- .../world/blocks/distribution/Conveyor.java | 2 +- .../world/blocks/units/UnitFactory.java | 2 +- 35 files changed, 268 insertions(+), 231 deletions(-) diff --git a/.gitignore b/.gitignore index 62ef5bbfad..b33484f175 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -##Packr, build stuff - logs/ /core/assets/mindustry-saves/ /core/assets/mindustry-maps/ diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index bb3f266f65..5ec66db65c 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -160,7 +160,7 @@ public class Mechs implements ContentList{ @Override public void updateAlt(Player player){ float scl = 1f - player.shootHeat/2f; - player.getVelocity().scl(scl); + player.velocity().scl(scl); } @Override @@ -230,7 +230,7 @@ public class Mechs implements ContentList{ if(Mathf.chance(Time.delta() * (0.15*scl))){ Effects.effect(BulletFx.hitLancer, Palette.lancerLaser, player.x, player.y); Lightning.create(player.getTeam(), Palette.lancerLaser, 10f, - player.x + player.getVelocity().x, player.y + player.getVelocity().y, player.rotation, 14); + player.x + player.velocity().x, player.y + player.velocity().y, player.rotation, 14); } } @@ -251,7 +251,7 @@ public class Mechs implements ContentList{ } float scld(Player player){ - return Mathf.clamp((player.getVelocity().len() - minV) / (maxV - minV)); + return Mathf.clamp((player.velocity().len() - minV) / (maxV - minV)); } }; @@ -271,7 +271,7 @@ public class Mechs implements ContentList{ @Override public boolean canShoot(Player player){ - return player.getVelocity().len() > 1.2f; + return player.velocity().len() > 1.2f; } }; diff --git a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java b/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java index 0bb8857f22..92b3b242ca 100644 --- a/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/ArtilleryBullets.java @@ -16,7 +16,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{ dense = new ArtilleryBulletType(3f, 0, "shell"){ { - hiteffect = BulletFx.flakExplosion; + hitEffect = BulletFx.flakExplosion; knockback = 0.8f; lifetime = 50f; bulletWidth = bulletHeight = 11f; @@ -34,13 +34,13 @@ public class ArtilleryBullets extends BulletList implements ContentList{ lifetime = 15f; backColor = Palette.plastaniumBack; frontColor = Palette.plastaniumFront; - despawneffect = Fx.none; + despawnEffect = Fx.none; } }; plastic = new ArtilleryBulletType(3.3f, 0, "shell"){ { - hiteffect = BulletFx.plasticExplosion; + hitEffect = BulletFx.plasticExplosion; knockback = 1f; lifetime = 55f; bulletWidth = bulletHeight = 13f; @@ -56,7 +56,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{ homing = new ArtilleryBulletType(3f, 0, "shell"){ { - hiteffect = BulletFx.flakExplosion; + hitEffect = BulletFx.flakExplosion; knockback = 0.8f; lifetime = 45f; bulletWidth = bulletHeight = 11f; @@ -70,7 +70,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{ incindiary = new ArtilleryBulletType(3f, 0, "shell"){ { - hiteffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; knockback = 0.8f; lifetime = 60f; bulletWidth = bulletHeight = 13f; @@ -87,7 +87,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{ explosive = new ArtilleryBulletType(2f, 0, "shell"){ { - hiteffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; knockback = 0.8f; lifetime = 70f; bulletWidth = bulletHeight = 14f; @@ -101,7 +101,7 @@ public class ArtilleryBullets extends BulletList implements ContentList{ unit = new ArtilleryBulletType(2f, 0, "shell"){ { - hiteffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; knockback = 0.8f; lifetime = 90f; bulletWidth = bulletHeight = 14f; diff --git a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java b/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java index c13a5b8409..d312640e35 100644 --- a/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/FlakBullets.java @@ -21,7 +21,7 @@ public class FlakBullets extends BulletList implements ContentList{ splashDamageRadius = 40f; fragBullet = ArtilleryBullets.plasticFrag; fragBullets = 4; - hiteffect = BulletFx.plasticExplosion; + hitEffect = BulletFx.plasticExplosion; frontColor = Palette.plastaniumFront; backColor = Palette.plastaniumBack; } diff --git a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java b/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java index a61a98c401..f3a3d9092c 100644 --- a/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/MissileBullets.java @@ -26,8 +26,8 @@ public class MissileBullets extends BulletList implements ContentList{ splashDamageRadius = 30f; splashDamage = 30f; lifetime = 150f; - hiteffect = BulletFx.blastExplosion; - despawneffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; } }; @@ -43,7 +43,7 @@ public class MissileBullets extends BulletList implements ContentList{ splashDamageRadius = 10f; splashDamage = 10f; lifetime = 160f; - hiteffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; incendSpread = 10f; incendAmount = 3; } @@ -58,8 +58,8 @@ public class MissileBullets extends BulletList implements ContentList{ splashDamageRadius = 30f; splashDamage = 22f; lifetime = 150f; - hiteffect = BulletFx.blastExplosion; - despawneffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; } @Override @@ -83,8 +83,8 @@ public class MissileBullets extends BulletList implements ContentList{ splashDamage = 1f; lifetime = 90f; trailColor = Color.valueOf("b6c6fd"); - hiteffect = BulletFx.blastExplosion; - despawneffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; backColor = Palette.bulletYellowBack; frontColor = Palette.bulletYellow; } @@ -92,7 +92,7 @@ public class MissileBullets extends BulletList implements ContentList{ @Override public void update(Bullet b){ super.update(b); - b.getVelocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); + b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); } }; @@ -110,14 +110,14 @@ public class MissileBullets extends BulletList implements ContentList{ trailColor = Color.GRAY; backColor = Palette.bulletYellowBack; frontColor = Palette.bulletYellow; - hiteffect = BulletFx.blastExplosion; - despawneffect = BulletFx.blastExplosion; + hitEffect = BulletFx.blastExplosion; + despawnEffect = BulletFx.blastExplosion; } @Override public void update(Bullet b){ super.update(b); - b.getVelocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); + b.velocity().rotate(Mathf.sin(Time.time() + b.id * 4422, 8f, 2f)); } }; } diff --git a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java index b67425b83e..fa6559fb10 100644 --- a/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/StandardBullets.java @@ -73,7 +73,7 @@ public class StandardBullets extends BulletList implements ContentList{ bulletWidth = 11f; bulletHeight = 14f; lifetime = 40f; - despawneffect = BulletFx.hitBulletSmall; + despawnEffect = BulletFx.hitBulletSmall; } }; diff --git a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java index 1bce07f371..bbc3d6336d 100644 --- a/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/TurretBullets.java @@ -9,6 +9,7 @@ import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; +import io.anuke.arc.util.Tmp; import io.anuke.mindustry.content.Liquids; import io.anuke.mindustry.content.StatusEffects; import io.anuke.mindustry.content.fx.BlockFx; @@ -41,8 +42,8 @@ public class TurretBullets extends BulletList implements ContentList{ damageLightning = new BulletType(0.0001f, 0f){ { lifetime = Lightning.lifetime; - hiteffect = BulletFx.hitLancer; - despawneffect = Fx.none; + hitEffect = BulletFx.hitLancer; + despawnEffect = Fx.none; status = StatusEffects.shocked; statusIntensity = 1f; } @@ -52,8 +53,8 @@ public class TurretBullets extends BulletList implements ContentList{ float healPercent = 3f; { - hiteffect = BulletFx.hitLaser; - despawneffect = BulletFx.hitLaser; + hitEffect = BulletFx.hitLaser; + despawnEffect = BulletFx.hitLaser; collidesTeam = true; } @@ -66,9 +67,9 @@ public class TurretBullets extends BulletList implements ContentList{ public void draw(Bullet b){ Draw.color(Palette.heal); Lines.stroke(2f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 7f); + Lines.lineAngleCenter(b.x, b.y, b.rot(), 7f); Draw.color(Color.WHITE); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 3f); + Lines.lineAngleCenter(b.x, b.y, b.rot(), 3f); Draw.reset(); } @@ -91,12 +92,12 @@ public class TurretBullets extends BulletList implements ContentList{ collides = false; collidesTiles = false; drag = 0.03f; - hiteffect = despawneffect = Fx.none; + hitEffect = despawnEffect = Fx.none; } @Override public void init(Bullet b){ - b.getVelocity().setLength(0.6f + Mathf.random(2f)); + b.velocity().setLength(0.6f + Mathf.random(2f)); } @Override @@ -128,12 +129,12 @@ public class TurretBullets extends BulletList implements ContentList{ basicFlame = new BulletType(2.3f, 5){ { - hitsize = 7f; + hitSize = 7f; lifetime = 35f; pierce = true; drag = 0.05f; - hiteffect = BulletFx.hitFlameSmall; - despawneffect = Fx.none; + hitEffect = BulletFx.hitFlameSmall; + despawnEffect = Fx.none; status = StatusEffects.burning; } @@ -149,16 +150,16 @@ public class TurretBullets extends BulletList implements ContentList{ float length = 100f; { - hiteffect = BulletFx.hitLancer; - despawneffect = Fx.none; - hitsize = 4; + hitEffect = BulletFx.hitLancer; + despawnEffect = Fx.none; + hitSize = 4; lifetime = 16f; pierce = true; } @Override public void init(Bullet b){ - Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length); + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); } @Override @@ -166,12 +167,12 @@ public class TurretBullets extends BulletList implements ContentList{ float f = Mathf.curve(b.fin(), 0f, 0.2f); float baseLen = length * f; - Lines.lineAngle(b.x, b.y, b.angle(), baseLen); + Lines.lineAngle(b.x, b.y, b.rot(), baseLen); for(int s = 0; s < 3; s++){ Draw.color(colors[s]); for(int i = 0; i < tscales.length; i++){ Lines.stroke(7f * b.fout() * (s == 0 ? 1.5f : s == 1 ? 1f : 0.3f) * tscales[i]); - Lines.lineAngle(b.x, b.y, b.angle(), baseLen * lenscales[i]); + Lines.lineAngle(b.x, b.y, b.rot(), baseLen * lenscales[i]); } } Draw.reset(); @@ -187,9 +188,9 @@ public class TurretBullets extends BulletList implements ContentList{ float length = 200f; { - hiteffect = BulletFx.hitMeltdown; - despawneffect = Fx.none; - hitsize = 4; + hitEffect = BulletFx.hitMeltdown; + despawnEffect = Fx.none; + hitSize = 4; drawSize = 420f; lifetime = 16f; pierce = true; @@ -198,14 +199,14 @@ public class TurretBullets extends BulletList implements ContentList{ @Override public void update(Bullet b){ if(b.timer.get(1, 5f)){ - Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length); + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), length); } Effects.shake(1f, 1f, b.x, b.y); } @Override public void hit(Bullet b, float hitx, float hity){ - Effects.effect(hiteffect, colors[2], hitx, hity); + Effects.effect(hitEffect, colors[2], hitx, hity); if(Mathf.chance(0.4)){ Fire.create(world.tileWorld(hitx+Mathf.range(5f), hity+Mathf.range(5f))); } @@ -215,13 +216,13 @@ public class TurretBullets extends BulletList implements ContentList{ public void draw(Bullet b){ float baseLen = (length) * b.fout(); - Lines.lineAngle(b.x, b.y, b.angle(), baseLen); + Lines.lineAngle(b.x, b.y, b.rot(), baseLen); for(int s = 0; s < colors.length; s++){ Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f))); for(int i = 0; i < tscales.length; i++){ - vector.trns(b.angle() + 180f, (lenscales[i] - 1f) * 35f); + Tmp.v1.trns(b.rot() + 180f, (lenscales[i] - 1f) * 35f); Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]); - Lines.lineAngle(b.x + vector.x, b.y + vector.y, b.angle(), baseLen * lenscales[i], CapStyle.none); + Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rot(), baseLen * lenscales[i], CapStyle.none); } } Draw.reset(); @@ -233,18 +234,16 @@ public class TurretBullets extends BulletList implements ContentList{ float raySpace = 2f; float rayLength = 80f; { - hiteffect = BulletFx.hitFuse; + hitEffect = BulletFx.hitFuse; lifetime = 13f; - despawneffect = Fx.none; + despawnEffect = Fx.none; pierce = true; } @Override public void init(Bullet b) { for (int i = 0; i < rays; i++) { - float offset = (i-rays/2)*raySpace; - vector.trns(b.angle(), 0.01f, offset); - Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), rayLength - Math.abs(i - (rays/2))*20f); + Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays/2))*20f); } } @@ -253,17 +252,15 @@ public class TurretBullets extends BulletList implements ContentList{ super.draw(b); Draw.color(Color.WHITE, Palette.surge, b.fin()); for(int i = 0; i < 7; i++){ - vector.trns(b.angle(), i * 8f); + Tmp.v1.trns(b.rot(), i * 8f); float sl = Mathf.clamp(b.fout()-0.5f) * (80f - i *10); - Shapes.tri(b.x + vector.x, b.y + vector.y, 4f, sl, b.angle() + 90); - Shapes.tri(b.x + vector.x, b.y + vector.y, 4f, sl, b.angle() - 90); + Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() + 90); + Shapes.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rot() - 90); } - Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.angle()); - Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.angle() + 180f); + Shapes.tri(b.x, b.y, 13f, (rayLength+50) * b.fout(), b.rot()); + Shapes.tri(b.x, b.y, 13f, 10f * b.fout(), b.rot() + 180f); Draw.reset(); } - - //TODO }; waterShot = new LiquidBulletType(Liquids.water){ @@ -300,8 +297,8 @@ public class TurretBullets extends BulletList implements ContentList{ lightning = new BulletType(0.001f, 12f){ { lifetime = 1f; - despawneffect = Fx.none; - hiteffect = BulletFx.hitLancer; + despawnEffect = Fx.none; + hitEffect = BulletFx.hitLancer; keepVelocity = false; } @@ -311,15 +308,15 @@ public class TurretBullets extends BulletList implements ContentList{ @Override public void init(Bullet b){ - Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.angle(), 30); + Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 30); } }; arc = new BulletType(0.001f, 26){ { lifetime = 1; - despawneffect = Fx.none; - hiteffect = BulletFx.hitLancer; + despawnEffect = Fx.none; + hitEffect = BulletFx.hitLancer; } @Override @@ -328,7 +325,7 @@ public class TurretBullets extends BulletList implements ContentList{ @Override public void init(Bullet b){ - Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.angle(), 36); + Lightning.create(b.getTeam(), Palette.lancerLaser, damage, b.x, b.y, b.rot(), 36); } }; @@ -336,8 +333,8 @@ public class TurretBullets extends BulletList implements ContentList{ { collidesTiles = false; lifetime = 200f; - despawneffect = BlockFx.smeltsmoke; - hiteffect = BulletFx.hitBulletBig; + despawnEffect = BlockFx.smeltsmoke; + hitEffect = BulletFx.hitBulletBig; drag = 0.005f; } @@ -346,10 +343,10 @@ public class TurretBullets extends BulletList implements ContentList{ float w = 11f, h = 13f; Draw.color(Palette.bulletYellowBack); - Draw.rect("shell-back", b.x, b.y, w, h, b.angle() + 90); + Draw.rect("shell-back", b.x, b.y, w, h, b.rot() + 90); Draw.color(Palette.bulletYellow); - Draw.rect("shell", b.x, b.y, w, h, b.angle() + 90); + Draw.rect("shell", b.x, b.y, w, h, b.rot() + 90); Draw.reset(); } @@ -412,7 +409,7 @@ public class TurretBullets extends BulletList implements ContentList{ for(int i = 0; i < data.items.length; i++){ int amountDropped = Mathf.random(0, data.items[i]); if(amountDropped > 0){ - float angle = b.angle() + Mathf.range(100f); + float angle = b.rot() + Mathf.range(100f); Effects.effect(EnvironmentFx.dropItem, Color.WHITE, b.x, b.y, angle, content.item(i)); } } diff --git a/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java b/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java index 86adce6b55..6052ee1b6b 100644 --- a/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java +++ b/core/src/io/anuke/mindustry/content/bullets/WeaponBullets.java @@ -35,7 +35,7 @@ public class WeaponBullets extends BulletList{ { bulletWidth = 9f; bulletHeight = 13f; - hiteffect = BulletFx.flakExplosion; + hitEffect = BulletFx.flakExplosion; } }; @@ -43,7 +43,7 @@ public class WeaponBullets extends BulletList{ { bulletWidth = 8f; bulletHeight = 12f; - hiteffect = BulletFx.flakExplosion; + hitEffect = BulletFx.flakExplosion; backColor = Palette.lightOrange; frontColor = Palette.lightishOrange; } @@ -67,7 +67,7 @@ public class WeaponBullets extends BulletList{ { bulletWidth = 8f; bulletHeight = 12f; - hiteffect = BlockFx.pulverize; + hitEffect = BlockFx.pulverize; backColor = new Color(0x4f4f4fff); frontColor = Color.GRAY; } @@ -91,7 +91,7 @@ public class WeaponBullets extends BulletList{ lifetime = 40f; drag = 0.025f; fragBullets = 5; - hiteffect = BulletFx.flakExplosion; + hitEffect = BulletFx.flakExplosion; fragBullet = tungstenShotgun; } }; diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index e3e70da110..71c8d9caef 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -347,7 +347,7 @@ public class NetClient implements ApplicationListener{ Call.onClientShapshot(lastSent++, Time.millis(), player.x, player.y, player.pointerX, player.pointerY, player.rotation, player.baseRotation, - player.getVelocity().x, player.getVelocity().y, + player.velocity().x, player.velocity().y, player.getMineTile(), player.isBoosting, player.isShooting, requests, Core.camera.position.x, Core.camera.position.y, diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 4987df27c4..16f0b1185c 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -329,7 +329,7 @@ public class NetServer implements ApplicationListener{ //set interpolator target to *new* position so it moves toward it player.getInterpolator().read(player.x, player.y, newx, newy, sent, rotation, baseRotation); - player.getVelocity().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player + player.velocity().set(xVelocity, yVelocity); //only for visual calculation purposes, doesn't actually update the player connection.lastRecievedClientSnapshot = snapshotID; connection.lastRecievedClientTime = Time.millis(); diff --git a/core/src/io/anuke/mindustry/entities/Damage.java b/core/src/io/anuke/mindustry/entities/Damage.java index 7df2455bc6..27713c81ea 100644 --- a/core/src/io/anuke/mindustry/entities/Damage.java +++ b/core/src/io/anuke/mindustry/entities/Damage.java @@ -110,7 +110,7 @@ public class Damage{ rect.height += expand * 2; Consumer cons = e -> { - e.getHitbox(hitrect); + e.hitbox(hitrect); Rectangle other = hitrect; other.y -= expand; other.x -= expand; @@ -134,7 +134,7 @@ public class Damage{ Consumer cons = entity -> { if(!predicate.test(entity)) return; - entity.getHitbox(hitrect); + entity.hitbox(hitrect); if(!hitrect.overlaps(rect)){ return; } @@ -165,7 +165,7 @@ public class Damage{ entity.damage(amount); //TODO better velocity displacement float dst = tr.set(entity.x - x, entity.y - y).len(); - entity.getVelocity().add(tr.setLength((1f - dst / radius) * 2f)); + entity.velocity().add(tr.setLength((1f - dst / radius) * 2f)); }; rect.setSize(radius * 2).setCenter(x, y); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index a6c073c61e..7380ae0ea9 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -100,17 +100,17 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra } @Override - public void getHitbox(Rectangle rectangle){ + public void hitbox(Rectangle rectangle){ rectangle.setSize(mech.hitsize).setCenter(x, y); } @Override - public void getHitboxTile(Rectangle rectangle){ + public void hitboxTile(Rectangle rectangle){ rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y); } @Override - public float getDrag(){ + public float drag(){ return mech.drag; } @@ -208,7 +208,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra } @Override - public float getMass(){ + public float mass(){ return mech.mass; } @@ -241,7 +241,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra } @Override - public float getMaxVelocity(){ + public float maxVelocity(){ return mech.maxSpeed; } @@ -571,7 +571,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra }else if(getCarry() != null){ dropCarry(); }else{ - Unit unit = Units.getClosest(team, x, y, 8f, u -> !u.isFlying() && u.getMass() <= mech.carryWeight); + Unit unit = Units.getClosest(team, x, y, 8f, u -> !u.isFlying() && u.mass() <= mech.carryWeight); if(unit != null){ carry(unit); @@ -675,7 +675,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra float expansion = 3f; - getHitbox(rect); + hitbox(rect); rect.x -= expansion; rect.y -= expansion; rect.width += expansion * 2f; @@ -732,7 +732,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra } Vector2 intercept = - Predict.intercept(x, y, target.getX(), target.getY(), target.getVelocity().x - velocity.x, target.getVelocity().y - velocity.y, getWeapon().getAmmo().bullet.speed); + Predict.intercept(x, y, target.getX(), target.getY(), target.velocity().x - velocity.x, target.velocity().y - velocity.y, getWeapon().getAmmo().bullet.speed); pointerX = intercept.x; pointerY = intercept.y; diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index c3dc293f95..a48defd085 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -257,7 +257,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{ } @Override - public Vector2 getVelocity(){ + public Vector2 velocity(){ return Vector2.ZERO; } diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index 1c3d4c6660..de4427b37a 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -124,7 +124,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ } @Override - public Vector2 getVelocity(){ + public Vector2 velocity(){ return velocity; } @@ -190,7 +190,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ } public void avoidOthers(float scaling){ - getHitbox(queryRect); + hitbox(queryRect); queryRect.setSize(queryRect.getWidth() * scaling); Units.getNearby(queryRect, t -> { @@ -228,7 +228,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ if(isCarried()){ //carried units do not take into account velocity normally set(carrier.getX(), carrier.getY()); - velocity.set(carrier.getVelocity()); + velocity.set(carrier.velocity()); return; } @@ -236,7 +236,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ status.update(this); - velocity.limit(getMaxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta()); + velocity.limit(maxVelocity()).scl(1f + (status.getSpeedMultiplier()-1f) * Time.delta()); if(isFlying()){ x += velocity.x * Time.delta(); @@ -289,7 +289,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ if(Math.abs(py - y) <= 0.0001f) velocity.y = 0f; } - velocity.scl(Mathf.clamp(1f - getDrag() * (isFlying() ? 1f : floor.dragMultiplier) * Time.delta())); + velocity.scl(Mathf.clamp(1f - drag() * (isFlying() ? 1f : floor.dragMultiplier) * Time.delta())); } public void applyEffect(StatusEffect effect, float intensity){ @@ -355,7 +355,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ public abstract float getArmor(); - public abstract float getMass(); + public abstract float mass(); public abstract boolean isFlying(); diff --git a/core/src/io/anuke/mindustry/entities/Units.java b/core/src/io/anuke/mindustry/entities/Units.java index 95e16842da..4b2e984f42 100644 --- a/core/src/io/anuke/mindustry/entities/Units.java +++ b/core/src/io/anuke/mindustry/entities/Units.java @@ -67,7 +67,7 @@ public class Units{ Units.getNearby(rect, unit -> { if(boolResult) return; if(!unit.isFlying()){ - unit.getHitbox(hitrect); + unit.hitbox(hitrect); if(hitrect.overlaps(rect)){ boolResult = true; @@ -89,7 +89,7 @@ public class Units{ Units.getNearby(rect, unit -> { if(value[0] || !pred.test(unit) || unit.isDead()) return; if(!unit.isFlying()){ - unit.getHitbox(hitrect); + unit.hitbox(hitrect); if(hitrect.overlaps(rect)){ value[0] = true; diff --git a/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java index 6a317f0882..ed25df2f5d 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/ArtilleryBulletType.java @@ -34,9 +34,9 @@ public class ArtilleryBulletType extends BasicBulletType{ float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); Draw.color(backColor); - Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90); + Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90); Draw.color(frontColor); - Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90); + Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.rot() - 90); Draw.color(); } } diff --git a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java index 7f3ca88aeb..8264736a92 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BasicBulletType.java @@ -57,9 +57,9 @@ public class BasicBulletType extends BulletType{ float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout()); Draw.color(backColor); - Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.angle() - 90); + Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.rot() - 90); Draw.color(frontColor); - Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.angle() - 90); + Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.rot() - 90); Draw.color(); } @@ -70,7 +70,7 @@ public class BasicBulletType extends BulletType{ if(homingPower > 0.0001f){ TargetTrait target = Units.getClosestTarget(b.getTeam(), b.x, b.y, homingRange); if(target != null){ - b.getVelocity().setAngle(Angles.moveToward(b.getVelocity().angle(), b.angleTo(target), homingPower * Time.delta())); + b.velocity().setAngle(Angles.moveToward(b.velocity().angle(), b.angleTo(target), homingPower * Time.delta())); } } } diff --git a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java index b2d10aeac6..3bd1fe6ad7 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/bullet/Bullet.java @@ -3,14 +3,15 @@ package io.anuke.mindustry.entities.bullet; import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.entities.EntityGroup; -import io.anuke.arc.entities.impl.BulletEntity; -import io.anuke.arc.entities.trait.Entity; -import io.anuke.arc.entities.trait.SolidTrait; -import io.anuke.arc.entities.trait.VelocityTrait; +import io.anuke.arc.entities.impl.SolidEntity; +import io.anuke.arc.entities.trait.*; import io.anuke.arc.math.Mathf; +import io.anuke.arc.math.geom.Rectangle; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.Interval; import io.anuke.arc.util.Time; +import io.anuke.arc.util.Tmp; +import io.anuke.arc.util.pooling.Pool.Poolable; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.effect.Lightning; @@ -26,14 +27,18 @@ import java.io.IOException; import static io.anuke.mindustry.Vars.*; -public class Bullet extends BulletEntity implements TeamTrait, SyncTrait, AbsorbTrait{ - private static Vector2 vector = new Vector2(); +public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Poolable, DrawTrait, VelocityTrait, TimeTrait, TeamTrait, SyncTrait, AbsorbTrait{ public Interval timer = new Interval(3); + private float lifeScl; private Team team; private Object data; private boolean supressCollision, supressOnce, initialized; + protected BulletType type; + protected Entity owner; + protected float time; + /**Internal use only!*/ public Bullet(){ } @@ -62,7 +67,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl); if(type.keepVelocity){ - bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).getVelocity() : Vector2.ZERO); + bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).velocity() : Vector2.ZERO); } bullet.team = team; @@ -83,6 +88,7 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT return create(type, parent.owner, parent.team, x, y, angle, velocityScl); } + /**Internal use only.*/ @Remote(called = Loc.server) public static void createBullet(BulletType type, float x, float y, float angle){ create(type, null, Team.none, x, y, angle); @@ -97,12 +103,6 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT supressOnce = true; } - @Override - public void absorb(){ - supressCollision = true; - remove(); - } - public BulletType getBulletType(){ return type; } @@ -124,22 +124,29 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT this.data = data; } + @Override + public void absorb(){ + supressCollision = true; + remove(); + } + @Override public float drawSize(){ return type.drawSize; } @Override - public float getDamage(){ + public float damage(){ + //todo hacky way to get damage, refactor if(owner instanceof Unit){ - return super.getDamage() * ((Unit) owner).getDamageMultipler(); + return type.damage * ((Unit) owner).getDamageMultipler(); } if(owner instanceof Lightning && data instanceof Float){ return (Float)data; } - return super.getDamage(); + return type.damage; } @Override @@ -172,35 +179,44 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT return team; } - @Override - public void draw(){ - type.draw(this); - } - @Override public float getShieldDamage(){ - return Math.max(getDamage(), type.splashDamage); + return Math.max(damage(), type.splashDamage); } @Override public boolean collides(SolidTrait other){ - return type.collides && super.collides(other) && !supressCollision && !(other instanceof Unit && ((Unit) other).isFlying() && !type.collidesAir); + return type.collides && (other != owner && !(other instanceof DamageTrait)) && !supressCollision && !(other instanceof Unit && ((Unit) other).isFlying() && !type.collidesAir); } @Override public void collision(SolidTrait other, float x, float y){ - super.collision(other, x, y); + if(!type.pierce) remove(); + type.hit(this, x, y); if(other instanceof Unit){ Unit unit = (Unit) other; - unit.getVelocity().add(vector.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.getMass())); + unit.velocity().add(Tmp.v3.set(other.getX(), other.getY()).sub(x, y).setLength(type.knockback / unit.mass())); unit.applyEffect(type.status, type.statusIntensity); } } @Override public void update(){ - super.update(); + type.update(this); + + x += velocity.x * Time.delta(); + y += velocity.y * Time.delta(); + + velocity.scl(Mathf.clamp(1f - type.drag * Time.delta())); + + time += Time.delta() * 1f/(lifeScl); + time = Mathf.clamp(time, 0, type.lifetime); + + if(time >= type.lifetime){ + if(!supressCollision) type.despawned(this); + remove(); + } if(type.hitTiles && collidesTiles() && !supressCollision && initialized){ world.raycastEach(world.toTile(lastPosition().x), world.toTile(lastPosition().y), world.toTile(x), world.toTile(y), (x, y) -> { @@ -234,20 +250,12 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT initialized = true; } - @Override - protected void updateLife(){ - time += Time.delta() * 1f/(lifeScl); - time = Mathf.clamp(time, 0, type.lifetime()); - - if(time >= type.lifetime){ - if(!supressCollision) type.despawned(this); - remove(); - } - } - @Override public void reset(){ - super.reset(); + type = null; + owner = null; + velocity.setZero(); + time = 0f; timer.clear(); lifeScl = 1f; team = null; @@ -257,6 +265,31 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT initialized = false; } + @Override + public void hitbox(Rectangle rectangle){ + rectangle.setSize(type.hitSize).setCenter(x, y); + } + + @Override + public void hitboxTile(Rectangle rectangle){ + rectangle.setSize(type.hitSize).setCenter(x, y); + } + + @Override + public float lifetime(){ + return type.lifetime; + } + + @Override + public void time(float time){ + this.time = time; + } + + @Override + public float time(){ + return time; + } + @Override public void removed(){ Pools.free(this); @@ -266,4 +299,44 @@ public class Bullet extends BulletEntity implements TeamTrait, SyncT public EntityGroup targetGroup(){ return bulletGroup; } + + @Override + public void added(){ + type.init(this); + } + + @Override + public void draw(){ + type.draw(this); + } + + @Override + public float fin(){ + return time / type.lifetime; + } + + @Override + public Vector2 velocity(){ + return velocity; + } + + public void velocity(float speed, float angle){ + velocity.set(0, speed).setAngle(angle); + } + + public void limit(float f){ + velocity.limit(f); + } + + /** Sets the bullet's rotation in degrees.*/ + public void rot(float angle){ + velocity.setAngle(angle); + } + + /** @return the bullet's rotation.*/ + public float rot(){ + float angle = Mathf.atan2(velocity.x, velocity.y) * Mathf.radiansToDegrees; + if(angle < 0) angle += 360; + return angle; + } } diff --git a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java index 0c2cbc7c94..69adf8d54e 100644 --- a/core/src/io/anuke/mindustry/entities/bullet/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/bullet/BulletType.java @@ -2,24 +2,28 @@ package io.anuke.mindustry.entities.bullet; import io.anuke.arc.entities.Effects; import io.anuke.arc.entities.Effects.Effect; -import io.anuke.arc.entities.impl.BaseBulletType; -import io.anuke.arc.math.geom.Vector2; import io.anuke.mindustry.content.StatusEffects; import io.anuke.mindustry.content.fx.BulletFx; +import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.game.Content; import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.StatusEffect; import io.anuke.mindustry.world.Tile; -public abstract class BulletType extends Content implements BaseBulletType{ +public abstract class BulletType extends Content{ public float lifetime; public float speed; public float damage; - public float hitsize = 4; - public float drawSize = 20f; + public float hitSize = 4; + public float drawSize = 40f; public float drag = 0f; public boolean pierce; - public Effect hiteffect, despawneffect; + public Effect hitEffect, despawnEffect; + + /**Effect created when shooting.*/ + public Effect shootEffect = Fx.none; + /**Extra smoke effect created when shooting.*/ + public Effect smokeEffect = Fx.none; public float splashDamage = 0f; /**Knockback in velocity.*/ @@ -45,14 +49,12 @@ public abstract class BulletType extends Content implements BaseBulletType { if(unit.isFlying()) return; - unit.getHitbox(rect2); + unit.hitbox(rect2); if(!rect.overlaps(rect2)) return; unit.applyEffect(liquid.effect, 0.5f); - if(unit.getVelocity().len() > 0.1){ + if(unit.velocity().len() > 0.1){ Effects.effect(BlockFx.ripple, liquid.color, unit.x, unit.y); } }); diff --git a/core/src/io/anuke/mindustry/entities/traits/AbsorbTrait.java b/core/src/io/anuke/mindustry/entities/traits/AbsorbTrait.java index 7c6520364c..dedffc5203 100644 --- a/core/src/io/anuke/mindustry/entities/traits/AbsorbTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/AbsorbTrait.java @@ -11,6 +11,6 @@ public interface AbsorbTrait extends Entity, TeamTrait, DamageTrait{ } default float getShieldDamage(){ - return getDamage(); + return damage(); } } diff --git a/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java b/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java index 68eac61412..f59ed37091 100644 --- a/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/TargetTrait.java @@ -18,14 +18,14 @@ public interface TargetTrait extends Position, VelocityTrait{ if(this instanceof SolidTrait){ return ((SolidTrait) this).getDeltaX(); } - return getVelocity().x; + return velocity().x; } default float getTargetVelocityY(){ if(this instanceof SolidTrait){ return ((SolidTrait) this).getDeltaY(); } - return getVelocity().y; + return velocity().y; } /** diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index 840aaf19de..c139aedf4b 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -85,7 +85,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } @Override - public float getDrag(){ + public float drag(){ return type.drag; } @@ -275,7 +275,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } @Override - public float getMass(){ + public float mass(){ return type.mass; } @@ -326,7 +326,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } @Override - public float getMaxVelocity(){ + public float maxVelocity(){ return type.maxVelocity; } @@ -357,12 +357,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ } @Override - public void getHitbox(Rectangle rectangle){ + public void hitbox(Rectangle rectangle){ rectangle.setSize(type.hitsize).setCenter(x, y); } @Override - public void getHitboxTile(Rectangle rectangle){ + public void hitboxTile(Rectangle rectangle){ rectangle.setSize(type.hitsizeTile).setCenter(x, y); } diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index 4ac8d2f761..b613415c2f 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -559,7 +559,7 @@ public class MobileInput extends InputHandler implements GestureListener{ consumed = true; player.dropCarry(); //drop off unit }else{ - Unit unit = Units.getClosest(player.getTeam(), Core.input.mouseWorld(x, y).x, Core.input.mouseWorld(x, y).y, 4f, u -> !u.isFlying() && u.getMass() <= player.mech.carryWeight); + Unit unit = Units.getClosest(player.getTeam(), Core.input.mouseWorld(x, y).x, Core.input.mouseWorld(x, y).y, 4f, u -> !u.isFlying() && u.mass() <= player.mech.carryWeight); if(unit != null){ consumed = true; diff --git a/core/src/io/anuke/mindustry/type/AmmoEntry.java b/core/src/io/anuke/mindustry/type/AmmoEntry.java index d92c7963e5..f0ef1c0c6d 100644 --- a/core/src/io/anuke/mindustry/type/AmmoEntry.java +++ b/core/src/io/anuke/mindustry/type/AmmoEntry.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.type; -/**Used to store ammo amounts in turrets.*/ +/**Used to store ammo amounts in turrets. + * TODO move inside turret class?*/ public class AmmoEntry{ public AmmoType type; public int amount; diff --git a/core/src/io/anuke/mindustry/type/Weapon.java b/core/src/io/anuke/mindustry/type/Weapon.java index d15ef9a3ae..107946661f 100644 --- a/core/src/io/anuke/mindustry/type/Weapon.java +++ b/core/src/io/anuke/mindustry/type/Weapon.java @@ -85,7 +85,7 @@ public class Weapon extends Content{ weapon.tr.trns(rotation + 180f, ammo.recoil); - shooter.getVelocity().add(weapon.tr); + shooter.velocity().add(weapon.tr); weapon.tr.trns(rotation, 3f); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 561eb9e90e..2070fff452 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -352,7 +352,7 @@ public class Block extends BaseBlock { } public void handleBulletHit(TileEntity entity, Bullet bullet){ - entity.damage(bullet.getDamage()); + entity.damage(bullet.damage()); } public void update(Tile tile){ diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index f579d3b683..976b0f0310 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -421,7 +421,7 @@ public class Tile implements Position, TargetTrait{ } @Override - public Vector2 getVelocity(){ + public Vector2 velocity(){ return Vector2.ZERO; } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java index 5a857f18e9..08392d7d32 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/DeflectorWall.java @@ -49,13 +49,13 @@ public class DeflectorWall extends Wall{ super.handleBulletHit(entity, bullet); //doesn't reflect powerful bullets - if(bullet.getDamage() > maxDamageDeflect) return; + if(bullet.damage() > maxDamageDeflect) return; float penX = Math.abs(entity.x - bullet.x), penY = Math.abs(entity.y - bullet.y); - bullet.getHitbox(rect2); + bullet.hitbox(rect2); - Vector2 position = Geometry.raycastRect(bullet.x, bullet.y, bullet.x + bullet.getVelocity().x, bullet.y + bullet.getVelocity().y, + Vector2 position = Geometry.raycastRect(bullet.x, bullet.y, bullet.x + bullet.velocity().x, bullet.y + bullet.velocity().y, rect.setCenter(entity.x, entity.y).setSize(size * tilesize + rect2.width + rect2.height)); if(position != null){ @@ -63,9 +63,9 @@ public class DeflectorWall extends Wall{ } if(penX > penY){ - bullet.getVelocity().x *= -1; + bullet.velocity().x *= -1; }else{ - bullet.getVelocity().y *= -1; + bullet.velocity().y *= -1; } bullet.updateVelocity(); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java b/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java index 307afd4425..5316227bfc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/SurgeWall.java @@ -19,7 +19,7 @@ public class SurgeWall extends Wall{ public void handleBulletHit(TileEntity entity, Bullet bullet){ super.handleBulletHit(entity, bullet); if(Mathf.chance(lightningChance)){ - Lightning.create(entity.getTeam(), Palette.surge, lightningDamage, bullet.x, bullet.y, bullet.angle() + 180f, lightningLength); + Lightning.create(entity.getTeam(), Palette.surge, lightningDamage, bullet.x, bullet.y, bullet.rot() + 180f, lightningLength); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java index 938b9e3eb8..295208554c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/LaserTurret.java @@ -33,8 +33,8 @@ public class LaserTurret extends PowerTurret{ LaserTurretEntity entity = tile.entity(); if(entity.bulletLife > 0 && entity.bullet != null){ - tr.trns(entity.rotation, size * tilesize / 2, 0f); - entity.bullet.setRotation(entity.rotation); + tr.trns(entity.rotation, size * tilesize / 2f, 0f); + entity.bullet.rot(entity.rotation); entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y); entity.bullet.time(0f); entity.heat = 1f; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java index cb639260c4..8af44e10c7 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java @@ -177,7 +177,7 @@ public class Conveyor extends Block{ } if(entity.convey.size * itemSpace < 0.9f){ - unit.getVelocity().add((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta()); + unit.velocity().add((tx * speed + centerx) * entity.delta(), (ty * speed + centery) * entity.delta()); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java index 72fa6e0939..b29ecab1b0 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java @@ -71,7 +71,7 @@ public class UnitFactory extends Block{ unit.setSpawner(tile); unit.set(tile.drawx() + Mathf.range(4), tile.drawy() + Mathf.range(4)); unit.add(); - unit.getVelocity().y = factory.launchVelocity; + unit.velocity().y = factory.launchVelocity; } }