Removed AmmoType class completely

This commit is contained in:
Anuken 2019-01-07 16:01:27 -05:00
parent de02061b5e
commit 5743d30851
29 changed files with 480 additions and 811 deletions

View File

@ -1,254 +0,0 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.content.bullets.*;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.ContentType;
public class AmmoTypes implements ContentList{
public static AmmoType
bulletCopper, bulletDense, bulletThorium, bulletSilicon, bulletPyratite,
bulletDenseBig, bulletPyratiteBig, bulletThoriumBig,
shock, bombExplosive, bombIncendiary, bombOil, shellCarbide, flamerThermite, weaponMissile, weaponMissileSwarm, bulletMech,
healBlaster, bulletGlaive,
flakExplosive, flakPlastic, flakSurge,
missileExplosive, missileIncindiary, missileSurge,
artilleryDense, artilleryPlastic, artilleryHoming, artilleryIncindiary, artilleryExplosive, unitArtillery,
basicFlame, lancerLaser, lightning, meltdownLaser, burstLaser,
fuseShotgun, oil, water, lava, cryofluid, arc;
@Override
public void load(){
//weapon specific
bulletMech = new AmmoType(StandardBullets.mechSmall){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
reloadMultiplier = 1f;
inaccuracy = 5f;
}};
bulletGlaive = new AmmoType(Items.pyratite, StandardBullets.glaive, 3){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
inaccuracy = 3f;
}};
healBlaster = new AmmoType(TurretBullets.healBullet){{
shootEffect = ShootFx.shootHeal;
smokeEffect = BulletFx.hitLaser;
reloadMultiplier = 1f;
inaccuracy = 2f;
}};
shock = new AmmoType(TurretBullets.lightning){{
shootEffect = BulletFx.hitLancer;
smokeEffect = Fx.none;
}};
shellCarbide = new AmmoType(WeaponBullets.shellCarbide){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
bombExplosive = new AmmoType(WeaponBullets.bombExplosive){{
shootEffect = Fx.none;
smokeEffect = Fx.none;
}};
bombIncendiary = new AmmoType(WeaponBullets.bombIncendiary){{
shootEffect = Fx.none;
smokeEffect = Fx.none;
}};
bombOil = new AmmoType(WeaponBullets.bombOil){{
shootEffect = Fx.none;
smokeEffect = Fx.none;
}};
flamerThermite = new AmmoType(TurretBullets.basicFlame){{
shootEffect = ShootFx.shootSmallFlame;
}};
weaponMissile = new AmmoType(MissileBullets.javelin){{
shootEffect = BulletFx.hitBulletSmall;
smokeEffect = Fx.none;
reloadMultiplier = 1.2f;
}};
weaponMissileSwarm = new AmmoType(MissileBullets.swarm){{
shootEffect = BulletFx.hitBulletSmall;
smokeEffect = ShootFx.shootSmallSmoke;
reloadMultiplier = 1.2f;
}};
//bullets
bulletCopper = new AmmoType(Items.copper, StandardBullets.copper, 5){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
reloadMultiplier = 1f;
inaccuracy = 5f;
}};
bulletDense = new AmmoType(Items.densealloy, StandardBullets.dense, 2){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
reloadMultiplier = 0.6f;
}};
bulletThorium = new AmmoType(Items.thorium, StandardBullets.thorium, 2){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
bulletSilicon = new AmmoType(Items.silicon, StandardBullets.homing, 5){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
reloadMultiplier = 1.4f;
}};
bulletPyratite = new AmmoType(Items.pyratite, StandardBullets.tracer, 3){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
inaccuracy = 3f;
}};
bulletDenseBig = new AmmoType(Items.densealloy, StandardBullets.denseBig, 1){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
bulletThoriumBig = new AmmoType(Items.thorium, StandardBullets.thoriumBig, 1){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
bulletPyratiteBig = new AmmoType(Items.pyratite, StandardBullets.tracerBig, 2){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
inaccuracy = 3f;
}};
//flak
flakExplosive = new AmmoType(Items.blastCompound, FlakBullets.explosive, 5){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
flakPlastic = new AmmoType(Items.plastanium, FlakBullets.plastic, 5){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}};
flakSurge = new AmmoType(Items.surgealloy, FlakBullets.surge, 5){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
reloadMultiplier = 1/2f;
}};
//missiles
missileExplosive = new AmmoType(Items.blastCompound, MissileBullets.explosive, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.2f;
}};
missileIncindiary = new AmmoType(Items.pyratite, MissileBullets.incindiary, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.0f;
}};
missileSurge = new AmmoType(Items.surgealloy, MissileBullets.surge, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.1f;
}};
//artillery
artilleryDense = new AmmoType(Items.densealloy, ArtilleryBullets.dense, 2){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
}};
artilleryPlastic = new AmmoType(Items.plastanium, ArtilleryBullets.plastic, 2){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.4f;
}};
artilleryHoming = new AmmoType(Items.silicon, ArtilleryBullets.homing, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 0.9f;
}};
artilleryIncindiary = new AmmoType(Items.pyratite, ArtilleryBullets.incindiary, 2){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.2f;
}};
artilleryExplosive = new AmmoType(Items.blastCompound, ArtilleryBullets.explosive, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.6f;
}};
unitArtillery = new AmmoType(Items.blastCompound, ArtilleryBullets.unit, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
reloadMultiplier = 1.6f;
}};
//flame
basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f){{
shootEffect = ShootFx.shootSmallFlame;
}};
//power
lancerLaser = new AmmoType(TurretBullets.lancerLaser);
burstLaser = new AmmoType(TurretBullets.burstLaser){{
range = 60f;
}};
lightning = new AmmoType(TurretBullets.lightning);
arc = new AmmoType(TurretBullets.arc);
meltdownLaser = new AmmoType(TurretBullets.meltdownLaser);
fuseShotgun = new AmmoType(Items.densealloy, TurretBullets.fuseShot, 1f){{
shootEffect = Fx.none;
smokeEffect = ShootFx.shootBigSmoke2;
}};
//liquid
oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f);
water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f);
lava = new AmmoType(Liquids.lava, TurretBullets.lavaShot, 0.3f);
cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f);
}
@Override
public ContentType type(){
return ContentType.ammo;
}
}

View File

