Added metal floor / Implemented teleporter activation
BIN
core/assets-raw/sprites/blocks/environment/metalfloor1.png
Normal file
|
After Width: | Height: | Size: 189 B |
BIN
core/assets-raw/sprites/blocks/environment/metalfloor2.png
Normal file
|
After Width: | Height: | Size: 189 B |
BIN
core/assets-raw/sprites/blocks/environment/metalfloor3.png
Normal file
|
After Width: | Height: | Size: 175 B |
BIN
core/assets-raw/sprites/blocks/environment/metalfloor4.png
Normal file
|
After Width: | Height: | Size: 188 B |
BIN
core/assets-raw/sprites/blocks/environment/metalfloor5.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
core/assets-raw/sprites/blocks/environment/metalfloor6.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
core/assets-raw/sprites/blocks/environment/metalflooredge.png
Normal file
|
After Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 346 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 492 B |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Apr 07 19:29:57 EDT 2018
|
#Sat Apr 07 20:46:33 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=864
|
androidBuildCode=870
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ public class Blocks {
|
|||||||
solid = true;
|
solid = true;
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
metalfloor = new Floor("metalfloor"){{
|
||||||
|
variants = 6;
|
||||||
|
}},
|
||||||
|
|
||||||
deepwater = new Floor("deepwater") {{
|
deepwater = new Floor("deepwater") {{
|
||||||
variants = 0;
|
variants = 0;
|
||||||
solid = true;
|
solid = true;
|
||||||
|
|||||||
@@ -215,6 +215,22 @@ public class BlockFx {
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
teleportActivate = new Effect(50, e -> {
|
||||||
|
Draw.color(e.color);
|
||||||
|
|
||||||
|
e.scaled(8f, e2 -> {
|
||||||
|
Lines.stroke(e2.fout()*4f);
|
||||||
|
Lines.circle(e2.x, e2.y, 4f + e2.fin()*27f);
|
||||||
|
});
|
||||||
|
|
||||||
|
Lines.stroke(e.fout()*2f);
|
||||||
|
|
||||||
|
Angles.randLenVectors(e.id, 30, 4f + 40f * e.fin(), (x, y) -> {
|
||||||
|
Lines.lineAngle(e.x + x, e.y + y, Mathf.atan2(x, y), e.fin()*4f + 1f);
|
||||||
|
});
|
||||||
|
|
||||||
|
Draw.reset();
|
||||||
|
}),
|
||||||
teleport = new Effect(60, e -> {
|
teleport = new Effect(60, e -> {
|
||||||
Draw.color(e.color);
|
Draw.color(e.color);
|
||||||
Lines.stroke(e.fin()*2f);
|
Lines.stroke(e.fin()*2f);
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package io.anuke.mindustry.world.blocks.types.distribution;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.ObjectSet;
|
import com.badlogic.gdx.utils.ObjectSet;
|
||||||
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.content.fx.BlockFx;
|
import io.anuke.mindustry.content.fx.BlockFx;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
import io.anuke.mindustry.world.blocks.types.PowerBlock;
|
||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
@@ -40,6 +42,10 @@ public class Teleporter extends PowerBlock{
|
|||||||
|
|
||||||
protected float warmupTime = 60f;
|
protected float warmupTime = 60f;
|
||||||
protected float teleportMax = 400f;
|
protected float teleportMax = 400f;
|
||||||
|
protected float liquidUse = 0.3f;
|
||||||
|
protected float powerUse = 0.3f;
|
||||||
|
protected Liquid inputLiquid = Liquids.cryofluid;
|
||||||
|
protected Effect activateEffect = BlockFx.teleportActivate;
|
||||||
protected Effect teleportEffect = BlockFx.teleport;
|
protected Effect teleportEffect = BlockFx.teleport;
|
||||||
protected Effect teleportOutEffect = BlockFx.teleportOut;
|
protected Effect teleportOutEffect = BlockFx.teleportOut;
|
||||||
|
|
||||||
@@ -54,9 +60,11 @@ public class Teleporter extends PowerBlock{
|
|||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
health = 80;
|
health = 80;
|
||||||
powerCapacity = 30f;
|
powerCapacity = 300f;
|
||||||
size = 3;
|
size = 3;
|
||||||
itemCapacity = 100;
|
itemCapacity = 100;
|
||||||
|
hasLiquids = true;
|
||||||
|
liquidCapacity = 100f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,25 +89,29 @@ public class Teleporter extends PowerBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
|
super.draw(tile);
|
||||||
|
|
||||||
TeleporterEntity entity = tile.entity();
|
TeleporterEntity entity = tile.entity();
|
||||||
float time = entity.time;
|
float time = entity.time;
|
||||||
|
float rad = entity.activeScl;
|
||||||
super.draw(tile);
|
|
||||||
|
|
||||||
Draw.color(getColor(tile, 0));
|
Draw.color(getColor(tile, 0));
|
||||||
Draw.rect("teleporter-top", tile.drawx(), tile.drawy());
|
Draw.rect("teleporter-top", tile.drawx(), tile.drawy());
|
||||||
|
Draw.reset();
|
||||||
|
|
||||||
|
if(rad <= 0.0001f) return;
|
||||||
|
|
||||||
Draw.color(getColor(tile, 0));
|
Draw.color(getColor(tile, 0));
|
||||||
|
|
||||||
Fill.circle(tile.drawx(), tile.drawy(), 7f + Mathf.absin(time+55, 8f, 1f));
|
Fill.circle(tile.drawx(), tile.drawy(), rad*(7f + Mathf.absin(time+55, 8f, 1f)));
|
||||||
|
|
||||||
Draw.color(getColor(tile, -1));
|
Draw.color(getColor(tile, -1));
|
||||||
|
|
||||||
Fill.circle(tile.drawx(), tile.drawy(), 2f + Mathf.absin(time, 7f, 3f));
|
Fill.circle(tile.drawx(), tile.drawy(), rad*(2f + Mathf.absin(time, 7f, 3f)));
|
||||||
|
|
||||||
for(int i = 0; i < 11; i ++){
|
for(int i = 0; i < 11; i ++){
|
||||||
Lines.swirl(tile.drawx(), tile.drawy(),
|
Lines.swirl(tile.drawx(), tile.drawy(),
|
||||||
2f + i/3f + Mathf.sin(time - i *75, 20f + i, 3f),
|
rad*(2f + i/3f + Mathf.sin(time - i *75, 20f + i, 3f)),
|
||||||
0.3f + Mathf.sin(time + i *33, 10f + i, 0.1f),
|
0.3f + Mathf.sin(time + i *33, 10f + i, 0.1f),
|
||||||
time * (1f + Mathf.randomSeedRange(i + 1, 1f)) + Mathf.randomSeedRange(i, 360f));
|
time * (1f + Mathf.randomSeedRange(i + 1, 1f)) + Mathf.randomSeedRange(i, 360f));
|
||||||
}
|
}
|
||||||
@@ -107,12 +119,12 @@ public class Teleporter extends PowerBlock{
|
|||||||
Draw.color(getColor(tile, 1));
|
Draw.color(getColor(tile, 1));
|
||||||
|
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
Lines.circle(tile.drawx(), tile.drawy(), 7f + Mathf.absin(time+55, 8f, 1f));
|
Lines.circle(tile.drawx(), tile.drawy(), rad*(7f + Mathf.absin(time+55, 8f, 1f)));
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
|
|
||||||
for(int i = 0; i < 11; i ++){
|
for(int i = 0; i < 11; i ++){
|
||||||
Lines.swirl(tile.drawx(), tile.drawy(),
|
Lines.swirl(tile.drawx(), tile.drawy(),
|
||||||
3f + i/3f + Mathf.sin(time + i *93, 20f + i, 3f),
|
rad*(3f + i/3f + Mathf.sin(time + i *93, 20f + i, 3f)),
|
||||||
0.2f + Mathf.sin(time + i *33, 10f + i, 0.1f),
|
0.2f + Mathf.sin(time + i *33, 10f + i, 0.1f),
|
||||||
time * (1f + Mathf.randomSeedRange(i + 1, 1f)) + Mathf.randomSeedRange(i, 360f));
|
time * (1f + Mathf.randomSeedRange(i + 1, 1f)) + Mathf.randomSeedRange(i, 360f));
|
||||||
}
|
}
|
||||||
@@ -130,39 +142,71 @@ public class Teleporter extends PowerBlock{
|
|||||||
tryDump(tile);
|
tryDump(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.teleporting){
|
if(!entity.active){
|
||||||
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 2f, 0.01f);
|
entity.activeScl = Mathf.lerpDelta(entity.activeScl, 0f, 0.01f);
|
||||||
}else{
|
|
||||||
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.04f);
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.time += Timers.delta()*entity.speedScl;
|
if(entity.power.amount >= powerCapacity){
|
||||||
|
entity.active = true;
|
||||||
if(entity.inventory.totalItems() == itemCapacity && entity.power.amount >= powerCapacity &&
|
|
||||||
entity.timer.get(timerTeleport, teleportMax)){
|
|
||||||
Array<Tile> testLinks = findLinks(tile);
|
|
||||||
|
|
||||||
if(testLinks.size == 0) return;
|
|
||||||
|
|
||||||
entity.teleporting = true;
|
|
||||||
|
|
||||||
Effects.effect(teleportEffect, getColor(tile, 0), tile.drawx(), tile.drawy());
|
|
||||||
Timers.run(warmupTime, () -> {
|
|
||||||
Array<Tile> links = findLinks(tile);
|
|
||||||
|
|
||||||
for(Tile other : links){
|
|
||||||
int canAccept = itemCapacity - other.entity.inventory.totalItems();
|
|
||||||
int total = entity.inventory.totalItems();
|
|
||||||
if(total == 0) break;
|
|
||||||
Effects.effect(teleportOutEffect, getColor(tile, 0), other.drawx(), other.drawy());
|
|
||||||
for(int i = 0; i < canAccept && i < total; i ++){
|
|
||||||
other.entity.inventory.addItem(entity.inventory.takeItem(), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Effects.effect(teleportOutEffect, getColor(tile, 0), tile.drawx(), tile.drawy());
|
|
||||||
entity.power.amount = 0f;
|
entity.power.amount = 0f;
|
||||||
entity.teleporting = false;
|
Effects.effect(activateEffect, getColor(tile, 0), tile.drawx(), tile.drawy());
|
||||||
});
|
}
|
||||||
|
}else {
|
||||||
|
entity.activeScl = Mathf.lerpDelta(entity.activeScl, 1f, 0.015f);
|
||||||
|
|
||||||
|
float powerUsed = Math.min(powerCapacity, powerUse * Timers.delta());
|
||||||
|
|
||||||
|
if (entity.power.amount >= powerUsed) {
|
||||||
|
entity.power.amount -= powerUsed;
|
||||||
|
entity.powerLackScl = Mathf.lerpDelta(entity.powerLackScl, 0f, 0.01f);
|
||||||
|
}else{
|
||||||
|
entity.powerLackScl = Mathf.lerpDelta(entity.powerLackScl, 1f, 0.01f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity.powerLackScl >= 0.999f){
|
||||||
|
catastrophicFailure(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.teleporting) {
|
||||||
|
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 2f, 0.01f);
|
||||||
|
float liquidUsed = Math.min(liquidCapacity, liquidUse * Timers.delta());
|
||||||
|
|
||||||
|
if (entity.liquid.amount >= liquidUsed) {
|
||||||
|
entity.liquid.amount -= liquidUsed;
|
||||||
|
} else {
|
||||||
|
catastrophicFailure(tile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entity.speedScl = Mathf.lerpDelta(entity.speedScl, 1f, 0.04f);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.time += Timers.delta() * entity.speedScl;
|
||||||
|
|
||||||
|
if (entity.inventory.totalItems() == itemCapacity && entity.power.amount >= powerCapacity &&
|
||||||
|
entity.timer.get(timerTeleport, teleportMax)) {
|
||||||
|
Array<Tile> testLinks = findLinks(tile);
|
||||||
|
|
||||||
|
if (testLinks.size == 0) return;
|
||||||
|
|
||||||
|
entity.teleporting = true;
|
||||||
|
|
||||||
|
Effects.effect(teleportEffect, getColor(tile, 0), tile.drawx(), tile.drawy());
|
||||||
|
Timers.run(warmupTime, () -> {
|
||||||
|
Array<Tile> links = findLinks(tile);
|
||||||
|
|
||||||
|
for (Tile other : links) {
|
||||||
|
int canAccept = itemCapacity - other.entity.inventory.totalItems();
|
||||||
|
int total = entity.inventory.totalItems();
|
||||||
|
if (total == 0) break;
|
||||||
|
Effects.effect(teleportOutEffect, getColor(tile, 0), other.drawx(), other.drawy());
|
||||||
|
for (int i = 0; i < canAccept && i < total; i++) {
|
||||||
|
other.entity.inventory.addItem(entity.inventory.takeItem(), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Effects.effect(teleportOutEffect, getColor(tile, 0), tile.drawx(), tile.drawy());
|
||||||
|
entity.power.amount = 0f;
|
||||||
|
entity.teleporting = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +255,15 @@ public class Teleporter extends PowerBlock{
|
|||||||
return new TeleporterEntity();
|
return new TeleporterEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount) {
|
||||||
|
return super.acceptLiquid(tile, source, liquid, amount) && liquid == inputLiquid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void catastrophicFailure(Tile tile){
|
||||||
|
//TODO fail gloriously
|
||||||
|
}
|
||||||
|
|
||||||
private Color getColor(Tile tile, int shift){
|
private Color getColor(Tile tile, int shift){
|
||||||
TeleporterEntity entity = tile.entity();
|
TeleporterEntity entity = tile.entity();
|
||||||
|
|
||||||
@@ -230,7 +283,9 @@ public class Teleporter extends PowerBlock{
|
|||||||
for(Tile other : teleporters[entity.color]){
|
for(Tile other : teleporters[entity.color]){
|
||||||
if(other != tile){
|
if(other != tile){
|
||||||
if(other.block() instanceof Teleporter){
|
if(other.block() instanceof Teleporter){
|
||||||
if(other.<TeleporterEntity>entity().color != entity.color){
|
TeleporterEntity oe = other.entity();
|
||||||
|
if(!oe.active) continue;
|
||||||
|
if(oe.color != entity.color){
|
||||||
removal.add(other);
|
removal.add(other);
|
||||||
}else if(other.entity.inventory.totalItems() == 0){
|
}else if(other.entity.inventory.totalItems() == 0){
|
||||||
returns.add(other);
|
returns.add(other);
|
||||||
@@ -250,7 +305,10 @@ public class Teleporter extends PowerBlock{
|
|||||||
public static class TeleporterEntity extends TileEntity{
|
public static class TeleporterEntity extends TileEntity{
|
||||||
public byte color = 0;
|
public byte color = 0;
|
||||||
public boolean teleporting;
|
public boolean teleporting;
|
||||||
|
public boolean active;
|
||||||
|
public float activeScl = 0f;
|
||||||
public float speedScl = 1f;
|
public float speedScl = 1f;
|
||||||
|
public float powerLackScl;
|
||||||
public float time;
|
public float time;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||