From ec5f74b753c31ce5a68c941734ee13541c70f998 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 1 Apr 2018 11:56:11 -0400 Subject: [PATCH] Removed every single bullet type, breaking everything --- core/assets/version.properties | 4 +- .../io/anuke/mindustry/content/Weapons.java | 2 +- .../content/blocks/WeaponBlocks.java | 2 +- .../io/anuke/mindustry/core/NetClient.java | 2 +- .../io/anuke/mindustry/core/NetServer.java | 2 +- .../io/anuke/mindustry/entities/Bullet.java | 5 +- .../anuke/mindustry/entities/BulletType.java | 486 ------------------ .../io/anuke/mindustry/entities/Player.java | 1 + .../anuke/mindustry/entities/SyncEntity.java | 1 + .../entities/bullets/BulletType.java | 19 + .../entities/bullets/TurretBullets.java | 4 + .../entities/bullets/UnitBullets.java | 4 + .../entities/bullets/WeaponBullets.java | 4 + .../mindustry/entities/units/BaseUnit.java | 2 +- .../entities/units/FlyingUnitType.java | 2 +- .../entities/units/GroundUnitType.java | 2 +- .../mindustry/entities/units/UnitType.java | 2 +- .../io/anuke/mindustry/game/EventType.java | 2 +- .../io/anuke/mindustry/resource/AmmoType.java | 8 + .../io/anuke/mindustry/resource/Weapon.java | 2 +- .../world/blocks/types/defense/Turret.java | 38 +- 21 files changed, 87 insertions(+), 507 deletions(-) delete mode 100644 core/src/io/anuke/mindustry/entities/BulletType.java create mode 100644 core/src/io/anuke/mindustry/entities/bullets/BulletType.java create mode 100644 core/src/io/anuke/mindustry/entities/bullets/TurretBullets.java create mode 100644 core/src/io/anuke/mindustry/entities/bullets/UnitBullets.java create mode 100644 core/src/io/anuke/mindustry/entities/bullets/WeaponBullets.java create mode 100644 core/src/io/anuke/mindustry/resource/AmmoType.java diff --git a/core/assets/version.properties b/core/assets/version.properties index c891d54e54..9b3876f599 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Sun Apr 01 10:41:23 EDT 2018 +#Sun Apr 01 11:42:10 EDT 2018 version=release -androidBuildCode=807 +androidBuildCode=809 name=Mindustry code=3.4 build=custom build diff --git a/core/src/io/anuke/mindustry/content/Weapons.java b/core/src/io/anuke/mindustry/content/Weapons.java index d5bcb962a8..1a40400821 100644 --- a/core/src/io/anuke/mindustry/content/Weapons.java +++ b/core/src/io/anuke/mindustry/content/Weapons.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.content; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.graphics.fx.BulletFx; import io.anuke.mindustry.resource.Weapon; diff --git a/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java index 25d80a46e3..0d7a8fa443 100644 --- a/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/WeaponBlocks.java @@ -3,7 +3,7 @@ package io.anuke.mindustry.content.blocks; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Liquids; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.effect.TeslaOrb; import io.anuke.mindustry.graphics.fx.BulletFx; import io.anuke.mindustry.world.Block; diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 59943bf2c8..9b2c746eaf 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.IntSet; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.SyncEntity; import io.anuke.mindustry.entities.units.BaseUnit; diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 2ac3cd5e15..6d1479c24c 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -5,7 +5,7 @@ import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.content.Recipes; import io.anuke.mindustry.content.UpgradeRecipes; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.SyncEntity; import io.anuke.mindustry.game.EventType.GameOverEvent; diff --git a/core/src/io/anuke/mindustry/entities/Bullet.java b/core/src/io/anuke/mindustry/entities/Bullet.java index b3174a0544..0d8ef4ca04 100644 --- a/core/src/io/anuke/mindustry/entities/Bullet.java +++ b/core/src/io/anuke/mindustry/entities/Bullet.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.entities; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.entities.BulletEntity; @@ -12,14 +13,14 @@ public class Bullet extends BulletEntity{ public Timer timer = new Timer(3); public Team team; - public Bullet(BulletType type, Unit owner, float x, float y, float angle){ + public Bullet(io.anuke.mindustry.entities.bullets.BulletType type, Unit owner, float x, float y, float angle){ super(type, owner, angle); this.type = type; this.team = owner.team; set(x, y); } - public Bullet(BulletType type, Entity owner, Team team, float x, float y, float angle){ + public Bullet(io.anuke.mindustry.entities.bullets.BulletType type, Entity owner, Team team, float x, float y, float angle){ super(type, owner, angle); this.team = team; this.type = type; diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java deleted file mode 100644 index acbdfa9144..0000000000 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ /dev/null @@ -1,486 +0,0 @@ -package io.anuke.mindustry.entities; - -import com.badlogic.gdx.graphics.Color; -import io.anuke.mindustry.entities.effect.DamageArea; -import io.anuke.mindustry.entities.effect.EMP; -import io.anuke.mindustry.graphics.fx.BlockFx; -import io.anuke.mindustry.graphics.fx.BulletFx; -import io.anuke.mindustry.graphics.fx.Fx; -import io.anuke.ucore.core.Effects; -import io.anuke.ucore.core.Timers; -import io.anuke.ucore.entities.BaseBulletType; -import io.anuke.ucore.graphics.Draw; -import io.anuke.ucore.graphics.Lines; -import io.anuke.ucore.util.Angles; -import io.anuke.ucore.util.Mathf; - -import static io.anuke.mindustry.graphics.fx.Fx.*; - -public abstract class BulletType extends BaseBulletType{ - - public static final BulletType - - none = new BulletType(0f, 0){ - public void draw(Bullet b){} - }, - stone = new BulletType(1.5f, 2){ - public void draw(Bullet b){ - Draw.colorl(0.64f); - Draw.rect("blank", b.x, b.y, 2f, 2f); - Draw.reset(); - } - }, - iron = new BulletType(1.7f, 2){ - public void draw(Bullet b){ - Draw.color(Color.GRAY); - Draw.rect("bullet", b.x, b.y, b.angle()); - Draw.reset(); - } - }, - chain = new BulletType(2f, 8){ - public void draw(Bullet b){ - Draw.color(whiteOrange); - Draw.rect("chainbullet", b.x, b.y, b.angle()); - Draw.reset(); - } - }, - sniper = new BulletType(3f, 25){ - public void draw(Bullet b){ - Draw.color(Color.LIGHT_GRAY); - Lines.stroke(1f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 3f); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 4)){ - Effects.effect(BulletFx.railsmoke, b.x, b.y); - } - } - }, - emp = new BulletType(1.6f, 8){ - { - lifetime = 50f; - hitsize = 6f; - } - - public void draw(Bullet b){ - float rad = 6f + Mathf.sin(Timers.time(), 5f, 2f); - - Draw.color(Color.SKY); - Lines.circle(b.x, b.y, 4f); - Draw.rect("circle", b.x, b.y, rad, rad); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 2)){ - Effects.effect(BulletFx.empspark, b.x + Mathf.range(2), b.y + Mathf.range(2)); - } - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Timers.run(5f, ()-> new EMP(b.x, b.y, b.getDamage()).add()); - Effects.effect(BulletFx.empshockwave, b); - Effects.shake(3f, 3f, b); - } - }, - //TODO better visuals for shell - shell = new BulletType(1.1f, 60){ - { - lifetime = 110f; - hitsize = 11f; - } - - public void draw(Bullet b){ - float rad = 8f; - Draw.color(Color.ORANGE); - Draw.color(Color.GRAY); - Draw.rect("circle", b.x, b.y, rad, rad); - rad += Mathf.sin(Timers.time(), 3f, 1f); - Draw.color(Color.ORANGE); - Draw.rect("circle", b.x, b.y, rad/1.7f, rad/1.7f); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 7)){ - Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2)); - } - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Effects.shake(3f, 3f, b); - - Effects.effect(BulletFx.shellsmoke, b); - Effects.effect(BulletFx.shellexplosion, b); - - DamageArea.damage(b.team, b.x, b.y, 25f, (int)(damage * 2f/3f)); - } - }, - flak = new BulletType(2.9f, 8) { - - public void init(Bullet b) { - b.velocity.scl(Mathf.random(0.6f, 1f)); - } - - public void update(Bullet b){ - if(b.timer.get(0, 7)){ - Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2)); - } - } - - public void draw(Bullet b) { - Draw.color(Color.GRAY); - Lines.stroke(3f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 2f); - Lines.stroke(1.5f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 5f); - Draw.reset(); - } - - public void hit(Bullet b, float hitx, float hity) { - Effects.effect(BulletFx.shellsmoke, b); - for(int i = 0; i < 3; i ++){ - Bullet bullet = new Bullet(flakspark, b, hitx, hity, b.angle() + Mathf.range(120f)); - bullet.add(); - } - } - - public void despawned(Bullet b) { - hit(b, b.x, b.y); - } - }, - flakspark = new BulletType(2f, 2) { - { - drag = 0.05f; - } - - public void init(Bullet b) { - b.velocity.scl(Mathf.random(0.6f, 1f)); - } - - public void draw(Bullet b) { - Draw.color(Color.LIGHT_GRAY, Color.GRAY, b.ifract()); - Lines.stroke(2f - b.ifract()); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 2f); - Draw.reset(); - } - }, - titanshell = new BulletType(1.8f, 38){ - { - lifetime = 70f; - hitsize = 15f; - } - - public void draw(Bullet b){ - Draw.color(whiteOrange); - Draw.rect("titanshell", b.x, b.y, b.angle()); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 4)){ - Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2)); - } - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Effects.shake(3f, 3f, b); - - Effects.effect(BulletFx.shellsmoke, b); - Effects.effect(BulletFx.shockwaveSmall, b); - - DamageArea.damage(b.team, b.x, b.y, 50f, (int)(damage * 2f/3f)); - } - }, - yellowshell = new BulletType(1.2f, 20){ - { - lifetime = 60f; - hitsize = 11f; - } - - public void draw(Bullet b){ - Draw.color(whiteYellow); - Draw.rect("titanshell", b.x, b.y, b.angle()); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 4)){ - Effects.effect(Fx.smoke, b.x + Mathf.range(2), b.y + Mathf.range(2)); - } - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Effects.shake(3f, 3f, b); - - Effects.effect(BulletFx.shellsmoke, b); - Effects.effect(BulletFx.shockwaveSmall, b); - - DamageArea.damage(b.team, b.x, b.y, 25f, (int)(damage * 2f/3f)); - } - }, - blast = new BulletType(1.1f, 90){ - { - lifetime = 0f; - hitsize = 8f; - speed = 0f; - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Effects.shake(3f, 3f, b); - - Effects.effect(BlockFx.blastsmoke, b); - Effects.effect(BulletFx.blastexplosion, b); - - //TODO remove translation() usage - Angles.circleVectors(30, 6f, (nx, ny) -> { - float ang = Mathf.atan2(nx, ny); - Bullet o = new Bullet(blastshot, b, b.x + nx, b.y + ny, ang).add(); - o.damage = b.damage/9; - }); - } - - public void draw(Bullet b){} - }, - blastshot = new BulletType(1.6f, 6){ - { - lifetime = 7f; - } - public void draw(Bullet b){} - }, - small = new BulletType(1.5f, 2){ - public void draw(Bullet b){ - Draw.color(glowy); - Draw.rect("shot", b.x, b.y, b.angle() - 45); - Draw.reset(); - } - }, - smallSlow = new BulletType(1.2f, 2){ - public void draw(Bullet b){ - Draw.color(Color.ORANGE); - Draw.rect("shot", b.x, b.y, b.angle() - 45); - Draw.reset(); - } - }, - purple = new BulletType(1.6f, 2){ - Color color = new Color(0x8b5ec9ff); - - public void draw(Bullet b){ - Draw.color(color); - Draw.rect("bullet", b.x, b.y, b.angle()); - Draw.reset(); - } - }, - flame = new BulletType(0.7f, 5){ //for turrets - public void draw(Bullet b){ - Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime); - float size = 6f-b.time/lifetime*5f; - Draw.rect("circle", b.x, b.y, size, size); - Draw.reset(); - } - }, - plasmaflame = new BulletType(0.8f, 17){ - { - lifetime = 65f; - } - public void draw(Bullet b){ - Draw.color(Color.valueOf("efa66c"), Color.valueOf("72deaf"), b.time/lifetime); - float size = 7f-b.time/lifetime*6f; - Draw.rect("circle", b.x, b.y, size, size); - Draw.reset(); - } - }, - flameshot = new BulletType(0.5f, 3){ //for enemies - public void draw(Bullet b){ - Draw.color(Color.ORANGE, Color.SCARLET, b.time/lifetime); - float size = 6f-b.time/lifetime*5f; - Draw.rect("circle", b.x, b.y, size, size); - Draw.reset(); - } - }, - shot = new BulletType(2.7f, 5){ - { - lifetime = 40; - } - - public void draw(Bullet b){ - Draw.color(Color.WHITE, lightOrange, b.fract()/2f + 0.25f); - Lines.stroke(1.5f); - Lines.lineAngle(b.x, b.y, b.angle(), 3f); - Draw.reset(); - } - }, - spread = new BulletType(2.4f, 9) { - { - lifetime = 70; - } - - public void draw(Bullet b) { - float size = 3f - b.ifract()*1f; - - Draw.color(Color.PURPLE, Color.WHITE, 0.8f); - Lines.stroke(1f); - Lines.circle(b.x, b.y, size); - Draw.reset(); - } - }, - cluster = new BulletType(4.5f, 12){ - { - lifetime = 60; - drag = 0.05f; - } - - public void draw(Bullet b){ - Lines.stroke(2f); - Draw.color(lightOrange, Color.WHITE, 0.4f); - Lines.poly(b.x, b.y, 3, 1.6f, b.angle()); - Lines.stroke(1f); - Draw.color(Color.WHITE, lightOrange, b.ifract()/2f); - Draw.alpha(b.ifract()); - Lines.spikes(b.x, b.y, 1.5f, 2f, 6); - Draw.reset(); - } - - public void despawned(Bullet b){ - hit(b); - } - - public void hit(Bullet b, float hitx, float hity){ - Effects.shake(1.5f, 1.5f, b); - - Effects.effect(BulletFx.clusterbomb, b); - - DamageArea.damage(b.team, b.x, b.y, 35f, damage); - } - }, - vulcan = new BulletType(4.5f, 12) { - { - lifetime = 50; - } - - public void init(Bullet b) { - Timers.reset(b, "smoke", Mathf.random(4f)); - } - - public void draw(Bullet b){ - Draw.color(lightGray); - Lines.stroke(1f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), 2f); - Draw.reset(); - } - - public void update(Bullet b){ - if(b.timer.get(0, 4)){ - Effects.effect(BulletFx.chainsmoke, b.x, b.y); - } - } - }, - shockshell = new BulletType(5.5f, 11) { - - { - drag = 0.03f; - lifetime = 30f; - } - - public void init(Bullet b) { - b.velocity.scl(Mathf.random(0.5f, 1f)); - } - - public void draw(Bullet b) { - Draw.color(Color.WHITE, Color.ORANGE, b.ifract()); - Lines.stroke(2f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), b.fract()*5f); - Draw.reset(); - } - - public void despawned(Bullet b) { - hit(b); - } - - public void hit(Bullet b, float hitx, float hity) { - for(int i = 0; i < 4; i ++){ - Bullet bullet = new Bullet(scrap, b, b.x, b.y, b.angle() + Mathf.range(80f)); - bullet.add(); - } - } - }, - scrap = new BulletType(2f, 3) { - { - drag = 0.06f; - lifetime = 30f; - } - - public void init(Bullet b) { - b.velocity.scl(Mathf.random(0.5f, 1f)); - } - - public void draw(Bullet b) { - Draw.color(Color.WHITE, Color.ORANGE, b.ifract()); - Lines.stroke(1f); - Lines.lineAngleCenter(b.x, b.y, b.angle(), b.fract()*4f); - Draw.reset(); - } - }, - beamlaser = new BulletType(0.001f, 38) { - float length = 230f; - { - drawSize = length*2f+20f; - lifetime = 15f; - } - - public void init(Bullet b) { - DamageArea.damageLine(b.team, BulletFx.beamhit, b.x, b.y, b.angle(), length, damage); - } - - public void draw(Bullet b) { - float f = b.fract()*1.5f; - - Draw.color(beam); - Draw.rect("circle", b.x, b.y, 6f*f, 6f*f); - Lines.stroke(3f * f); - Lines.lineAngle(b.x, b.y, b.angle(), length); - - Lines.stroke(2f * f); - Lines.lineAngle(b.x, b.y, b.angle(), length + 6f); - Lines.stroke(1f * f); - Lines.lineAngle(b.x, b.y, b.angle(), length + 12f); - - Draw.color(beamLight); - Lines.stroke(1.5f * f); - Draw.rect("circle", b.x, b.y, 3f*f, 3f*f); - Lines.lineAngle(b.x, b.y, b.angle(), length); - } - }; - - private BulletType(float speed, int damage){ - this.speed = speed; - this.damage = damage; - } - - @Override - public void hit(Bullet b, float hitx, float hity){ - Effects.effect(Fx.hit, hitx, hity); - } -} diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 7b93bd8693..ffd7355c15 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.content.Weapons; import io.anuke.mindustry.content.blocks.Blocks; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.graphics.fx.ExplosionFx; import io.anuke.mindustry.graphics.fx.Fx; diff --git a/core/src/io/anuke/mindustry/entities/SyncEntity.java b/core/src/io/anuke/mindustry/entities/SyncEntity.java index 3dea8724de..448a259e7c 100644 --- a/core/src/io/anuke/mindustry/entities/SyncEntity.java +++ b/core/src/io/anuke/mindustry/entities/SyncEntity.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.TimeUtils; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.DestructibleEntity; import io.anuke.ucore.util.Mathf; diff --git a/core/src/io/anuke/mindustry/entities/bullets/BulletType.java b/core/src/io/anuke/mindustry/entities/bullets/BulletType.java new file mode 100644 index 0000000000..4d9fb6be1b --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/bullets/BulletType.java @@ -0,0 +1,19 @@ +package io.anuke.mindustry.entities.bullets; + +import io.anuke.mindustry.entities.Bullet; +import io.anuke.mindustry.graphics.fx.Fx; +import io.anuke.ucore.core.Effects; +import io.anuke.ucore.entities.BaseBulletType; + +public abstract class BulletType extends BaseBulletType{ + + private BulletType(float speed, int damage){ + this.speed = speed; + this.damage = damage; + } + + @Override + public void hit(Bullet b, float hitx, float hity){ + Effects.effect(Fx.hit, hitx, hity); + } +} diff --git a/core/src/io/anuke/mindustry/entities/bullets/TurretBullets.java b/core/src/io/anuke/mindustry/entities/bullets/TurretBullets.java new file mode 100644 index 0000000000..df5aba1054 --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/bullets/TurretBullets.java @@ -0,0 +1,4 @@ +package io.anuke.mindustry.entities.bullets; + +public class TurretBullets { +} diff --git a/core/src/io/anuke/mindustry/entities/bullets/UnitBullets.java b/core/src/io/anuke/mindustry/entities/bullets/UnitBullets.java new file mode 100644 index 0000000000..63a70c205c --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/bullets/UnitBullets.java @@ -0,0 +1,4 @@ +package io.anuke.mindustry.entities.bullets; + +public class UnitBullets { +} diff --git a/core/src/io/anuke/mindustry/entities/bullets/WeaponBullets.java b/core/src/io/anuke/mindustry/entities/bullets/WeaponBullets.java new file mode 100644 index 0000000000..78fc0c3a43 --- /dev/null +++ b/core/src/io/anuke/mindustry/entities/bullets/WeaponBullets.java @@ -0,0 +1,4 @@ +package io.anuke.mindustry.entities.bullets; + +public class WeaponBullets { +} diff --git a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java index e5dfc8a66c..06a036aed9 100644 --- a/core/src/io/anuke/mindustry/entities/units/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/units/BaseUnit.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.entities.units; import io.anuke.mindustry.entities.Bullet; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.game.Team; import io.anuke.ucore.entities.Entity; diff --git a/core/src/io/anuke/mindustry/entities/units/FlyingUnitType.java b/core/src/io/anuke/mindustry/entities/units/FlyingUnitType.java index 8da49b4206..daab095d7a 100644 --- a/core/src/io/anuke/mindustry/entities/units/FlyingUnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/FlyingUnitType.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.entities.units; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ObjectSet; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.game.TeamInfo.TeamData; import io.anuke.mindustry.graphics.fx.Fx; diff --git a/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java index 0e1d7ea4d2..fe0735519a 100644 --- a/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/GroundUnitType.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.entities.units; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ObjectSet; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.game.TeamInfo.TeamData; diff --git a/core/src/io/anuke/mindustry/entities/units/UnitType.java b/core/src/io/anuke/mindustry/entities/units/UnitType.java index 503130759b..b3239c561e 100644 --- a/core/src/io/anuke/mindustry/entities/units/UnitType.java +++ b/core/src/io/anuke/mindustry/entities/units/UnitType.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.entities.units; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.entities.Bullet; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.graphics.fx.ExplosionFx; diff --git a/core/src/io/anuke/mindustry/game/EventType.java b/core/src/io/anuke/mindustry/game/EventType.java index 7ae7b972d4..6974878805 100644 --- a/core/src/io/anuke/mindustry/game/EventType.java +++ b/core/src/io/anuke/mindustry/game/EventType.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.game; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.resource.Weapon; diff --git a/core/src/io/anuke/mindustry/resource/AmmoType.java b/core/src/io/anuke/mindustry/resource/AmmoType.java new file mode 100644 index 0000000000..c5b84084b1 --- /dev/null +++ b/core/src/io/anuke/mindustry/resource/AmmoType.java @@ -0,0 +1,8 @@ +package io.anuke.mindustry.resource; + +import io.anuke.mindustry.entities.bullets.BulletType; + +public abstract class AmmoType { + + public abstract BulletType getBullet(Item item); +} diff --git a/core/src/io/anuke/mindustry/resource/Weapon.java b/core/src/io/anuke/mindustry/resource/Weapon.java index d71c05bda0..808e48ce6c 100644 --- a/core/src/io/anuke/mindustry/resource/Weapon.java +++ b/core/src/io/anuke/mindustry/resource/Weapon.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.resource; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.Bullet; -import io.anuke.mindustry.entities.BulletType; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.net.Net; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java index 23076b8eaf..7cb3c48680 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Turret.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types.defense; import com.badlogic.gdx.graphics.Color; import io.anuke.mindustry.entities.*; +import io.anuke.mindustry.entities.bullets.BulletType; import io.anuke.mindustry.graphics.fx.Fx; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.resource.Item; @@ -37,7 +38,7 @@ public class Turret extends Block{ protected float shotTransation = 2; protected float shotDelayScale = 0; protected String shootsound = "shoot"; - protected BulletType bullet = BulletType.iron; + protected io.anuke.mindustry.entities.bullets.BulletType bullet = BulletType.iron; protected Item ammo; protected int ammoMultiplier = 20; protected int maxammo = 400; @@ -48,6 +49,7 @@ public class Turret extends Block{ protected int soundReload = 0; protected Translator tr = new Translator(); protected String base = null; //name of the region to draw under turret, usually null + protected ShootStyle style = ShootStyle.normal; public Turret(String name) { super(name); @@ -149,11 +151,8 @@ public class Turret extends Block{ entity.rotation = Mathf.slerpDelta(entity.rotation, targetRot, rotatespeed); - if(Angles.angleDist(entity.rotation, targetRot) < shootCone && entity.timer.get(timerReload, reload)){ - if(shootsound != null && entity.timer.get(timerSound, soundReload)) Effects.sound(shootsound, entity); - shoot(tile); - consumeAmmo(tile); - entity.ammo --; + if(Angles.angleDist(entity.rotation, targetRot) < shootCone/* && entity.timer.get(timerReload, reload)*/){ + style.shoot(this, entity); } } } @@ -216,7 +215,6 @@ public class Turret extends Block{ bullet(tile, entity.rotation + Mathf.range(inaccuracy)); }); } - } Effects.effect(shootEffect, tile.drawx() + tr.x, @@ -235,6 +233,32 @@ public class Turret extends Block{ public TileEntity getEntity(){ return new TurretEntity(); } + + public enum ShootStyle{ + normal{ + void shoot(Turret turret, TurretEntity entity){ + if(entity.timer.get(turret.timerReload, turret.reload)){ + if(turret.shootsound != null && entity.timer.get(turret.timerSound, turret.soundReload)) + Effects.sound(turret.shootsound, entity); + turret.consumeAmmo(entity.tile); + entity.ammo --; + + turret.tr.trns(entity.rotation, turret.size * tilesize/2); + + turret.bullet(entity.tile, entity.rotation + Mathf.range(turret.inaccuracy)); + + Effects.effect(turret.shootEffect, entity.tile.drawx() + turret.tr.x, + entity.tile.drawy() + turret.tr.y, entity.rotation); + + if(turret.shootShake > 0){ + Effects.shake(turret.shootShake, turret.shootShake, entity.tile.entity); + } + } + } + }; + + abstract void shoot(Turret turret, TurretEntity entity); + } public static class TurretEntity extends TileEntity{ public TileEntity blockTarget;