@ -0,0 +1,17 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.type.ContentType;
public class Bullets implements ContentList{
@Override
public void load(){
}
@Override
public ContentType type(){
return ContentType.bullet;
}
}

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.content.bullets.*;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.ContentList;
@ -8,7 +9,7 @@ import io.anuke.mindustry.type.Weapon;
public class Weapons implements ContentList{
public static Weapon blaster, blasterSmall, glaiveBlaster, droneBlaster, healBlaster, healBlasterDrone, chainBlaster, shockgun,
sapper, swarmer, bomber, bomberTrident, flakgun, flamethrower, missiles, artillery, laserBurster, healBlasterDrone2;
swarmer, bomber, bomberTrident, flakgun, flamethrower, missiles, artillery, laserBurster, healBlasterDrone2;
@Override
public void load(){
@ -18,7 +19,7 @@ public class Weapons implements ContentList{
reload = 14f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletMech;
ammo = StandardBullets.mechSmall;
}};
blasterSmall = new Weapon("blaster"){{
@ -26,7 +27,7 @@ public class Weapons implements ContentList{
reload = 15f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletCopper;
ammo = StandardBullets.copper;
}};
glaiveBlaster = new Weapon("bomber"){{
@ -34,7 +35,7 @@ public class Weapons implements ContentList{
reload = 10f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletGlaive;
ammo = StandardBullets.glaive;
}};
droneBlaster = new Weapon("blaster"){{
@ -43,7 +44,7 @@ public class Weapons implements ContentList{
width = 1f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletCopper;
ammo = StandardBullets.copper;
}};
healBlaster = new Weapon("heal-blaster"){{
@ -52,7 +53,7 @@ public class Weapons implements ContentList{
roundrobin = false;
ejectEffect = Fx.none;
recoil = 2f;
ammo = AmmoTypes.healBlaster;
ammo = TurretBullets.healBullet;
}};
missiles = new Weapon("missiles"){{
@ -64,7 +65,7 @@ public class Weapons implements ContentList{
ejectEffect = Fx.none;
velocityRnd = 0.2f;
spacing = 1f;
ammo = AmmoTypes.weaponMissile;
ammo = MissileBullets.javelin;
}};
swarmer = new Weapon("swarmer"){{
@ -77,7 +78,7 @@ public class Weapons implements ContentList{
roundrobin = true;
ejectEffect = Fx.none;
shake = 3f;
ammo = AmmoTypes.weaponMissileSwarm;
ammo = MissileBullets.swarm;
}};
chainBlaster = new Weapon("chain-blaster"){{
@ -85,7 +86,7 @@ public class Weapons implements ContentList{
reload = 28f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletCopper;
ammo = StandardBullets.copper;
}};
shockgun = new Weapon("shockgun"){{
@ -96,7 +97,7 @@ public class Weapons implements ContentList{
inaccuracy = 0f;
velocityRnd = 0.2f;
ejectEffect = Fx.none;
ammo = AmmoTypes.shock;
ammo = TurretBullets.lightning;
}};
flakgun = new Weapon("flakgun"){{
@ -108,7 +109,7 @@ public class Weapons implements ContentList{
recoil = 3f;
velocityRnd = 0.1f;
ejectEffect = ShootFx.shellEjectMedium;
ammo = AmmoTypes.shellCarbide;
ammo = ArtilleryBullets.dense;
}};
flamethrower = new Weapon("flamethrower"){{
@ -117,7 +118,7 @@ public class Weapons implements ContentList{
roundrobin = true;
recoil = 1f;
ejectEffect = Fx.none;
ammo = AmmoTypes.flamerThermite;
ammo = TurretBullets.basicFlame;
}};
artillery = new Weapon("artillery"){{
@ -127,15 +128,7 @@ public class Weapons implements ContentList{
recoil = 5f;
shake = 2f;
ejectEffect = ShootFx.shellEjectMedium;
ammo = AmmoTypes.unitArtillery;
}};
sapper = new Weapon("sapper"){{
length = 1.5f;
reload = 12f;
roundrobin = true;
ejectEffect = ShootFx.shellEjectSmall;
ammo = AmmoTypes.bulletDense;
ammo = ArtilleryBullets.unit;
}};
bomber = new Weapon("bomber"){{
@ -146,7 +139,7 @@ public class Weapons implements ContentList{
ejectEffect = Fx.none;
velocityRnd = 1f;
inaccuracy = 40f;
ammo = AmmoTypes.bombExplosive;
ammo = WeaponBullets.bombExplosive;
}};
bomberTrident = new Weapon("bomber"){{
@ -158,7 +151,7 @@ public class Weapons implements ContentList{
ejectEffect = Fx.none;
velocityRnd = 1f;
inaccuracy = 40f;
ammo = AmmoTypes.bombExplosive;
ammo = WeaponBullets.bombExplosive;
}};
laserBurster = new Weapon("bomber"){{
@ -167,7 +160,7 @@ public class Weapons implements ContentList{
width = 0f;
roundrobin = true;
ejectEffect = Fx.none;
ammo = AmmoTypes.lancerLaser;
ammo = TurretBullets.lancerLaser;
}};
healBlasterDrone = new Weapon("heal-blaster"){{
@ -177,7 +170,7 @@ public class Weapons implements ContentList{
roundrobin = true;
ejectEffect = Fx.none;
recoil = 2f;
ammo = AmmoTypes.healBlaster;
ammo = TurretBullets.healBullet;
}};
healBlasterDrone2 = new Weapon("heal-blaster"){{
@ -187,7 +180,7 @@ public class Weapons implements ContentList{
roundrobin = true;
ejectEffect = Fx.none;
recoil = 2f;
ammo = AmmoTypes.healBlaster;
ammo = TurretBullets.healBullet;
}};
}

View File

@ -1,17 +1,14 @@
package io.anuke.mindustry.content.blocks;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.Color;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.AmmoTypes;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.content.bullets.*;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.defense.turrets.*;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.math.Angles;
import io.anuke.arc.math.Mathf;
public class TurretBlocks extends BlockList implements ContentList{
public static Block duo, /*scatter,*/
@ -20,7 +17,12 @@ public class TurretBlocks extends BlockList implements ContentList{
@Override
public void load(){
duo = new DoubleTurret("duo"){{
ammoTypes = new AmmoType[]{AmmoTypes.bulletCopper, AmmoTypes.bulletDense, AmmoTypes.bulletPyratite, AmmoTypes.bulletSilicon};
ammo(
Items.copper, StandardBullets.copper,
Items.densealloy, StandardBullets.dense,
Items.pyratite, StandardBullets.tracer,
Items.silicon, StandardBullets.homing
);
reload = 25f;
restitution = 0.03f;
range = 90f;
@ -32,7 +34,11 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
hail = new ArtilleryTurret("hail"){{
ammoTypes = new AmmoType[]{AmmoTypes.artilleryDense, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary};
ammo(
Items.densealloy, ArtilleryBullets.dense,
Items.silicon, ArtilleryBullets.homing,
Items.pyratite, ArtilleryBullets.incendiary
);
reload = 60f;
recoil = 2f;
range = 230f;
@ -41,29 +47,22 @@ public class TurretBlocks extends BlockList implements ContentList{
health = 120;
}};
scorch = new LiquidTurret("scorch"){
protected TextureRegion shootRegion;
@Override
public void load(){
super.load();
shootRegion = Core.atlas.find(name + "-shoot");
}
{
ammoTypes = new AmmoType[]{AmmoTypes.basicFlame};
scorch = new LiquidTurret("scorch"){{
ammo(Liquids.oil, TurretBullets.basicFlame);
recoil = 0f;
reload = 4f;
shootCone = 50f;
ammoUseEffect = ShootFx.shellEjectSmall;
health = 160;
drawer = (tile, entity) -> Draw.rect(entity.target != null ? shootRegion : region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
}
};
}};
wave = new LiquidTurret("wave"){{
ammoTypes = new AmmoType[]{AmmoTypes.water, AmmoTypes.lava, AmmoTypes.cryofluid, AmmoTypes.oil};
ammo(
Liquids.water, TurretBullets.waterShot,
Liquids.lava, TurretBullets.lavaShot,
Liquids.cryofluid, TurretBullets.cryoShot,
Liquids.oil, TurretBullets.oilShot
);
size = 2;
recoil = 0f;
reload = 4f;
@ -88,7 +87,7 @@ public class TurretBlocks extends BlockList implements ContentList{
chargeTime = 60f;
chargeMaxDelay = 30f;
chargeEffects = 7;
shootType = AmmoTypes.lancerLaser;
shootType = TurretBullets.lancerLaser;
recoil = 2f;
reload = 100f;
cooldown = 0.03f;
@ -106,7 +105,7 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
arc = new PowerTurret("arc"){{
shootType = AmmoTypes.arc;
shootType = TurretBullets.arc;
reload = 85f;
shootShake = 1f;
shootCone = 40f;
@ -121,7 +120,11 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
swarmer = new BurstTurret("swarmer"){{
ammoTypes = new AmmoType[]{AmmoTypes.missileExplosive, AmmoTypes.missileIncindiary, AmmoTypes.missileSurge};
ammo(
Items.blastCompound, MissileBullets.explosive,
Items.pyratite, MissileBullets.incindiary,
Items.surgealloy, MissileBullets.surge
);
reload = 50f;
shots = 4;
burstSpacing = 5;
@ -132,20 +135,17 @@ public class TurretBlocks extends BlockList implements ContentList{
health = 380;
}};
salvo = new BurstTurret("salvo"){
TextureRegion[] panels = new TextureRegion[2];
salvo = new BurstTurret("salvo"){{
ammo(
Items.copper, StandardBullets.copper,
Items.densealloy, StandardBullets.dense,
Items.pyratite, StandardBullets.tracer,
Items.silicon, StandardBullets.homing,
Items.thorium, StandardBullets.thorium
);
@Override
public void load() {
super.load();
panels[0] = Core.atlas.find(name + "-panel-left");
panels[1] = Core.atlas.find(name + "-panel-right");
}
{
size = 2;
range = 120f;
ammoTypes = new AmmoType[]{AmmoTypes.bulletCopper, AmmoTypes.bulletDense, AmmoTypes.bulletPyratite, AmmoTypes.bulletThorium, AmmoTypes.bulletSilicon};
reload = 35f;
restitution = 0.03f;
ammoEjectBack = 3f;
@ -155,31 +155,17 @@ public class TurretBlocks extends BlockList implements ContentList{
burstSpacing = 4;
shots = 3;
ammoUseEffect = ShootFx.shellEjectBig;
drawer = (tile, entity) -> {
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
float offsetx = (int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 3f);
float offsety = -(int) (abscurve(Mathf.curve(entity.reload / reload, 0.3f, 0.2f)) * 2f);
for(int i : Mathf.signs){
float rot = entity.rotation + 90 * i;
Draw.rect(panels[i == -1 ? 0 : 1],
tile.drawx() + tr2.x + Angles.trnsx(rot, offsetx, offsety),
tile.drawy() + tr2.y + Angles.trnsy(rot, -offsetx, offsety), entity.rotation - 90);
}
};
health = 360;
}
/** Converts a value range from 0-1 to a value range 0-1-0. */
float abscurve(float f){
return 1f - Math.abs(f - 0.5f) * 2f;
}
};
}};
ripple = new ArtilleryTurret("ripple"){{
ammoTypes = new AmmoType[]{AmmoTypes.artilleryDense, AmmoTypes.artilleryHoming, AmmoTypes.artilleryIncindiary, AmmoTypes.artilleryExplosive, AmmoTypes.artilleryPlastic};
ammo(
Items.densealloy, ArtilleryBullets.dense,
Items.silicon, ArtilleryBullets.homing,
Items.pyratite, ArtilleryBullets.incendiary,
Items.blastCompound, ArtilleryBullets.explosive,
Items.plastanium, ArtilleryBullets.plastic
);
size = 3;
shots = 4;
inaccuracy = 12f;
@ -197,7 +183,11 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
cyclone = new ItemTurret("cyclone"){{
ammoTypes = new AmmoType[]{AmmoTypes.flakExplosive, AmmoTypes.flakPlastic, AmmoTypes.flakSurge};
ammo(
Items.blastCompound, FlakBullets.explosive,
Items.plastanium, FlakBullets.plastic,
Items.surgealloy, FlakBullets.surge
);
xRand = 4f;
reload = 8f;
range = 145f;
@ -211,7 +201,7 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
fuse = new ItemTurret("fuse"){{
ammoTypes = new AmmoType[]{AmmoTypes.fuseShotgun};
ammo(Items.densealloy, TurretBullets.fuseShot);
reload = 50f;
shootShake = 4f;
range = 80f;
@ -223,7 +213,11 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
spectre = new DoubleTurret("spectre"){{
ammoTypes = new AmmoType[]{AmmoTypes.bulletDenseBig, AmmoTypes.bulletPyratiteBig, AmmoTypes.bulletThoriumBig};
ammo(
Items.densealloy, StandardBullets.denseBig,
Items.pyratite, StandardBullets.tracerBig,
Items.thorium, StandardBullets.thoriumBig
);
reload = 6f;
coolantMultiplier = 0.5f;
maxCoolantUsed = 1.5f;
@ -243,7 +237,7 @@ public class TurretBlocks extends BlockList implements ContentList{
}};
meltdown = new LaserTurret("meltdown"){{
shootType = AmmoTypes.meltdownLaser;
shootType = TurretBullets.meltdownLaser;
shootEffect = ShootFx.shootBigSmoke2;
shootCone = 40f;
recoil = 4f;

View File

@ -9,13 +9,12 @@ import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.game.ContentList;
public class ArtilleryBullets extends BulletList implements ContentList{
public static BulletType dense, plastic, plasticFrag, homing, incindiary, explosive, surge, unit;
public static BulletType dense, plastic, plasticFrag, homing, incendiary, explosive, surge, unit;
@Override
public void load(){
dense = new ArtilleryBulletType(3f, 0, "shell"){
{
dense = new ArtilleryBulletType(3f, 0, "shell"){{
hitEffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 50f;
@ -23,11 +22,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
collidesTiles = false;
splashDamageRadius = 25f;
splashDamage = 33f;
}
};
}};
plasticFrag = new BasicBulletType(2.5f, 6, "bullet"){
{
plasticFrag = new BasicBulletType(2.5f, 6, "bullet"){{
bulletWidth = 10f;
bulletHeight = 12f;
bulletShrink = 1f;
@ -35,11 +32,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
backColor = Palette.plastaniumBack;
frontColor = Palette.plastaniumFront;
despawnEffect = Fx.none;
}
};
}};
plastic = new ArtilleryBulletType(3.3f, 0, "shell"){
{
plastic = new ArtilleryBulletType(3.3f, 0, "shell"){{
hitEffect = BulletFx.plasticExplosion;
knockback = 1f;
lifetime = 55f;
@ -51,11 +46,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
fragBullets = 9;
backColor = Palette.plastaniumBack;
frontColor = Palette.plastaniumFront;
}
};
}};
homing = new ArtilleryBulletType(3f, 0, "shell"){
{
homing = new ArtilleryBulletType(3f, 0, "shell"){{
hitEffect = BulletFx.flakExplosion;
knockback = 0.8f;
lifetime = 45f;
@ -65,11 +58,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
splashDamage = 33f;
homingPower = 2f;
homingRange = 50f;
}
};
}};
incindiary = new ArtilleryBulletType(3f, 0, "shell"){
{
incendiary = new ArtilleryBulletType(3f, 0, "shell"){{
hitEffect = BulletFx.blastExplosion;
knockback = 0.8f;
lifetime = 60f;
@ -82,11 +73,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
frontColor = Palette.lightishOrange;
backColor = Palette.lightOrange;
trailEffect = BulletFx.incendTrail;
}
};
}};
explosive = new ArtilleryBulletType(2f, 0, "shell"){
{
explosive = new ArtilleryBulletType(2f, 0, "shell"){{
hitEffect = BulletFx.blastExplosion;
knockback = 0.8f;
lifetime = 70f;
@ -96,11 +85,9 @@ public class ArtilleryBullets extends BulletList implements ContentList{
splashDamage = 50f;
backColor = Palette.missileYellowBack;
frontColor = Palette.missileYellow;
}
};
}};
unit = new ArtilleryBulletType(2f, 0, "shell"){
{
unit = new ArtilleryBulletType(2f, 0, "shell"){{
hitEffect = BulletFx.blastExplosion;
knockback = 0.8f;
lifetime = 90f;
@ -111,13 +98,10 @@ public class ArtilleryBullets extends BulletList implements ContentList{
splashDamage = 50f;
backColor = Palette.bulletYellowBack;
frontColor = Palette.bulletYellow;
}
};
}};
surge = new ArtilleryBulletType(3f, 0, "shell"){
{
surge = new ArtilleryBulletType(3f, 0, "shell"){{
//TODO
}
};
}};
}
}

View File

@ -2,10 +2,11 @@ package io.anuke.mindustry.content.bullets;
import io.anuke.arc.graphics.Color;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.entities.bullet.BasicBulletType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.graphics.Palette;
public class StandardBullets extends BulletList implements ContentList{
public static BulletType copper, dense, thorium, homing, tracer, mechSmall, glaive, denseBig, thoriumBig, tracerBig;
@ -13,39 +14,40 @@ public class StandardBullets extends BulletList implements ContentList{
@Override
public void load(){
copper = new BasicBulletType(2.5f, 7, "bullet"){
{
copper = new BasicBulletType(2.5f, 7, "bullet"){{
bulletWidth = 7f;
bulletHeight = 9f;
}
};
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
ammoMultiplier = 5;
}};
dense = new BasicBulletType(3.5f, 18, "bullet"){
{
dense = new BasicBulletType(3.5f, 18, "bullet"){{
bulletWidth = 9f;
bulletHeight = 12f;
armorPierce = 0.2f;
}
};
reloadMultiplier = 0.6f;
ammoMultiplier = 2;
}};
thorium = new BasicBulletType(4f, 29, "bullet"){
{
thorium = new BasicBulletType(4f, 29, "bullet"){{
bulletWidth = 10f;
bulletHeight = 13f;
armorPierce = 0.5f;
}
};
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
ammoMultiplier = 2;
}};
homing = new BasicBulletType(3f, 9, "bullet"){
{
homing = new BasicBulletType(3f, 9, "bullet"){{
bulletWidth = 7f;
bulletHeight = 9f;
homingPower = 5f;
}
};
reloadMultiplier = 1.4f;
ammoMultiplier = 5;
}};
tracer = new BasicBulletType(3.2f, 11, "bullet"){
{
tracer = new BasicBulletType(3.2f, 11, "bullet"){{
bulletWidth = 10f;
bulletHeight = 12f;
frontColor = Palette.lightishOrange;
@ -53,11 +55,10 @@ public class StandardBullets extends BulletList implements ContentList{
incendSpread = 3f;
incendAmount = 1;
incendChance = 0.3f;
}
};
inaccuracy = 3f;
}};
glaive = new BasicBulletType(4f, 7.5f, "bullet"){
{
glaive = new BasicBulletType(4f, 7.5f, "bullet"){{
bulletWidth = 10f;
bulletHeight = 12f;
frontColor = Color.valueOf("feb380");
@ -65,36 +66,29 @@ public class StandardBullets extends BulletList implements ContentList{
incendSpread = 3f;
incendAmount = 1;
incendChance = 0.3f;
}
};
}};
mechSmall = new BasicBulletType(4f, 9, "bullet"){
{
mechSmall = new BasicBulletType(4f, 9, "bullet"){{
bulletWidth = 11f;
bulletHeight = 14f;
lifetime = 40f;
inaccuracy = 5f;
despawnEffect = BulletFx.hitBulletSmall;
}
};
}};
denseBig = new BasicBulletType(7f, 42, "bullet"){
{
denseBig = new BasicBulletType(7f, 42, "bullet"){{
bulletWidth = 15f;
bulletHeight = 21f;
armorPierce = 0.2f;
}
};
}};
thoriumBig = new BasicBulletType(8f, 65, "bullet"){
{
thoriumBig = new BasicBulletType(8f, 65, "bullet"){{
bulletWidth = 16f;
bulletHeight = 23f;
armorPierce = 0.5f;
}
};
}};
tracerBig = new BasicBulletType(7f, 38, "bullet"){
{
tracerBig = new BasicBulletType(7f, 38, "bullet"){{
bulletWidth = 16f;
bulletHeight = 21f;
frontColor = Palette.lightishOrange;
@ -102,7 +96,6 @@ public class StandardBullets extends BulletList implements ContentList{
incendSpread = 3f;
incendAmount = 2;
incendChance = 0.3f;
}
};
}};
}
}

View File

@ -67,10 +67,6 @@ public class ContentLoader{
new TurretBullets(),
new WeaponBullets(),
//ammotypes
new AmmoTypes(),
//weapons
new Weapons(),

View File

@ -629,7 +629,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
protected void updateFlying(){
if(Units.invalidateTarget(target, this) && !(target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team &&
mech.canHeal && dst(target) < getWeapon().getAmmo().getRange())){
mech.canHeal && dst(target) < getWeapon().getAmmo().range())){
target = null;
}
@ -709,11 +709,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(target == null){
isShooting = false;
if(Core.settings.getBool("autotarget")){
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().getRange());
target = Units.getClosestTarget(team, x, y, getWeapon().getAmmo().range());
if(mech.canHeal && target == null){
target = Geometry.findClosest(x, y, world.indexer.getDamaged(Team.blue));
if(target != null && dst(target) > getWeapon().getAmmo().getRange()){
if(target != null && dst(target) > getWeapon().getAmmo().range()){
target = null;
}else if(target != null){
target = ((Tile) target).entity;
@ -725,14 +725,14 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
}
}
}else if(target.isValid() || (target instanceof TileEntity && ((TileEntity) target).damaged() && target.getTeam() == team &&
mech.canHeal && dst(target) < getWeapon().getAmmo().getRange())){
mech.canHeal && dst(target) < getWeapon().getAmmo().range())){
//rotate toward and shoot the target
if(mech.turnCursor){
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
}
Vector2 intercept =
Predict.intercept(x, y, target.getX(), target.getY(), target.velocity().x - velocity.x, target.velocity().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().speed);
pointerX = intercept.x;
pointerY = intercept.y;

View File

@ -48,7 +48,7 @@ public class Units{
/**See {@link #invalidateTarget(TargetTrait, Team, float, float, float)}*/
public static boolean invalidateTarget(TargetTrait target, Unit targeter){
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.getWeapon().getAmmo().getRange());
return invalidateTarget(target, targeter.team, targeter.x, targeter.y, targeter.getWeapon().getAmmo().range());
}
/**Returns whether there are any entities on this tile.*/

View File

@ -13,9 +13,7 @@ import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.graphics.Palette;
/**
* A BulletType for most ammo-based bullets shot from turrets and units.
*/
/**An extended BulletType for most ammo-based bullets shot from turrets and units.*/
public class BasicBulletType extends BulletType{
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
public float bulletWidth = 5f, bulletHeight = 7f;

View File

@ -4,7 +4,7 @@ import io.anuke.arc.entities.Effects;
import io.anuke.arc.entities.Effects.Effect;
import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.StatusEffect;
@ -21,9 +21,17 @@ public abstract class BulletType extends Content{
public Effect hitEffect, despawnEffect;
/**Effect created when shooting.*/
public Effect shootEffect = Fx.none;
public Effect shootEffect = ShootFx.shootSmall;
/**Extra smoke effect created when shooting.*/
public Effect smokeEffect = Fx.none;
public Effect smokeEffect = ShootFx.shootSmallSmoke;
/**Extra inaccuracy when firing.*/
public float inaccuracy = 0f;
/**How many bullets get created per ammo item/liquid.*/
public float ammoMultiplier = 1f;
/**Multiplied by turret reload speed to get final shoot speed.*/
public float reloadMultiplier = 1f;
/**Recoil from shooter entities.*/
public float recoil;
public float splashDamage = 0f;
/**Knockback in velocity.*/
@ -57,6 +65,11 @@ public abstract class BulletType extends Content{
despawnEffect = BulletFx.hitBulletSmall;
}
/**Returns maximum distance the bullet this bullet type has can travel.*/
public float range(){
return speed * lifetime;
}
public boolean collides(Bullet bullet, Tile tile){
return true;
}

View File

@ -184,7 +184,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
public void targetClosest(){
target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().getAmmo().getRange(), type.range), u -> type.targetAir || !u.isFlying());
target = Units.getClosestTarget(team, x, y, Math.max(getWeapon().getAmmo().range(), type.range), u -> type.targetAir || !u.isFlying());
}
public TileEntity getClosestEnemyCore(){

View File

@ -8,10 +8,10 @@ import io.anuke.arc.math.geom.Vector2;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.entities.Predict;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.entities.traits.CarriableTrait;
import io.anuke.mindustry.entities.traits.CarryTrait;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
@ -74,11 +74,11 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
}else{
attack(150f);
if((Angles.near(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().bullet.keepVelocity) //bombers don't care about rotation
&& dst(target) < Math.max(getWeapon().getAmmo().getRange(), type.range)){
AmmoType ammo = getWeapon().getAmmo();
if((Angles.near(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().keepVelocity) //bombers don't care about rotation
&& dst(target) < Math.max(getWeapon().getAmmo().range(), type.range)){
BulletType ammo = getWeapon().getAmmo();
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.speed);
getWeapon().update(FlyingUnit.this, to.x, to.y);
}

View File

@ -10,8 +10,8 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Predict;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Tile;
@ -43,11 +43,11 @@ public abstract class GroundUnit extends BaseUnit{
TileEntity core = getClosestEnemyCore();
float dst = core == null ? 0 : dst(core);
if(core != null && dst < getWeapon().getAmmo().getRange() / 1.1f){
if(core != null && dst < getWeapon().getAmmo().range() / 1.1f){
target = core;
}
if(dst > getWeapon().getAmmo().getRange() * 0.5f){
if(dst > getWeapon().getAmmo().range() * 0.5f){
moveToCore();
}
}
@ -187,13 +187,13 @@ public abstract class GroundUnit extends BaseUnit{
}
if(!Units.invalidateTarget(target, this)){
if(dst(target) < getWeapon().getAmmo().getRange()){
if(dst(target) < getWeapon().getAmmo().range()){
rotate(angleTo(target));
if(Angles.near(angleTo(target), rotation, 13f)){
AmmoType ammo = getWeapon().getAmmo();
BulletType ammo = getWeapon().getAmmo();
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.bullet.speed);
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.speed);
getWeapon().update(GroundUnit.this, to.x, to.y);
}

View File

@ -292,16 +292,6 @@ public class TypeIO{
return content.liquid(buffer.get());
}
@WriteClass(AmmoType.class)
public static void writeAmmo(ByteBuffer buffer, AmmoType type){
buffer.put(type.id);
}
@ReadClass(AmmoType.class)
public static AmmoType readAmmo(ByteBuffer buffer){
return content.getByID(ContentType.weapon, buffer.get());
}
@WriteClass(BulletType.class)
public static void writeBulletType(ByteBuffer buffer, BulletType type){
buffer.put(type.id);

View File

@ -13,7 +13,6 @@ import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.content.blocks.*;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Edges;
@ -74,12 +73,14 @@ public class FortressGenerator{
float placeChance = difficultyScl*0.75f+0.25f;
IntIntMap ammoPerType = new IntIntMap();
//todo implement
/*
for(Block turret : turrets){
if(!(turret instanceof ItemTurret)) continue;
ItemTurret t = (ItemTurret)turret;
int size = t.getAmmoTypes().length;
ammoPerType.put(t.id, Mathf.clamp((int)(size* difficultyScl) + gen.random.range(1), 0, size - 1));
}
}*/
TriFunction<Tile, Block, Predicate<Tile>, Boolean> checker = (current, block, pred) -> {
for(Point2 point : Edges.getEdges(block.size)){
@ -181,11 +182,12 @@ public class FortressGenerator{
if(block instanceof PowerTurret){
tile.entity.power.satisfaction = 1.0f;
}else if(block instanceof ItemTurret){
//todo implement
/*}else if(block instanceof ItemTurret){
ItemTurret turret = (ItemTurret)block;
AmmoType[] type = turret.getAmmoTypes();
int index = ammoPerType.get(block.id, 0);
block.handleStack(type[index].item, block.acceptStack(type[index].item, 1000, tile, null), tile, null);
block.handleStack(type[index].item, block.acceptStack(type[index].item, 1000, tile, null), tile, null);*/
}else if(block instanceof NuclearReactor){
tile.entity.items.add(Items.thorium, 30);
}else if(block instanceof LiquidTurret){

View File

@ -1,13 +0,0 @@
package io.anuke.mindustry.type;
/**Used to store ammo amounts in turrets.
* TODO move inside turret class?*/
public class AmmoEntry{
public AmmoType type;
public int amount;
public AmmoEntry(AmmoType type, int amount){
this.type = type;
this.amount = amount;
}
}

View File

@ -1,75 +0,0 @@
package io.anuke.mindustry.type;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.game.Content;
import io.anuke.arc.entities.Effects.Effect;
public class AmmoType extends Content {
/**The item used. Always null if liquid isn't.*/
public final Item item;
/**The liquid used. Always null if item isn't.*/
public final Liquid liquid;
/**The resulting bullet. Never null.*/
public final BulletType bullet;
/**
* For item ammo, this is amount given per ammo item.
* For liquid ammo, this is amount used per shot.
*/
public final float quantityMultiplier;
/**Reload speed multiplier.*/
public float reloadMultiplier = 1f;
/**Bullet recoil strength.*/
public float recoil = 0f;
/**Additional inaccuracy in degrees.*/
public float inaccuracy;
/**Effect created when shooting.*/
public Effect shootEffect = Fx.none;
/**Extra smoke effect created when shooting.*/
public Effect smokeEffect = Fx.none;
/**Range. Use a value < 0 to calculate from bullet.*/
public float range = -1f;
/**
* Creates an AmmoType with no liquid or item. Used for power-based ammo.
*/
public AmmoType(BulletType result){
this.item = null;
this.liquid = null;
this.bullet = result;
this.quantityMultiplier = 1f;
this.reloadMultiplier = 1f;
}
/**
* Creates an AmmoType with an item.
*/
public AmmoType(Item item, BulletType result, float multiplier){
this.item = item;
this.liquid = null;
this.bullet = result;
this.quantityMultiplier = multiplier;
}
/**
* Creates an AmmoType with a liquid.
*/
public AmmoType(Liquid liquid, BulletType result, float multiplier){
this.item = null;
this.liquid = liquid;
this.bullet = result;
this.quantityMultiplier = multiplier;
}
/**
* Returns maximum distance the bullet this ammo type has can travel.
*/
public float getRange(){
return range < 0 ? bullet.speed * bullet.lifetime : range;
}
@Override
public ContentType getContentType(){
return ContentType.ammo;
}
}

View File

@ -11,7 +11,6 @@ public enum ContentType {
weapon,
status,
unit,
ammo,
weather,
effect
}

View File

@ -13,6 +13,7 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.entities.traits.ShooterTrait;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.gen.Call;
@ -24,7 +25,7 @@ public class Weapon extends Content{
/**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/
protected static float minPlayerDist = 20f;
/**ammo type map. set with setAmmo()*/
protected AmmoType ammo;
protected BulletType ammo;
/**shell ejection effect*/
protected Effect ejectEffect = Fx.none;
/**weapon reload in frames*/
@ -47,7 +48,7 @@ public class Weapon extends Content{
protected float velocityRnd = 0f;
/**whether to shoot the weapons in different arms one after another, rather than all at once*/
protected boolean roundrobin = false;
/**translator for vector calulations*/
/**vector for vector calulations*/
protected Vector2 tr = new Vector2();
public TextureRegion equipRegion, region;
@ -81,7 +82,7 @@ public class Weapon extends Content{
Weapon weapon = shooter.getWeapon();
Angles.shotgun(weapon.shots, weapon.spacing, rotation, f -> weapon.bullet(shooter, x, y, f + Mathf.range(weapon.inaccuracy)));
AmmoType ammo = weapon.ammo;
BulletType ammo = weapon.ammo;
weapon.tr.trns(rotation + 180f, ammo.recoil);
@ -109,7 +110,7 @@ public class Weapon extends Content{
return ContentType.weapon;
}
public AmmoType getAmmo(){
public BulletType getAmmo(){
return ammo;
}
@ -165,7 +166,7 @@ public class Weapon extends Content{
if(owner == null) return;
tr.trns(angle, 3f);
Bullet.create(ammo.bullet,
Bullet.create(ammo,
owner, owner.getTeam(), x + tr.x, y + tr.y, angle, (1f - velocityRnd) + Mathf.random(velocityRnd));
}
}

View File

@ -1,11 +1,11 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Vector2;
import io.anuke.mindustry.entities.Predict;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import io.anuke.arc.math.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
@ -21,23 +21,23 @@ public class ArtilleryTurret extends ItemTurret{
}
@Override
protected void shoot(Tile tile, AmmoType ammo){
protected void shoot(Tile tile, BulletType ammo){
TurretEntity entity = tile.entity();
entity.recoil = recoil;
entity.heat = 1f;
AmmoType type = peekAmmo(tile);
BulletType type = peekAmmo(tile);
tr.trns(entity.rotation, size * tilesize / 2);
Vector2 predict = Predict.intercept(tile, entity.target, type.bullet.speed);
Vector2 predict = Predict.intercept(tile, entity.target, type.speed);
float dst = entity.dst(predict.x, predict.y);
float maxTraveled = type.bullet.lifetime * type.bullet.speed;
float maxTraveled = type.lifetime * type.speed;
for(int i = 0; i < shots; i++){
Bullet.create(ammo.bullet, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y,
Bullet.create(ammo, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y,
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), 1f + Mathf.range(velocityInaccuracy), (dst / maxTraveled));
}

View File

@ -1,9 +1,9 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.world.Tile;
import io.anuke.arc.util.Time;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.tilesize;
@ -15,7 +15,7 @@ public class BurstTurret extends ItemTurret{
}
@Override
protected void shoot(Tile tile, AmmoType ammo){
protected void shoot(Tile tile, BulletType ammo){
TurretEntity entity = tile.entity();
entity.heat = 1f;
@ -28,7 +28,7 @@ public class BurstTurret extends ItemTurret{
entity.recoil = recoil;
tr.trns(entity.rotation, size * tilesize / 2, Mathf.range(xRand));
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
bullet(tile, ammo, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
useAmmo(tile);
});

View File

@ -1,13 +1,13 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.world.Tile;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.entities.Effects.Effect;
import io.anuke.arc.util.Time;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.tilesize;
@ -24,7 +24,7 @@ public class ChargeTurret extends PowerTurret{
}
@Override
public void shoot(Tile tile, AmmoType ammo){
public void shoot(Tile tile, BulletType ammo){
LaserTurretEntity entity = tile.entity();
useAmmo(tile);
@ -47,7 +47,7 @@ public class ChargeTurret extends PowerTurret{
tr.trns(entity.rotation, size * tilesize / 2);
entity.recoil = recoil;
entity.heat = 1f;
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
bullet(tile, ammo, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
entity.shooting = false;
});

View File

@ -1,8 +1,8 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.world.Tile;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.tilesize;
@ -15,14 +15,14 @@ public class DoubleTurret extends ItemTurret{
}
@Override
protected void shoot(Tile tile, AmmoType ammo){
protected void shoot(Tile tile, BulletType ammo){
TurretEntity entity = tile.entity();
entity.shots++;
int i = Mathf.signs[entity.shots % 2];
tr.trns(entity.rotation - 90, shotWidth * i, size * tilesize / 2);
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
bullet(tile, ammo, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
useAmmo(tile);

View File

@ -1,26 +1,30 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.arc.collection.ObjectMap;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.type.AmmoEntry;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.values.ItemFilterValue;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class ItemTurret extends CooledTurret{
protected int maxAmmo = 50;
protected AmmoType[] ammoTypes;
protected ObjectMap<Item, AmmoType> ammoMap = new ObjectMap<>();
protected ObjectMap<Item, BulletType> ammo = new ObjectMap<>();
public ItemTurret(String name){
super(name);
hasItems = true;
}
public AmmoType[] getAmmoTypes(){
return ammoTypes;
/**Initializes accepted ammo map. Format: [item1, bullet1, item2, bullet2...]*/
protected void ammo(Object... objects){
ammo = ObjectMap.of(objects);
}
@Override
@ -28,19 +32,18 @@ public class ItemTurret extends CooledTurret{
super.setStats();
stats.remove(BlockStat.itemCapacity);
stats.add(BlockStat.inputItems, new ItemFilterValue(item -> ammoMap.containsKey(item)));
stats.add(BlockStat.inputItems, new ItemFilterValue(item -> ammo.containsKey(item)));
}
@Override
public int acceptStack(Item item, int amount, Tile tile, Unit source){
TurretEntity entity = tile.entity();
AmmoType type = ammoMap.get(item);
BulletType type = ammo.get(item);
if(type == null) return 0;
return Math.min((int) ((maxAmmo - entity.totalAmmo) / ammoMap.get(item).quantityMultiplier), amount);
return Math.min((int) ((maxAmmo - entity.totalAmmo) / ammo.get(item).ammoMultiplier), amount);
}
@Override
@ -61,47 +64,67 @@ public class ItemTurret extends CooledTurret{
TurretEntity entity = tile.entity();
if(entity == null) return;
AmmoType type = ammoMap.get(item);
entity.totalAmmo += type.quantityMultiplier;
BulletType type = ammo.get(item);
entity.totalAmmo += type.ammoMultiplier;
entity.items.add(item, 1);
//find ammo entry by type
for(int i = 0; i < entity.ammo.size; i++){
AmmoEntry entry = entity.ammo.get(i);
ItemEntry entry = (ItemEntry)entity.ammo.get(i);
//if found, put it to the right
if(entry.type == type){
entry.amount += type.quantityMultiplier;
if(entry.item == item){
entry.amount += type.ammoMultiplier;
entity.ammo.swap(i, entity.ammo.size - 1);
return;
}
}
//must not be found
AmmoEntry entry = new AmmoEntry(type, (int) type.quantityMultiplier);
entity.ammo.add(entry);
entity.ammo.add(new ItemEntry(item, (int) type.ammoMultiplier));
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
TurretEntity entity = tile.entity();
return ammoMap != null && ammoMap.get(item) != null && entity.totalAmmo + ammoMap.get(item).quantityMultiplier <= maxAmmo;
return ammo != null && ammo.get(item) != null && entity.totalAmmo + ammo.get(item).ammoMultiplier <= maxAmmo;
}
public class ItemTurretEntity extends TurretEntity{
@Override
public void write(DataOutput stream) throws IOException{
stream.writeByte(ammo.size);
for(AmmoEntry entry : ammo){
ItemEntry i = (ItemEntry)entry;
stream.writeByte(i.item.id);
stream.writeShort(i.amount);
}
}
@Override
public void init(){
super.init();
public void read(DataInput stream) throws IOException{
byte amount = stream.readByte();
for(int i = 0; i < amount; i++){
Item item = Vars.content.item(stream.readByte());
short a = stream.readShort();
totalAmmo += a;
ammo.add(new ItemEntry(item, a));
}
}
}
if(ammoTypes != null){
for(AmmoType type : ammoTypes){
if(type.item == null) continue;
if(ammoMap.containsKey(type.item)){
throw new RuntimeException("Turret \"" + name + "\" has two conflicting ammo entries on item type " + type.item + "!");
}else{
ammoMap.put(type.item, type);
}
}
class ItemEntry extends AmmoEntry{
protected Item item;
ItemEntry(Item item, int amount){
this.item = item;
this.amount = amount;
}
@Override
public BulletType type(){
return ammo.get(item);
}
}
}

View File

@ -1,16 +1,15 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.math.Angles;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
import io.anuke.arc.entities.Effects;
import io.anuke.arc.util.Time;
import io.anuke.arc.math.Angles;
import io.anuke.arc.math.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
@ -55,7 +54,7 @@ public class LaserTurret extends PowerTurret{
}
if(entity.reload >= reload && entity.cons.valid()){
AmmoType type = peekAmmo(tile);
BulletType type = peekAmmo(tile);
shoot(tile, type);

View File

@ -1,32 +1,41 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.arc.collection.ObjectMap;
import io.anuke.arc.entities.Effects;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.entities.effect.Fire;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
import io.anuke.arc.entities.Effects;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public abstract class LiquidTurret extends Turret{
protected AmmoType[] ammoTypes;
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
protected ObjectMap<Liquid, BulletType> ammo = new ObjectMap<>();
public LiquidTurret(String name){
super(name);
hasLiquids = true;
}
/**Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...]*/
protected void ammo(Object... objects){
ammo = ObjectMap.of(objects);
}
@Override
public void setStats(){
super.setStats();
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(item -> liquidAmmoMap.containsKey(item)));
stats.add(BlockStat.inputLiquid, new LiquidFilterValue(item -> ammo.containsKey(item)));
}
@Override
@ -58,12 +67,12 @@ public abstract class LiquidTurret extends Turret{
@Override
protected void effects(Tile tile){
AmmoType type = peekAmmo(tile);
BulletType type = peekAmmo(tile);
TurretEntity entity = tile.entity();
Effects.effect(type.shootEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
Effects.effect(type.smokeEffect, type.liquid.color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
Effects.effect(type.shootEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
Effects.effect(type.smokeEffect, entity.liquids.current().color, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
if(shootShake > 0){
Effects.shake(shootShake, shootShake, tile.entity);
@ -73,36 +82,23 @@ public abstract class LiquidTurret extends Turret{
}
@Override
public AmmoType useAmmo(Tile tile){
public BulletType useAmmo(Tile tile){
TurretEntity entity = tile.entity();
if(tile.isEnemyCheat()) return liquidAmmoMap.get(entity.liquids.current());
AmmoType type = liquidAmmoMap.get(entity.liquids.current());
entity.liquids.remove(type.liquid, type.quantityMultiplier);
if(tile.isEnemyCheat()) return ammo.get(entity.liquids.current());
BulletType type = ammo.get(entity.liquids.current());
entity.liquids.remove(entity.liquids.current(), type.ammoMultiplier);
return type;
}
@Override
public AmmoType peekAmmo(Tile tile){
return liquidAmmoMap.get(tile.entity.liquids.current());
public BulletType peekAmmo(Tile tile){
return ammo.get(tile.entity.liquids.current());
}
@Override
public boolean hasAmmo(Tile tile){
TurretEntity entity = tile.entity();
return liquidAmmoMap.get(entity.liquids.current()) != null && entity.liquids.total() >= liquidAmmoMap.get(entity.liquids.current()).quantityMultiplier;
}
@Override
public void init(){
super.init();
for(AmmoType type : ammoTypes){
if(liquidAmmoMap.containsKey(type.liquid)){
throw new RuntimeException("Turret \"" + name + "\" has two conflicting ammo entries on liquid type " + type.liquid + "!");
}else{
liquidAmmoMap.put(type.liquid, type);
}
}
return ammo.get(entity.liquids.current()) != null && entity.liquids.total() >= ammo.get(entity.liquids.current()).ammoMultiplier;
}
@Override
@ -112,8 +108,45 @@ public abstract class LiquidTurret extends Turret{
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return super.acceptLiquid(tile, source, liquid, amount) && liquidAmmoMap.get(liquid) != null
&& (tile.entity.liquids.current() == liquid || (liquidAmmoMap.containsKey(tile.entity.liquids.current()) && tile.entity.liquids.get(tile.entity.liquids.current()) <= liquidAmmoMap.get(tile.entity.liquids.current()).quantityMultiplier + 0.001f));
return super.acceptLiquid(tile, source, liquid, amount) && ammo.get(liquid) != null
&& (tile.entity.liquids.current() == liquid || (ammo.containsKey(tile.entity.liquids.current()) && tile.entity.liquids.get(tile.entity.liquids.current()) <= ammo.get(tile.entity.liquids.current()).ammoMultiplier + 0.001f));
}
public class LiquidTurretEntity extends TurretEntity{
@Override
public void write(DataOutput stream) throws IOException{
stream.writeByte(ammo.size);
for(AmmoEntry entry : ammo){
LiquidEntry i = (LiquidEntry)entry;
stream.writeByte(i.liquid.id);
stream.writeShort(i.amount);
}
}
@Override
public void read(DataInput stream) throws IOException{
byte amount = stream.readByte();
for(int i = 0; i < amount; i++){
Liquid liquid = Vars.content.liquid(stream.readByte());
short a = stream.readShort();
totalAmmo += a;
ammo.add(new LiquidEntry(liquid, a));
}
}
}
class LiquidEntry extends AmmoEntry{
protected Liquid liquid;
LiquidEntry(Liquid liquid, int amount){
this.liquid = liquid;
this.amount = amount;
}
@Override
public BulletType type(){
return ammo.get(liquid);
}
}
}

View File

@ -1,6 +1,6 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
@ -8,7 +8,7 @@ import io.anuke.mindustry.world.meta.StatUnit;
public abstract class PowerTurret extends CooledTurret{
/** The percentage of power which will be used per shot. */
protected float powerUsed = 0.5f;
protected AmmoType shootType;
protected BulletType shootType;
public PowerTurret(String name){
super(name);
@ -29,7 +29,7 @@ public abstract class PowerTurret extends CooledTurret{
}
@Override
public AmmoType useAmmo(Tile tile){
public BulletType useAmmo(Tile tile){
if(tile.isEnemyCheat()) return shootType;
// Make sure that power can not go negative in case of threading issues or similar
tile.entity.power.satisfaction -= Math.min(powerUsed, tile.entity.power.satisfaction);
@ -37,7 +37,7 @@ public abstract class PowerTurret extends CooledTurret{
}
@Override
public AmmoType peekAmmo(Tile tile){
public BulletType peekAmmo(Tile tile){
return shootType;
}
}

View File

@ -24,9 +24,6 @@ import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.type.AmmoEntry;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
@ -34,11 +31,6 @@ import io.anuke.mindustry.world.meta.BlockGroup;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.meta.StatUnit;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.tilesize;
public abstract class Turret extends Block{
@ -197,8 +189,8 @@ public abstract class Turret extends Block{
if(validateTarget(tile)){
AmmoType type = peekAmmo(tile);
float speed = type.bullet.speed;
BulletType type = peekAmmo(tile);
float speed = type.speed;
if(speed < 0.1f) speed = 9999999f;
Vector2 result = Predict.intercept(entity, entity.target, speed);
@ -246,7 +238,7 @@ public abstract class Turret extends Block{
}
/**Consume ammo and return a type.*/
public AmmoType useAmmo(Tile tile){
public BulletType useAmmo(Tile tile){
if(tile.isEnemyCheat()) return peekAmmo(tile);
TurretEntity entity = tile.entity();
@ -255,15 +247,15 @@ public abstract class Turret extends Block{
if(entry.amount == 0) entity.ammo.pop();
entity.totalAmmo -= ammoPerShot;
Time.run(reload / 2f, () -> ejectEffects(tile));
return entry.type;
return entry.type();
}
/**
* Get the ammo type that will be returned if useAmmo is called.
*/
public AmmoType peekAmmo(Tile tile){
public BulletType peekAmmo(Tile tile){
TurretEntity entity = tile.entity();
return entity.ammo.peek().type;
return entity.ammo.peek().type();
}
/**
@ -278,7 +270,7 @@ public abstract class Turret extends Block{
TurretEntity entity = tile.entity();
if(entity.reload >= reload){
AmmoType type = peekAmmo(tile);
BulletType type = peekAmmo(tile);
shoot(tile, type);
@ -288,18 +280,16 @@ public abstract class Turret extends Block{
}
}
protected void shoot(Tile tile, AmmoType ammo){
protected void shoot(Tile tile, BulletType type){
TurretEntity entity = tile.entity();
entity.recoil = recoil;
entity.heat = 1f;
AmmoType type = peekAmmo(tile);
tr.trns(entity.rotation, size * tilesize / 2f, Mathf.range(xRand));
for(int i = 0; i < shots; i++){
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i-shots/2) * spread);
bullet(tile, type, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i-shots/2) * spread);
}
effects(tile);
@ -343,6 +333,12 @@ public abstract class Turret extends Block{
return new TurretEntity();
}
public static abstract class AmmoEntry{
public int amount;
public abstract BulletType type();
}
public static class TurretEntity extends TileEntity{
public Array<AmmoEntry> ammo = new Array<>();
public int totalAmmo;
@ -352,25 +348,5 @@ public abstract class Turret extends Block{
public float heat;
public int shots;
public TargetTrait target;
@Override
public void write(DataOutput stream) throws IOException{
stream.writeByte(ammo.size);
for(AmmoEntry entry : ammo){
stream.writeByte(entry.type.id);
stream.writeShort(entry.amount);
}
}
@Override
public void read(DataInput stream) throws IOException{
byte amount = stream.readByte();
for(int i = 0; i < amount; i++){
AmmoType type = content.getByID(ContentType.ammo, stream.readByte());
short ta = stream.readShort();
ammo.add(new AmmoEntry(type, ta));
totalAmmo += ta;
}
}
}
}