Implemented liquid turrets with ammo / Implemented flamer turret

This commit is contained in:
Anuken 2018-04-03 23:06:39 -04:00
parent 636da8f95f
commit 397220e682
18 changed files with 355 additions and 130 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

View File

@ -132,70 +132,70 @@ multiplexer
index: -1
poweredconveyor
rotate: false
xy: 413, 103
xy: 572, 161
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
poweredconveyormove
rotate: false
xy: 572, 161
xy: 582, 165
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
pulseconduit-bottom
rotate: false
xy: 592, 160
xy: 592, 150
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
pulseconduit-top
rotate: false
xy: 592, 150
xy: 582, 145
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
router
rotate: false
xy: 756, 384
xy: 766, 384
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sortedunloader
rotate: false
xy: 423, 103
xy: 433, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sorter
rotate: false
xy: 433, 144
xy: 443, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
splitter
rotate: false
xy: 443, 144
xy: 433, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
steelconveyor
rotate: false
xy: 433, 134
xy: 453, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
steelconveyormove
rotate: false
xy: 453, 144
xy: 433, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -209,7 +209,7 @@ teleporter-top
index: -1
unloader
rotate: false
xy: 493, 124
xy: 483, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -223,7 +223,7 @@ vault
index: -1
vault-icon
rotate: false
xy: 483, 104
xy: 493, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -524,14 +524,14 @@ lead3
index: -1
mossblock
rotate: false
xy: 373, 104
xy: 383, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
oil
rotate: false
xy: 383, 104
xy: 393, 103
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -545,56 +545,56 @@ oiledge
index: -1
rock1
rotate: false
xy: 717, 281
xy: 678, 207
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
rock2
rotate: false
xy: 678, 207
xy: 756, 384
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sand1
rotate: false
xy: 786, 387
xy: 796, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sand2
rotate: false
xy: 796, 387
xy: 806, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sand3
rotate: false
xy: 806, 387
xy: 816, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sandblock1
rotate: false
xy: 816, 387
xy: 826, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sandblock2
rotate: false
xy: 826, 387
xy: 836, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
sandblock3
rotate: false
xy: 836, 387
xy: 846, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -608,56 +608,56 @@ sandedge
index: -1
shrub
rotate: false
xy: 926, 387
xy: 936, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
shrubshadow
rotate: false
xy: 936, 387
xy: 946, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snow1
rotate: false
xy: 966, 387
xy: 681, 231
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snow2
rotate: false
xy: 681, 231
xy: 682, 221
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snow3
rotate: false
xy: 682, 221
xy: 423, 143
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snowblock1
rotate: false
xy: 423, 143
xy: 423, 133
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snowblock2
rotate: false
xy: 423, 133
xy: 423, 123
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
snowblock3
rotate: false
xy: 423, 123
xy: 423, 113
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -671,42 +671,42 @@ snowedge
index: -1
stone1
rotate: false
xy: 443, 124
xy: 453, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stone2
rotate: false
xy: 453, 134
xy: 473, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stone3
rotate: false
xy: 473, 144
xy: 433, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stoneblock1
rotate: false
xy: 433, 104
xy: 443, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stoneblock2
rotate: false
xy: 443, 114
xy: 453, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stoneblock3
rotate: false
xy: 453, 124
xy: 463, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -720,49 +720,49 @@ stoneedge
index: -1
thorium1
rotate: false
xy: 463, 124
xy: 473, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
thorium2
rotate: false
xy: 473, 134
xy: 493, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
thorium3
rotate: false
xy: 493, 144
xy: 453, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titanium1
rotate: false
xy: 453, 104
xy: 463, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titanium2
rotate: false
xy: 463, 114
xy: 473, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titanium3
rotate: false
xy: 473, 124
xy: 483, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
water
rotate: false
xy: 503, 143
xy: 513, 143
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -832,7 +832,7 @@ enemyspawn
index: -1
playerspawn
rotate: false
xy: 403, 103
xy: 413, 103
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -972,14 +972,14 @@ nuclearreactor-lights
index: -1
powerinfinite
rotate: false
xy: 582, 165
xy: 572, 151
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
powernode
rotate: false
xy: 572, 151
xy: 582, 155
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -993,28 +993,28 @@ powernodelarge
index: -1
powervoid
rotate: false
xy: 582, 155
xy: 592, 160
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
rtgenerator
rotate: false
xy: 766, 384
xy: 776, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
rtgenerator-top
rotate: false
xy: 776, 387
xy: 786, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
shieldgenerator
rotate: false
xy: 876, 387
xy: 886, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1028,7 +1028,7 @@ shieldprojector
index: -1
solarpanel
rotate: false
xy: 423, 113
xy: 423, 103
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1042,7 +1042,7 @@ teleporter
index: -1
thermalgenerator
rotate: false
xy: 453, 114
xy: 463, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1236,13 +1236,20 @@ lavasmelter
orig: 8, 8
offset: 0, 0
index: -1
melter
liquidsource
rotate: false
xy: 363, 103
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
melter
rotate: false
xy: 373, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
nucleardrill
rotate: false
xy: 751, 422
@ -1301,7 +1308,7 @@ oilextractor-top
index: -1
oilrefinery
rotate: false
xy: 393, 103
xy: 403, 103
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1385,63 +1392,63 @@ siliconsmelter-top
index: -1
pulverizer
rotate: false
xy: 582, 145
xy: 592, 140
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
pulverizer-rotator
rotate: false
xy: 592, 140
xy: 677, 281
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
pump
rotate: false
xy: 677, 281
xy: 687, 281
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
reinforceddrill
rotate: false
xy: 687, 281
xy: 697, 281
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
reinforceddrill-rotator
rotate: false
xy: 697, 281
xy: 707, 281
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
reinforceddrill-top
rotate: false
xy: 707, 281
xy: 717, 281
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
separator
rotate: false
xy: 846, 387
xy: 856, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
separator-liquid
rotate: false
xy: 856, 387
xy: 866, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
siliconextractor
rotate: false
xy: 946, 387
xy: 956, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1455,56 +1462,56 @@ siliconsmelter
index: -1
smelter
rotate: false
xy: 956, 387
xy: 966, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
steeldrill
rotate: false
xy: 433, 124
xy: 443, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
steeldrill-rotator
rotate: false
xy: 443, 134
xy: 463, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
steeldrill-top
rotate: false
xy: 463, 144
xy: 433, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stonedrill
rotate: false
xy: 463, 134
xy: 483, 144
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
stoneformer
rotate: false
xy: 483, 144
xy: 443, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titaniumdrill
rotate: false
xy: 483, 134
xy: 463, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titaniumdrill-top
rotate: false
xy: 463, 104
xy: 473, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1777,7 +1784,7 @@ ironwall
index: -1
steelwall
rotate: false
xy: 433, 114
xy: 443, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1791,21 +1798,21 @@ steelwall-large
index: -1
stonewall
rotate: false
xy: 443, 104
xy: 453, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titaniumshieldwall
rotate: false
xy: 473, 114
xy: 483, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titaniumwall
rotate: false
xy: 483, 124
xy: 493, 134
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -1868,28 +1875,28 @@ laserfull
index: -1
shell
rotate: false
xy: 866, 387
xy: 876, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
shot
rotate: false
xy: 906, 387
xy: 916, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
shot-long
rotate: false
xy: 916, 387
xy: 926, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
titanshell
rotate: false
xy: 493, 134
xy: 473, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
@ -3043,42 +3050,42 @@ clustergun-equip
index: -1
shockgun
rotate: false
xy: 886, 387
xy: 896, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
shockgun-equip
rotate: false
xy: 896, 387
xy: 906, 387
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
triblaster
rotate: false
xy: 473, 104
xy: 483, 114
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
triblaster-equip
rotate: false
xy: 483, 114
xy: 493, 124
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
vulcan
rotate: false
xy: 493, 114
xy: 493, 104
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
vulcan-equip
rotate: false
xy: 493, 104
xy: 503, 143
size: 8, 8
orig: 8, 8
offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Tue Apr 03 18:35:41 EDT 2018
#Tue Apr 03 22:20:20 EDT 2018
version=release
androidBuildCode=815
androidBuildCode=816
name=Mindustry
code=3.4
build=custom build

