Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2018-09-14 10:53:27 -04:00
45 changed files with 1147 additions and 936 deletions

View File

@@ -217,7 +217,7 @@ public class AmmoTypes implements ContentList{
spectreLaser = new AmmoType(TurretBullets.lancerLaser);
meltdownLaser = new AmmoType(TurretBullets.lancerLaser);
meltdownLaser = new AmmoType(TurretBullets.meltdownLaser);
fuseShotgun = new AmmoType(Items.densealloy, TurretBullets.fuseShot, 1f){{
shootEffect = Fx.none;

View File

@@ -19,8 +19,8 @@ public class Recipes implements ContentList{
new Recipe(defense, DefenseBlocks.copperWall, new ItemStack(Items.copper, 12));
new Recipe(defense, DefenseBlocks.copperWallLarge, new ItemStack(Items.copper, 12 * 4));
new Recipe(defense, DefenseBlocks.compositeWall, new ItemStack(Items.densealloy, 12));
new Recipe(defense, DefenseBlocks.compositeWallLarge, new ItemStack(Items.densealloy, 12 * 4));
new Recipe(defense, DefenseBlocks.denseAlloyWall, new ItemStack(Items.densealloy, 12));
new Recipe(defense, DefenseBlocks.denseAlloyWallLarge, new ItemStack(Items.densealloy, 12 * 4));
new Recipe(defense, DefenseBlocks.door, new ItemStack(Items.densealloy, 12), new ItemStack(Items.silicon, 8));
new Recipe(defense, DefenseBlocks.doorLarge, new ItemStack(Items.densealloy, 12 * 4), new ItemStack(Items.silicon, 8 * 4));
@@ -35,7 +35,7 @@ public class Recipes implements ContentList{
new Recipe(defense, DefenseBlocks.surgeWallLarge, new ItemStack(Items.surgealloy, 12 * 4));
//projectors
new Recipe(defense, DefenseBlocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
new Recipe(defense, DefenseBlocks.mendProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 50), new ItemStack(Items.silicon, 250));
new Recipe(defense, DefenseBlocks.overdriveProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));
new Recipe(defense, DefenseBlocks.forceProjector, new ItemStack(Items.lead, 200), new ItemStack(Items.densealloy, 150), new ItemStack(Items.titanium, 150), new ItemStack(Items.silicon, 250));

View File

@@ -57,7 +57,7 @@ public class CraftingBlocks extends BlockList implements ContentList{
plastaniumCompressor = new PlastaniumCompressor("plastanium-compressor"){{
hasItems = true;
liquidCapacity = 60f;
craftTime = 80f;
craftTime = 60f;
output = Items.plastanium;
itemCapacity = 30;
size = 2;
@@ -67,7 +67,7 @@ public class CraftingBlocks extends BlockList implements ContentList{
updateEffect = BlockFx.plasticburn;
consumes.liquid(Liquids.oil, 0.25f);
consumes.power(0.25f);
consumes.power(0.3f);
consumes.item(Items.titanium, 2);
}};

View File

@@ -114,10 +114,9 @@ public class DebugBlocks extends BlockList implements ContentList{
for(int i = 0; i < items.size; i++){
if(i == 0) continue;
final int f = i;
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> {
ImageButton button = cont.addImageButton("liquid-icon-" + items.get(i).name, "toggle", 24, () -> {
Call.setLiquidSourceLiquid(null, tile, 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){

View File

@@ -7,7 +7,7 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.defense.*;
public class DefenseBlocks extends BlockList implements ContentList{
public static Block copperWall, copperWallLarge, compositeWall, compositeWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
public static Block copperWall, copperWallLarge, denseAlloyWall, denseAlloyWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, overdriveProjector, forceProjector, shockMine;
@Override
@@ -23,11 +23,11 @@ public class DefenseBlocks extends BlockList implements ContentList{
size = 2;
}};
compositeWall = new Wall("composite-wall"){{
denseAlloyWall = new Wall("dense-alloy-wall"){{
health = 110 * wallHealthMultiplier;
}};
compositeWallLarge = new Wall("composite-wall-large"){{
denseAlloyWallLarge = new Wall("dense-alloy-wall-large"){{
health = 110 * wallHealthMultiplier * 4;
size = 2;
}};

View File

@@ -19,7 +19,7 @@ public class LiquidBlocks extends BlockList implements ContentList{
rotaryPump = new Pump("rotary-pump"){{
shadow = "shadow-rounded-2";
pumpAmount = 0.25f;
pumpAmount = 0.2f;
consumes.power(0.015f);
liquidCapacity = 30f;
powerCapacity = 20f;
@@ -30,7 +30,7 @@ public class LiquidBlocks extends BlockList implements ContentList{
thermalPump = new Pump("thermal-pump"){{
shadow = "shadow-rounded-2";
pumpAmount = 0.55f;
pumpAmount = 0.3f;
consumes.power(0.03f);
liquidCapacity = 40f;
hasPower = true;

View File

@@ -22,7 +22,7 @@ public class PowerBlocks extends BlockList implements ContentList{
thermalGenerator = new LiquidHeatGenerator("thermal-generator"){{
maxLiquidGenerate = 0.5f;
powerCapacity = 40f;
powerPerLiquid = 1.5f;
powerPerLiquid = 1f;
generateEffect = BlockFx.redgeneratespark;
size = 2;
}};

View File

@@ -82,7 +82,7 @@ public class TurretBlocks extends BlockList implements ContentList{
};
}};
lancer = new LaserTurret("lancer"){{
lancer = new ChargeTurret("lancer"){{
range = 90f;
chargeTime = 60f;
chargeMaxDelay = 30f;
@@ -105,7 +105,7 @@ public class TurretBlocks extends BlockList implements ContentList{
arc = new PowerTurret("arc"){{
shootType = AmmoTypes.arc;
reload = 30f;
reload = 40f;
shootShake = 1f;
powerUsed = 5f;
powerCapacity = 30f;
@@ -216,10 +216,13 @@ public class TurretBlocks extends BlockList implements ContentList{
spectre = new DoubleTurret("spectre"){{
ammoTypes = new AmmoType[]{AmmoTypes.bulletDenseBig, AmmoTypes.bulletPyratiteBig, AmmoTypes.bulletThoriumBig};
reload = 4f;
restitution = 0.03f;
ammoUseEffect = ShootFx.shellEjectMedium;
reload = 6f;
coolantMultiplier = 0.5f;
maxCoolantUsed = 1.5f;
restitution = 0.1f;
ammoUseEffect = ShootFx.shellEjectBig;
range = 200f;
inaccuracy = 3f;
recoil = 3f;
xRand = 3f;
shotWidth = 4f;
@@ -231,9 +234,19 @@ public class TurretBlocks extends BlockList implements ContentList{
health = 155 * size * size;
}};
meltdown = new PowerTurret("meltdown"){{
meltdown = new LaserTurret("meltdown"){{
shootType = AmmoTypes.meltdownLaser;
shootEffect = ShootFx.shootBigSmoke2;
shootCone = 40f;
recoil = 4f;
size = 4;
shootShake = 2f;
powerUsed = 10f;
range = 160f;
reload = 130f;
firingMoveFract = 0.25f;
shootDuration = 180f;
powerCapacity = 50f;
}};
}
}

View File

@@ -20,10 +20,7 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.graphics.Shapes;
import io.anuke.ucore.graphics.*;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
@@ -31,7 +28,7 @@ import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.world;
public class TurretBullets extends BulletList implements ContentList{
public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet, arc;
public static BulletType fireball, basicFlame, lancerLaser, meltdownLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet, arc;
@Override
public void load(){
@@ -161,6 +158,55 @@ public class TurretBullets extends BulletList implements ContentList{
}
};
meltdownLaser = new BulletType(0.001f, 20){
Color tmpColor = new Color();
Color[] colors = {Color.valueOf("ec745855"), Color.valueOf("ec7458aa"), Color.valueOf("ff9c5a"), Color.WHITE};
float[] tscales = {1f, 0.7f, 0.5f, 0.2f};
float[] strokes = {2f, 1.5f, 1f, 0.3f};
float[] lenscales = {1f, 1.12f, 1.15f, 1.17f};
float length = 200f;
{
hiteffect = BulletFx.hitMeltdown;
despawneffect = Fx.none;
hitsize = 4;
lifetime = 16f;
pierce = true;
}
@Override
public void update(Bullet b){
if(b.timer.get(1, 5f)){
Damage.collideLine(b, b.getTeam(), hiteffect, b.x, b.y, b.angle(), length);
}
Effects.shake(1f, 1f, b.x, b.y);
}
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hiteffect, colors[2], hitx, hity);
if(Mathf.chance(0.4)){
Fire.create(world.tileWorld(hitx, hity));
}
}
@Override
public void draw(Bullet b){
float baseLen = (length) * b.fout();
Lines.lineAngle(b.x, b.y, b.angle(), baseLen);
for(int s = 0; s < colors.length; s++){
Draw.color(tmpColor.set(colors[s]).mul(1f + Mathf.absin(Timers.time(), 1f, 0.1f)));
for(int i = 0; i < tscales.length; i++){
vector.trns(b.angle() + 180f, (lenscales[i] - 1f) * 35f);
Lines.stroke((9f + Mathf.absin(Timers.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
Lines.lineAngle(b.x + vector.x, b.y + vector.y, b.angle(), baseLen * lenscales[i], CapStyle.none);
}
}
Draw.reset();
}
};
fuseShot = new BulletType(0.01f, 70){
int rays = 3;
float raySpace = 2f;

View File

@@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class BulletFx extends FxList implements ContentList{
public static Effect hitBulletSmall, hitFuse, hitBulletBig, hitFlameSmall, hitLiquid, hitLaser, hitLancer, despawn, flakExplosion, blastExplosion, plasticExplosion,
public static Effect hitBulletSmall, hitFuse, hitBulletBig, hitFlameSmall, hitLiquid, hitLaser, hitLancer, hitMeltdown, despawn, flakExplosion, blastExplosion, plasticExplosion,
artilleryTrail, incendTrail, missileTrail, absorb, flakExplosionBig, plasticExplosionFlak;
@Override
@@ -101,6 +101,18 @@ public class BulletFx extends FxList implements ContentList{
Draw.reset();
});
hitMeltdown = new Effect(12, e -> {
Draw.color(Palette.meltdownHit);
Lines.stroke(e.fout() * 2f);
Angles.randLenVectors(e.id, 6, e.finpow() * 18f, e.rotation, 360f, (x, y) -> {
float ang = Mathf.atan2(x, y);
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f);
});
Draw.reset();
});
hitLaser = new Effect(8, e -> {
Draw.color(Color.WHITE, Palette.heal, e.fin());
Lines.stroke(0.5f + e.fout());

View File

@@ -102,6 +102,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
player.onDeath();
}
@Override
public float getDrag(){
return mech.drag;
}
@Override
public Timer getTimer(){
return timer;
@@ -431,6 +436,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
//region update methods
float lastx, lasty;
@Override
public void update(){
hitTime -= Timers.delta();

View File

@@ -53,7 +53,9 @@ public class Predict{
* See {@link #intercept(float, float, float, float, float, float, float)}.
*/
public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.getVelocity().x - src.getVelocity().x, dst.getVelocity().x - src.getVelocity().y, v);
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(),
dst.getTargetVelocityX() - src.getTargetVelocityX(),
dst.getTargetVelocityY() - src.getTargetVelocityY(), v);
}
private static Vector2 quad(float a, float b, float c){

View File

@@ -207,13 +207,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
/**Updates velocity and status effects.*/
public void updateVelocityStatus(float drag, float maxVelocity){
Floor floor = getFloorOn();
if(isCarried()){ //carried units do not take into account velocity normally
set(carrier.getX(), carrier.getY());
velocity.set(carrier.getVelocity());
return;
}
Floor floor = getFloorOn();
Tile tile = world.tileWorld(x, y);
status.update(this);

View File

@@ -37,23 +37,23 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
public Bullet(){
}
public static void create(BulletType type, TeamTrait owner, float x, float y, float angle){
create(type, owner, owner.getTeam(), x, y, angle);
public static Bullet create(BulletType type, TeamTrait owner, float x, float y, float angle){
return create(type, owner, owner.getTeam(), x, y, angle);
}
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle){
create(type, owner, team, x, y, angle, 1f);
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle){
return create(type, owner, team, x, y, angle, 1f);
}
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl){
create(type, owner, team, x, y, angle, velocityScl, 1f, null);
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl){
return create(type, owner, team, x, y, angle, velocityScl, 1f, null);
}
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
create(type, owner, team, x, y, angle, velocityScl, lifetimeScl, null);
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl){
return create(type, owner, team, x, y, angle, velocityScl, lifetimeScl, null);
}
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
public static Bullet create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
Bullet bullet = Pooling.obtain(Bullet.class, Bullet::new);
bullet.type = type;
bullet.owner = owner;
@@ -78,14 +78,15 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
bullet.set(x, y);
bullet.add();
return bullet;
}
public static void create(BulletType type, Bullet parent, float x, float y, float angle){
create(type, parent.owner, parent.team, x, y, angle);
public static Bullet create(BulletType type, Bullet parent, float x, float y, float angle){
return create(type, parent.owner, parent.team, x, y, angle);
}
public static void create(BulletType type, Bullet parent, float x, float y, float angle, float velocityScl){
create(type, parent.owner, parent.team, x, y, angle, velocityScl);
public static Bullet create(BulletType type, Bullet parent, float x, float y, float angle, float velocityScl){
return create(type, parent.owner, parent.team, x, y, angle, velocityScl);
}
@Remote(called = Loc.server)

View File

@@ -238,19 +238,20 @@ public interface BuilderTrait extends Entity{
/**Do not call directly.*/
default void updateMining(Unit unit){
Tile tile = getMineTile();
TileEntity core = unit.getClosestCore();
if(tile.block() != Blocks.air || unit.distanceTo(tile.worldx(), tile.worldy()) > mineDistance || !unit.inventory.canAcceptItem(tile.floor().drops.item)){
if(core == null || tile.block() != Blocks.air || unit.distanceTo(tile.worldx(), tile.worldy()) > mineDistance || !unit.inventory.canAcceptItem(tile.floor().drops.item)){
setMineTile(null);
}else{
Item item = tile.floor().drops.item;
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(tile.worldx(), tile.worldy()), 0.4f);
if(unit.inventory.canAcceptItem(item) &&
if(core.items.get(item) < core.tile.block().getMaximumAccepted(core.tile, item) &&
Mathf.chance(Timers.delta() * (0.06 - item.hardness * 0.01) * getMinePower())){
Call.transferItemToUnit(item,
tile.worldx() + Mathf.range(tilesize / 2f),
tile.worldy() + Mathf.range(tilesize / 2f),
unit);
Call.transferItemTo(item, 1,
tile.worldx() + Mathf.range(tilesize / 2f),
tile.worldy() + Mathf.range(tilesize / 2f), core.tile);
}
if(Mathf.chance(0.06 * Timers.delta())){

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.traits;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.trait.PosTrait;
import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.entities.trait.VelocityTrait;
/**
@@ -13,6 +14,22 @@ public interface TargetTrait extends PosTrait, VelocityTrait{
Team getTeam();
default float getTargetVelocityX(){
if(this instanceof SolidTrait){
return getX() - ((SolidTrait) this).lastPosition().x;
}else{
return getVelocity().x;
}
}
default float getTargetVelocityY(){
if(this instanceof SolidTrait){
return getY() - ((SolidTrait) this).lastPosition().y;
}else{
return getVelocity().y;
}
}
/**
* Whether this entity is a valid target.
*/

View File

@@ -82,6 +82,11 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
threads.runDelay(unit::remove);
}
@Override
public float getDrag(){
return type.drag;
}
/**Called when a command is recieved from the command center.*/
public abstract void onCommand(UnitCommand command);

View File

@@ -1,17 +1,14 @@
package io.anuke.mindustry.entities.units;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.entities.effect.ItemDrop;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.Item;
import io.anuke.ucore.util.Mathf;
public class UnitDrops{
private static final int maxItems = 200;
private static Item[] dropTable;
public static void dropItems(BaseUnit unit){
//just don't drop anything for now
/*
if(Vars.itemGroup.size() > maxItems || unit.getTeam() != Team.red){
return;
}
@@ -28,6 +25,6 @@ public class UnitDrops{
unit.getVelocity().x + Mathf.range(3f), unit.getVelocity().y + Mathf.range(3f));
}
}
}
}*/
}
}

View File

@@ -13,6 +13,8 @@ public class Palette{
missileYellow = Color.valueOf("ffd2ae"),
missileYellowBack = Color.valueOf("e58956"),
meltdownHit = Color.valueOf("ffb98b"),
plastaniumBack = Color.valueOf("d8d97f"),
plastaniumFront = Color.valueOf("fffac6"),

View File

@@ -0,0 +1,70 @@
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.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
public class ChargeTurret extends PowerTurret{
protected float chargeTime = 30f;
protected int chargeEffects = 5;
protected float chargeMaxDelay = 10f;
protected Effect chargeEffect = Fx.none;
protected Effect chargeBeginEffect = Fx.none;
public ChargeTurret(String name){
super(name);
}
@Override
public void shoot(Tile tile, AmmoType ammo){
LaserTurretEntity entity = tile.entity();
useAmmo(tile);
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeBeginEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
for(int i = 0; i < chargeEffects; i++){
Timers.run(Mathf.random(chargeMaxDelay), () -> {
if(!isTurret(tile)) return;
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
});
}
entity.shooting = true;
Timers.run(chargeTime, () -> {
if(!isTurret(tile)) return;
tr.trns(entity.rotation, size * tilesize / 2);
entity.recoil = recoil;
entity.heat = 1f;
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
entity.shooting = false;
});
}
@Override
public boolean shouldTurn(Tile tile){
LaserTurretEntity entity = tile.entity();
return !entity.shooting;
}
@Override
public TileEntity getEntity(){
return new LaserTurretEntity();
}
public class LaserTurretEntity extends TurretEntity{
public boolean shooting;
}
}

View File

@@ -1,7 +1,6 @@
package io.anuke.mindustry.world.blocks.defense.turrets;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.entities.effect.Fire;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
@@ -13,14 +12,10 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
public class CooledTurret extends Turret{
/**
* How much reload is lowered by for each unit of liquid of heat capacity 1.
*/
/**How much reload is lowered by for each unit of liquid of heat capacity 1.*/
protected float coolantMultiplier = 1f;
/**
* Max coolant used per tick.
*/
protected float maxUsed = 1f;
/**Max coolant used per tick.*/
protected float maxCoolantUsed = 1f;
protected Effect coolEffect = BlockFx.fuelburn;
public CooledTurret(String name){
@@ -28,7 +23,7 @@ public class CooledTurret extends Turret{
hasLiquids = true;
liquidCapacity = 20f;
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f, 0.01f)).update(false).optional(true);
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.01f)).update(false).optional(true);
}
@Override
@@ -38,18 +33,13 @@ public class CooledTurret extends Turret{
TurretEntity entity = tile.entity();
Liquid liquid = entity.liquids.current();
float used = Math.min(Math.min(entity.liquids.get(liquid), maxUsed * Timers.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity));
float used = Math.min(Math.min(entity.liquids.get(liquid), maxCoolantUsed * Timers.delta()), Math.max(0, ((reload - entity.reload) / coolantMultiplier) / liquid.heatCapacity));
entity.reload += (used * liquid.heatCapacity) / liquid.heatCapacity;
entity.liquids.remove(liquid, used);
if(Mathf.chance(0.04 * used)){
Effects.effect(coolEffect, tile.drawx() + Mathf.range(size * tilesize / 2f), tile.drawy() + Mathf.range(size * tilesize / 2f));
}
//don't use oil as coolant, thanks
if(Mathf.chance(liquid.flammability / 10f * used)){
Fire.create(tile);
}
}
@Override

View File

@@ -1,62 +1,65 @@
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.entities.bullet.Bullet;
import io.anuke.mindustry.entities.bullet.BulletType;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Angles;
import static io.anuke.mindustry.Vars.tilesize;
public class LaserTurret extends PowerTurret{
protected float chargeTime = 30f;
protected int chargeEffects = 5;
protected float chargeMaxDelay = 10f;
protected Effect chargeEffect = Fx.none;
protected Effect chargeBeginEffect = Fx.none;
protected float firingMoveFract = 0.25f;
protected float shootDuration = 100f;
public LaserTurret(String name){
super(name);
}
@Override
public void shoot(Tile tile, AmmoType ammo){
protected void updateShooting(Tile tile){
LaserTurretEntity entity = tile.entity();
useAmmo(tile);
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeBeginEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
for(int i = 0; i < chargeEffects; i++){
Timers.run(Mathf.random(chargeMaxDelay), () -> {
if(!isTurret(tile)) return;
tr.trns(entity.rotation, size * tilesize / 2);
Effects.effect(chargeEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);
});
if(entity.bulletLife > 0 && entity.bullet != null){
tr.trns(entity.rotation, size * tilesize / 2, 0f);
entity.bullet.setRotation(entity.rotation);
entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y);
entity.bullet.time(0f);
entity.heat = 1f;
entity.recoil = recoil;
entity.bulletLife -= Timers.delta();
if(entity.bulletLife <= 0f){
entity.bullet = null;
}
return;
}
entity.shooting = true;
if(entity.reload >= reload){
AmmoType type = peekAmmo(tile);
Timers.run(chargeTime, () -> {
if(!isTurret(tile)) return;
tr.trns(entity.rotation, size * tilesize / 2);
entity.recoil = recoil;
entity.heat = 1f;
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy));
effects(tile);
entity.shooting = false;
});
shoot(tile, type);
entity.reload = 0f;
}else{
entity.reload += tile.entity.delta() * peekAmmo(tile).reloadMultiplier;
}
}
@Override
public boolean shouldTurn(Tile tile){
protected void turnToTarget(Tile tile, float targetRot){
LaserTurretEntity entity = tile.entity();
return !entity.shooting;
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta() * (entity.bulletLife > 0f ? firingMoveFract : 1f));
}
@Override
protected void bullet(Tile tile, BulletType type, float angle){
LaserTurretEntity entity = tile.entity();
entity.bullet = Bullet.create(type, tile.entity, tile.getTeam(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
entity.bulletLife = shootDuration;
}
@Override
@@ -64,7 +67,8 @@ public class LaserTurret extends PowerTurret{
return new LaserTurretEntity();
}
public class LaserTurretEntity extends TurretEntity{
public boolean shooting;
class LaserTurretEntity extends TurretEntity{
Bullet bullet;
float bulletLife;
}
}

View File

@@ -213,7 +213,7 @@ public abstract class Turret extends Block{
}
if(shouldTurn(tile)){
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta());
turnToTarget(tile, targetRot);
}
if(Angles.angleDist(entity.rotation, targetRot) < shootCone){
@@ -235,6 +235,12 @@ public abstract class Turret extends Block{
tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir));
}
protected void turnToTarget(Tile tile, float targetRot){
TurretEntity entity = tile.entity();
entity.rotation = Angles.moveToward(entity.rotation, targetRot, rotatespeed * entity.delta());
}
public boolean shouldTurn(Tile tile){
return true;
}