View File

@ -6,5 +6,7 @@ import io.anuke.mindustry.resource.AmmoType;
public class AmmoTypes {
public static final AmmoType
basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5, 0.9f);
basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5, 0.9f),
basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f, 0.9f);
}

View File

@ -121,6 +121,7 @@ public class Recipes {
new Recipe(units, DebugBlocks.itemSource, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.itemVoid, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.liquidSource, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.powerVoid, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.powerInfinite, stack(Items.steel, 10), stack(Items.densealloy, 5)).setDebug()
);

View File

@ -1,11 +1,23 @@
package io.anuke.mindustry.content.blocks;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerBlock;
import io.anuke.mindustry.world.blocks.types.distribution.Sorter;
import io.anuke.mindustry.world.blocks.types.power.PowerDistributor;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Table;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class DebugBlocks {
public static final Block
@ -43,6 +55,90 @@ public class DebugBlocks {
}
},
liquidSource = new Block("liquidsource"){
{
update = true;
solid = true;
hasLiquids = true;
liquidCapacity = 100f;
}
@Override
public boolean isConfigurable(Tile tile) {
return true;
}
@Override
public void update(Tile tile) {
LiquidSourceEntity entity = tile.entity();
tile.entity.liquid.amount = liquidCapacity;
tile.entity.liquid.liquid = entity.source;
tryDumpLiquid(tile);
}
@Override
public void draw(Tile tile){
super.draw(tile);
LiquidSourceEntity entity = tile.entity();
Draw.color(entity.source.color);
Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f);
Draw.color();
}
@Override
public void buildTable(Tile tile, Table table){
LiquidSourceEntity entity = tile.entity();
Array<Liquid> items = Liquid.getAllLiquids();
ButtonGroup<ImageButton> group = new ButtonGroup<>();
Table cont = new Table();
cont.margin(4);
cont.marginBottom(5);
cont.add().colspan(4).height(50f * (int)(items.size/4f + 1f));
cont.row();
for(int i = 0; i < items.size; i ++){
if(i == 0) continue;
final int f = i;
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
entity.source = items.get(f);
}).size(38, 42).padBottom(-5.1f).group(group).get();
button.getStyle().imageUpColor = items.get(i).color;
button.setChecked(entity.source.id == f);
if(i%4 == 3){
cont.row();
}
}
table.add(cont);
}
@Override
public TileEntity getEntity(){
return new LiquidSourceEntity();
}
class LiquidSourceEntity extends TileEntity{
public Liquid source = Liquids.water;
@Override
public void write(DataOutputStream stream) throws IOException {
stream.writeByte(source.id);
}
@Override
public void read(DataInputStream stream) throws IOException {
source = Liquid.getByID(stream.readByte());
}
}
},
itemVoid = new Block("itemvoid"){
{
update = solid = true;

View File

@ -35,9 +35,14 @@ public class WeaponBlocks{
ammoUseEffect = BulletFx.shellEjectSmall;
}},
flameturret = new Turret("flameturret"){
},
flameturret = new LiquidTurret("flameturret"){{
ammoTypes = new AmmoType[]{AmmoTypes.basicFlame};
recoil = 0f;
reload = 5f;
shootCone = 50f;
shootEffect = BulletFx.shootSmallFlame;
ammoUseEffect = BulletFx.shellEjectSmall;
}},
railgunturret = new Turret("railgunturret"){
@ -55,9 +60,9 @@ public class WeaponBlocks{
},
magmaturret = new LiquidTurret("magmaturret") {
},
magmaturret = new LiquidTurret("magmaturret") {{
ammoTypes = new AmmoType[]{AmmoTypes.basicFlame};
}},
plasmaturret = new Turret("plasmaturret"){

View File

@ -3,6 +3,8 @@ package io.anuke.mindustry.content.bullets;
import com.badlogic.gdx.graphics.Color;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.graphics.fx.BulletFx;
import io.anuke.mindustry.graphics.fx.Fx;
import io.anuke.ucore.graphics.Draw;
public class TurretBullets {
@ -15,5 +17,19 @@ public class TurretBullets {
Draw.rect("bullet", b.x, b.y, 9f, 5f + b.fract()*7f, b.angle() - 90);
Draw.color();
}
},
basicFlame = new BulletType(2f, 4) {
{
hitsize = 7f;
lifetime = 30f;
pierce = true;
drag = 0.07f;
hiteffect = BulletFx.hitFlameSmall;
despawneffect = Fx.none;
}
@Override
public void draw(Bullet b) {}
};
}

View File

@ -43,6 +43,9 @@ public class ContentLoader {
//units
new UnitTypes(),
//ammotypes
new AmmoTypes(),
};
for(Block block : Block.getAllBlocks()){

View File

@ -1,22 +1,22 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.entities.BulletEntity;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.util.Timer;
import static io.anuke.mindustry.Vars.*;
public class Bullet extends BulletEntity{
public IntSet collided;
public Timer timer = new Timer(3);
public Team team;
public Bullet(BulletType type, Unit owner, float x, float y, float angle){
super(type, owner, angle);
this.type = type;
this.team = owner.team;
set(x, y);
this(type, owner, owner.team, x, y, angle);
}
public Bullet(BulletType type, Entity owner, Team team, float x, float y, float angle){
@ -24,6 +24,10 @@ public class Bullet extends BulletEntity{
this.team = team;
this.type = type;
set(x, y);
if(type.pierce){
collided = new IntSet();
}
}
public Bullet(BulletType type, Bullet parent, float x, float y, float angle){
@ -44,7 +48,8 @@ public class Bullet extends BulletEntity{
type.draw(this);
}
}
@Override
public float drawSize(){
return 8;
}
@ -53,6 +58,18 @@ public class Bullet extends BulletEntity{
return true;
}
@Override
public boolean collides(SolidEntity other){
return super.collides(other) && (!type.pierce || !collided.contains(other.id));
}
@Override
public void collision(SolidEntity other, float x, float y){
super.collision(other, x, y);
if(type.pierce)
collided.add(other.id);
}
@Override
public void update(){
super.update();

View File

@ -2,26 +2,25 @@ package io.anuke.mindustry.entities;
import io.anuke.mindustry.graphics.fx.BulletFx;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.entities.BaseBulletType;
public abstract class BulletType extends BaseBulletType<Bullet>{
public Effect hitEffect = BulletFx.hit;
public Effect despawnEffect = BulletFx.despawn;
public BulletType(float speed, int damage){
this.speed = speed;
this.damage = damage;
lifetime = 40f;
hiteffect = BulletFx.hitBulletSmall;
despawneffect = BulletFx.despawn;
}
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hitEffect, hitx, hity, b.angle());
Effects.effect(hiteffect, hitx, hity, b.angle());
}
@Override
public void despawned(Bullet b){
Effects.effect(despawnEffect, b.x, b.y, b.angle());
Effects.effect(despawneffect, b.x, b.y, b.angle());
}
}

View File

@ -10,6 +10,8 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class BulletFx {
public static Color lightFlame = Color.valueOf("ffdd55");
public static Color darkFlame = Color.valueOf("db401c");
public static Color lightOrange = Color.valueOf("f68021");
public static Color lighterOrange = Color.valueOf("f6e096");
@ -33,6 +35,16 @@ public class BulletFx {
Draw.reset();
}),
shootSmallFlame = new Effect(30f, e -> {
Draw.color(lightFlame, darkFlame, Color.GRAY, e.ifract());
Angles.randLenVectors(e.id, 8, e.powfract()*26f, e.rotation, 10f, (x, y) -> {
Fill.circle(e.x + x, e.y + y, 0.65f + e.fract()*1.5f);
});
Draw.reset();
}),
shellEjectSmall = new Effect(30f, e -> {
Draw.color(lightOrange, Color.LIGHT_GRAY, Color.GRAY, e.ifract());
Draw.alpha(e.fract());
@ -45,7 +57,7 @@ public class BulletFx {
Draw.color();
}),
hit = new Effect(14, e -> {
hitBulletSmall = new Effect(14, e -> {
Draw.color(Color.WHITE, lightOrange, e.ifract());
Lines.stroke(0.5f + e.fract());
@ -57,6 +69,18 @@ public class BulletFx {
Draw.reset();
}),
hitFlameSmall = new Effect(14, e -> {
Draw.color(lightFlame, darkFlame, e.ifract());
Lines.stroke(0.5f + e.fract());
Angles.randLenVectors(e.id, 5, e.ifract()*15f, e.rotation, 50f, (x, y) -> {
float ang = Mathf.atan2(x, y);
Lines.lineAngle(e.x + x, e.y + y, ang, e.fract()*3 + 1f);
});
Draw.reset();
}),
despawn = new Effect(12, e -> {
Draw.color(lighterOrange, Color.GRAY, e.ifract());
Lines.stroke(e.fract());

View File

@ -8,18 +8,37 @@ public class AmmoType {
private static Array<AmmoType> allTypes = new Array<>();
public final byte id;
/**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.*/
public final BulletType bullet;
public final int quantityMultiplier;
/**For item ammo, this is amount given per ammo item.
* For liquid ammo, this is amount used per shot.*/
public final float quantityMultiplier;
/**Turret shoot speed multiplier.*/
public final float speedMultiplier;
public AmmoType(Item item, BulletType result, int multiplier, float speedMultiplier){
{
this.id = (byte)(lastID++);
allTypes.add(this);
}
public AmmoType(Item item, BulletType result, float multiplier, float speedMultiplier){
this.item = item;
this.liquid = null;
this.bullet = result;
this.quantityMultiplier = multiplier;
this.speedMultiplier = speedMultiplier;
}
public AmmoType(Liquid liquid, BulletType result, float multiplier, float speedMultiplier){
this.item = null;
this.liquid = liquid;
this.bullet = result;
this.quantityMultiplier = multiplier;
this.speedMultiplier = speedMultiplier;
this.id = (byte)(lastID++);
allTypes.add(this);
}
public static Array<AmmoType> getAllTypes() {

View File

@ -68,6 +68,7 @@ public class Turret extends Block{
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 {
@ -153,9 +154,8 @@ public class Turret extends Block{
}
//must not be found
AmmoEntry entry = new AmmoEntry(type, type.quantityMultiplier);
AmmoEntry entry = new AmmoEntry(type, (int)type.quantityMultiplier);
entity.ammo.add(entry);
}
@Override

View File

@ -0,0 +1,9 @@
package io.anuke.mindustry.world.blocks.types.defense.turrets;
import io.anuke.mindustry.world.blocks.types.defense.Turret;
public class ItemTurret extends Turret {
public ItemTurret(String name) {
super(name);
}
}

View File

@ -1,43 +1,69 @@
package io.anuke.mindustry.world.blocks.types.defense.turrets;
import io.anuke.mindustry.content.Liquids;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.resource.AmmoType;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.BlockBar;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.defense.Turret;
//TODO
public abstract class LiquidTurret extends Turret {
public Liquid ammoLiquid = Liquids.water;
public float liquidCapacity = 60f;
public float liquidPerShot = 1f;
protected ObjectMap<Liquid, AmmoType> liquidAmmoMap = new ObjectMap<>();
public LiquidTurret(String name) {
super(name);
hasLiquids = true;
}
@Override
public void setBars() {
super.setBars();
bars.remove(BarType.inventory);
bars.add(new BlockBar(BarType.liquid, true, tile -> tile.entity.liquid.amount / liquidCapacity));
}
@Override
public AmmoType useAmmo(Tile tile){
TurretEntity entity = tile.entity();
AmmoType type = liquidAmmoMap.get(entity.liquid.liquid);
entity.liquid.amount -= type.quantityMultiplier;
return type;
}
@Override
public AmmoType peekAmmo(Tile tile){
return liquidAmmoMap.get(tile.entity.liquid.liquid);
}
@Override
public boolean hasAmmo(Tile tile){
TurretEntity entity = tile.entity();
return liquidAmmoMap.get(entity.liquid.liquid) != null && entity.liquid.amount >= liquidAmmoMap.get(entity.liquid.liquid).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);
}
}
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source) {
return false;
}
@Override
public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
//TODO
}
/*
@Override
public void consumeAmmo(Tile tile){
TurretEntity entity = tile.entity();
entity.liquid.amount -= liquidPerShot;
}*/
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return ammoLiquid == liquid && super.acceptLiquid(tile, source, liquid, amount);
return super.acceptLiquid(tile, source, liquid, amount) && liquidAmmoMap.get(liquid) != null;
}
}

View File

@ -10,6 +10,7 @@ import java.io.IOException;
public class LiquidModule extends BlockModule {
public float amount;
/**Should never be null.*/
public Liquid liquid = Liquids.none;
@Override