More reorganization, implemented multiblock drills, API changes

This commit is contained in:
Anuken 2018-03-04 22:00:32 -05:00
parent 099d88ba7b
commit 292dbf101b
70 changed files with 606 additions and 559 deletions

View file

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 304 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 459 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

View file

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 203 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 383 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 496 B

After

Width:  |  Height:  |  Size: 496 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 520 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

View file

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 329 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

After

Width:  |  Height:  |  Size: 338 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 450 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

View file

Before

Width:  |  Height:  |  Size: 370 B

After

Width:  |  Height:  |  Size: 370 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 677 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 384 B

View file

Before

Width:  |  Height:  |  Size: 128 B

After

Width:  |  Height:  |  Size: 128 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 189 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 203 B

After

Width:  |  Height:  |  Size: 203 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 305 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 307 B

After

Width:  |  Height:  |  Size: 307 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 221 B

After

Width:  |  Height:  |  Size: 221 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 194 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 224 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

View file

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 307 B

After

Width:  |  Height:  |  Size: 307 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 262 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 295 B

After

Width:  |  Height:  |  Size: 295 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 276 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 207 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 282 B

Before After
Before After

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before After
Before After

View file

@ -1,7 +1,7 @@
#Autogenerated file. Do not modify.
#Sun Mar 04 15:33:08 EST 2018
#Sun Mar 04 21:59:47 EST 2018
version=release
androidBuildCode=369
androidBuildCode=384
name=Mindustry
code=3.4
build=custom build

View file

@ -288,7 +288,6 @@ public class Control extends Module{
Timers.run(1f, Musics::shuffleAll);
Entities.initPhysics();
Entities.collisions().setCollider(tilesize, world::solid);
Platform.instance.updateRPC();

View file

@ -389,7 +389,7 @@ public class Renderer extends RendererModule{
Draw.color(Colors.get("accent"));
Lines.stroke(1f);
Lines.square(tile.drawx(), tile.drawy(),
tile.block().width * tilesize / 2f + 1f);
tile.block().size * tilesize / 2f + 1f);
Draw.reset();
}
@ -447,7 +447,7 @@ public class Renderer extends RendererModule{
if(showBlockDebug && target.entity != null){
Draw.color(Color.RED);
Lines.crect(target.drawx(), target.drawy(), target.block().width * tilesize, target.block().height * tilesize);
Lines.crect(target.drawx(), target.drawy(), target.block().size * tilesize, target.block().size * tilesize);
Vector2 v = new Vector2();
@ -472,14 +472,14 @@ public class Renderer extends RendererModule{
if(Inputs.keyDown("block_info") && target.block().fullDescription != null){
Draw.color(Colors.get("accent"));
Lines.crect(target.drawx(), target.drawy(), target.block().width * tilesize, target.block().height * tilesize);
Lines.crect(target.drawx(), target.drawy(), target.block().size * tilesize, target.block().size * tilesize);
Draw.color();
}
if(target.entity != null) {
int bot = 0, top = 0;
for (BlockBar bar : target.block().bars) {
float offset = Mathf.sign(bar.top) * (target.block().height / 2f * tilesize + 3f + 4f * ((bar.top ? top : bot))) +
float offset = Mathf.sign(bar.top) * (target.block().size / 2f * tilesize + 3f + 4f * ((bar.top ? top : bot))) +
(bar.top ? -1f : 0f);
float value = bar.value.get(target);

View file

@ -32,7 +32,7 @@ public class World extends Module{
private Tile core;
private Array<SpawnPoint> spawns = new Array<>();
private Tile[] temptiles = new Tile[4];
private Array<Tile> tempTiles = new Array<>();
public World(){
maps.loadMaps();
@ -241,7 +241,7 @@ public class World extends Module{
tile.setBlock(Blocks.air);
}else{
Tile target = tile.target();
Array<Tile> removals = target.getLinkedTiles();
Array<Tile> removals = target.getLinkedTiles(tempTiles);
for(Tile toremove : removals){
//note that setting a new block automatically unlinks it
toremove.setBlock(Blocks.air);

View file

@ -28,7 +28,7 @@ public class BlastType extends EnemyType {
if(enemy.target instanceof TileEntity){
TileEntity e = (TileEntity)enemy.target;
range = (e.tile.block().width * tilesize) /2f + 8f;
range = (e.tile.block().size * tilesize) /2f + 8f;
ox = e.tile.block().getPlaceOffset().x;
oy = e.tile.block().getPlaceOffset().y;
}

View file

@ -1,7 +1,6 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.math.GridPoint2;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
@ -327,7 +326,7 @@ public class Tutorial{
canForward = false;
showBlock = true;
canPlace = true;
targetBlock = WeaponBlocks.turret;
targetBlock = WeaponBlocks.doubleturret;
blockPlaceX = 2;
blockPlaceY = 2;
}

View file

@ -158,13 +158,13 @@ public class DesktopInput extends InputHandler{
public int tilex(){
return (recipe != null && recipe.result.isMultiblock() &&
recipe.result.width % 2 == 0) ?
recipe.result.size % 2 == 0) ?
Mathf.scl(Graphics.mouseWorld().x, tilesize) : Mathf.scl2(Graphics.mouseWorld().x, tilesize);
}
public int tiley(){
return (recipe != null && recipe.result.isMultiblock() &&
recipe.result.height % 2 == 0) ?
recipe.result.size % 2 == 0) ?
Mathf.scl(Graphics.mouseWorld().y, tilesize) : Mathf.scl2(Graphics.mouseWorld().y, tilesize);
}

View file

@ -71,7 +71,7 @@ public abstract class InputHandler extends InputAdapter{
}
public boolean round2(){
return !(recipe != null && recipe.result.isMultiblock() && recipe.result.height % 2 == 0);
return !(recipe != null && recipe.result.isMultiblock() && recipe.result.size % 2 == 0);
}
public boolean validPlace(int x, int y, Block type){

View file

@ -36,8 +36,8 @@ public enum PlaceMode{
Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid"));
Lines.stroke(2f);
Lines.crect(x + offset.x, y + offset.y, tilesize * control.input().recipe.result.width + si,
tilesize * control.input().recipe.result.height + si);
Lines.crect(x + offset.x, y + offset.y, tilesize * control.input().recipe.result.size + si,
tilesize * control.input().recipe.result.size + si);
control.input().recipe.result.drawPlace(tilex, tiley, control.input().rotation, valid);
Lines.stroke(2f);
@ -150,7 +150,7 @@ public enum PlaceMode{
tile = tile.getLinked();
if(tile != null && control.input().validBreak(tile.x, tile.y)){
Lines.crect(tile.drawx(), tile.drawy(),
tile.block().width * t, tile.block().height * t);
tile.block().size* t, tile.block().size * t);
}
}
}
@ -251,13 +251,13 @@ public enum PlaceMode{
x2 = this.endx * t, y2 = this.endy * t;
if(x2 >= x){
x -= block.width * t/2;
x2 += block.width * t/2;
x -= block.size * t/2;
x2 += block.size * t/2;
}
if(y2 >= y){
y -= block.height * t/2;
y2 += block.height * t/2;
y -= block.size * t/2;
y2 += block.size * t/2;
}
x += offset.x;
@ -284,7 +284,7 @@ public enum PlaceMode{
if(!control.input().validPlace(px, py, control.input().recipe.result)
|| !state.inventory.hasItems(control.input().recipe.requirements, amount)){
Lines.crect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
Lines.crect(px * t + offset.x, py * t + offset.y, t*block.size, t*block.size);
}
amount ++;
}

View file

@ -9,35 +9,37 @@ public class Item{
private static final Array<Item> items = new Array<>();
public static final Item
stone = new Item("stone"),
iron = new Item("iron"),
coal = new Item("coal"){
{
explosiveness = 0.2f;
flammability = 0.5f;
material = false;
}
},
steel = new Item("steel"),
titanium = new Item("titanium"),
dirium = new Item("dirium"),
uranium = new Item("uranium"){
{
explosiveness = 0.1f;
material = false;
}
},
quartz = new Item("quartz") {
{
material = false;
}
},
glass = new Item("glass"),
silicon = new Item("silicon"){
{
material = false;
}
};
stone = new Item("stone"),
iron = new Item("iron"),
coal = new Item("coal"){
{
explosiveness = 0.2f;
flammability = 0.5f;
material = false;
}
},
steel = new Item("steel"),
titanium = new Item("titanium"),
dirium = new Item("dirium"),
uranium = new Item("uranium"){
{
explosiveness = 0.1f;
material = false;
}
},
quartz = new Item("quartz") {
{
material = false;
}
},
glass = new Item("glass"),
silicon = new Item("silicon"),
biomatter = new Item("biomatter"){
{
material = false;
flammability = 0.4f;
}
};
public final int id;
public final String name;
@ -55,7 +57,7 @@ public class Item{
}
public void init(){
this.region = Draw.region("icon-" + name);
this.region = Draw.region("item-" + name);
}
public String localizedName(){

View file

@ -9,7 +9,7 @@ public class ItemStack{
this.item = item;
this.amount = amount;
}
public boolean equals(ItemStack other){
return other != null && other.item == item && other.amount == amount;
}

View file

@ -34,16 +34,14 @@ public class Recipes {
new Recipe(distribution, DistributionBlocks.vault, stack(Item.steel, 50)),
new Recipe(distribution, DistributionBlocks.unloader, stack(Item.steel, 5)),
//new Recipe(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
new Recipe(weapon, WeaponBlocks.doubleturret, stack(Item.stone, 7)),
new Recipe(weapon, WeaponBlocks.machineturret, stack(Item.iron, 8), stack(Item.stone, 10)),
//new Recipe(weapon, WeaponBlocks.shotgunturret, stack(Item.iron, 10), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.gatlingturret, stack(Item.iron, 8), stack(Item.stone, 10)),
new Recipe(weapon, WeaponBlocks.flameturret, stack(Item.iron, 12), stack(Item.steel, 9)),
new Recipe(weapon, WeaponBlocks.sniperturret, stack(Item.iron, 15), stack(Item.steel, 10)),
new Recipe(weapon, WeaponBlocks.railgunturret, stack(Item.iron, 15), stack(Item.steel, 10)),
new Recipe(weapon, WeaponBlocks.laserturret, stack(Item.steel, 12), stack(Item.titanium, 12)),
new Recipe(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
new Recipe(weapon, WeaponBlocks.flakturret, stack(Item.steel, 25), stack(Item.titanium, 15)),
new Recipe(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 25), stack(Item.dirium, 15)),
//new Recipe(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 20), stack(Item.dirium, 15)),
new Recipe(weapon, WeaponBlocks.magmaturret, stack(Item.steel, 80), stack(Item.titanium, 70), stack(Item.dirium, 60)),
new Recipe(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 40)),
new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),

View file

@ -269,7 +269,7 @@ public class BlocksFragment implements Fragment{
desctable.left();
for(ItemStack stack : recipe.requirements){
requirements.addImage(Draw.region("icon-"+stack.item.name)).size(8*3);
requirements.addImage(stack.item.region).size(8*3);
Label reqlabel = new Label("");
reqlabel.update(()->{
@ -309,7 +309,7 @@ public class BlocksFragment implements Fragment{
pane.setFadeScrollBars(false);
Table top = new Table();
top.left();
top.add(new Image(Draw.region(block.name))).size(8*5 * block.width);
top.add(new Image(Draw.region(block.name))).size(8*5 * block.size);
top.add("[accent]"+block.formalName).padLeft(6f);
table.add(top).fill().left();
table.row();
@ -357,8 +357,7 @@ public class BlocksFragment implements Fragment{
int amount = state.inventory.getItems()[i];
if(amount == 0) continue;
String formatted = amount > 99999999 ? "inf" : format(amount);
Image image = new Image(Draw.hasRegion("icon-" + Item.getByID(i).name) ?
Draw.region("icon-" + Item.getByID(i).name) : Draw.region("blank"));
Image image = new Image(Item.getByID(i).region);
Label label = new Label(formatted);
label.setFontScale(fontscale*1.5f);
itemtable.add(image).size(8*3);

View file

@ -28,8 +28,8 @@ public class Block{
private static int lastid;
private static Array<Block> blocks = new Array<>();
private static ObjectMap<String, Block> map = new ObjectMap<>();
protected static TextureRegion temp = new TextureRegion();
protected Array<Tile> tempTiles = new Array<>();
protected Vector2 offset = new Vector2();
/**internal name*/
@ -72,8 +72,8 @@ public class Block{
public ItemStack drops = null;
/**liquids that drop from this block, used for pumps*/
public Liquid liquidDrop = null;
/**multiblock width/height*/
public int width = 1, height = 1;
/**multiblock size*/
public int size = 1;
/**Brief block description. Should be short enough fit in the place menu.*/
public final String description;
/**Detailed description of the block. Can be as long as necesary.*/
@ -131,7 +131,7 @@ public class Block{
}
public void getStats(Array<String> list){
list.add("[gray]size: " + width + "x" + height);
list.add("[gray]size: " + size);
list.add("[healthstats]health: " + health);
}
@ -194,11 +194,11 @@ public class Block{
* Tries to put this item into a nearby container, if there are no available
* containers, it gets added to the block's inventory.*/
public void offloadNear(Tile tile, Item item){
GridPoint2[] nearby = Edges.getEdges(width);
GridPoint2[] nearby = Edges.getEdges(size);
for(int j = 0; j < nearby.length; j ++){
Tile other = tile.getNearby(nearby[j]);
Tile in = tile.getNearby(Edges.getInsideEdges(width)[j]);
Tile in = tile.getNearby(Edges.getInsideEdges(size)[j]);
if(other != null && other.block().acceptItem(item, other, in) && canDump(tile, other, item)){
other.block().handleItem(item, other, in);
return;
@ -215,7 +215,7 @@ public class Block{
/**Try dumping a specific item near the tile.*/
protected boolean tryDump(Tile tile, Item todump){
GridPoint2[] nearby = Edges.getEdges(width);
GridPoint2[] nearby = Edges.getEdges(size);
byte i = (byte)(tile.getDump() % nearby.length);
for(int j = 0; j < nearby.length; j ++){
@ -224,7 +224,7 @@ public class Block{
for(Item item : Item.getAllItems()){
other = tile.getNearby(nearby[i]);
in = tile.getNearby(Edges.getInsideEdges(width)[i]);
in = tile.getNearby(Edges.getInsideEdges(size)[i]);
if(todump != null && item != todump) continue;
@ -289,11 +289,11 @@ public class Block{
/**Offset for placing and drawing multiblocks.*/
public Vector2 getPlaceOffset(){
return offset.set(((width + 1) % 2) * tilesize/2, ((height + 1) % 2) * tilesize/2);
return offset.set(((size + 1) % 2) * tilesize/2, ((size + 1) % 2) * tilesize/2);
}
public boolean isMultiblock(){
return width != 1 || height != 1;
return size > 1;
}
public static Array<Block> getAllBlocks(){

View file

@ -20,6 +20,7 @@ import static io.anuke.mindustry.Vars.*;
public class Placement {
private static final Rectangle rect = new Rectangle();
private static Array<Tile> tempTiles = new Array<>();
/**Returns block type that was broken, or null if unsuccesful.*/
public static Block breakBlock(int x, int y, boolean effect, boolean sound){
@ -47,7 +48,7 @@ public class Placement {
if(effect) Effects.effect(Fx.breakBlock, tile.worldx(), tile.worldy());
}else{
Tile target = tile.isLinked() ? tile.getLinked() : tile;
Array<Tile> removals = target.getLinkedTiles();
Array<Tile> removals = target.getLinkedTiles(tempTiles);
for(Tile toremove : removals){
//note that setting a new block automatically unlinks it
toremove.setBlock(Blocks.air);
@ -67,11 +68,11 @@ public class Placement {
tile.setBlock(result, rotation);
if(result.isMultiblock()){
int offsetx = -(result.width-1)/2;
int offsety = -(result.height-1)/2;
int offsetx = -(result.size-1)/2;
int offsety = -(result.size-1)/2;
for(int dx = 0; dx < result.width; dx ++){
for(int dy = 0; dy < result.height; dy ++){
for(int dx = 0; dx < result.size; dx ++){
for(int dy = 0; dy < result.size; dy ++){
int worldx = dx + offsetx + x;
int worldy = dy + offsety + y;
if(!(worldx == x && worldy == y)){
@ -102,7 +103,7 @@ public class Placement {
return false;
}
rect.setSize(type.width * tilesize, type.height * tilesize);
rect.setSize(type.size * tilesize, type.size * tilesize);
Vector2 offset = type.getPlaceOffset();
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
@ -130,10 +131,10 @@ public class Placement {
if(tile == null || (isSpawnPoint(tile) && (type.solidifes || type.solid))) return false;
if(type.isMultiblock()){
int offsetx = -(type.width-1)/2;
int offsety = -(type.height-1)/2;
for(int dx = 0; dx < type.width; dx ++){
for(int dy = 0; dy < type.height; dy ++){
int offsetx = -(type.size-1)/2;
int offsety = -(type.size-1)/2;
for(int dx = 0; dx < type.size; dx ++){
for(int dy = 0; dy < type.size; dy ++){
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
if(other == null || (other.block() != Blocks.air && !other.block().alwaysReplace) || isSpawnPoint(other)){
return false;

View file

@ -16,7 +16,6 @@ import static io.anuke.mindustry.Vars.world;
public class Tile{
public static final Object tileSetLock = new Object();
private static final Array<Tile> tmpArray = new Array<>();
/**Block ID data.*/
private byte floor, wall;
@ -201,18 +200,20 @@ public class Tile{
/**Returns the list of all tiles linked to this multiblock, or an empty array if it's not a multiblock.
* This array contains all linked tiles, including this tile itself.*/
public synchronized Array<Tile> getLinkedTiles(){
public synchronized Array<Tile> getLinkedTiles(Array<Tile> tmpArray){
Block block = block();
tmpArray.clear();
if(!(block.width == 1 && block.height == 1)){
int offsetx = -(block.width-1)/2;
int offsety = -(block.height-1)/2;
for(int dx = 0; dx < block.width; dx ++){
for(int dy = 0; dy < block.height; dy ++){
if(block.isMultiblock()){
int offsetx = -(block.size-1)/2;
int offsety = -(block.size-1)/2;
for(int dx = 0; dx < block.size; dx ++){
for(int dy = 0; dy < block.size; dy ++){
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
tmpArray.add(other);
}
}
}else{
tmpArray.add(this);
}
return tmpArray;
}
@ -229,7 +230,7 @@ public class Tile{
}
public void allNearby(Consumer<Tile> cons){
for(GridPoint2 point : Edges.getEdges(block().width)){
for(GridPoint2 point : Edges.getEdges(block().size)){
Tile tile = world.tile(x + point.x, y + point.y);
if(tile != null){
cons.accept(tile.target());
@ -238,7 +239,7 @@ public class Tile{
}
public void allInside(Consumer<Tile> cons){
for(GridPoint2 point : Edges.getInsideEdges(block().width)){
for(GridPoint2 point : Edges.getInsideEdges(block().size)){
Tile tile = world.tile(x + point.x, y + point.y);
if(tile != null){
cons.accept(tile);

View file

@ -33,15 +33,15 @@ public class DefenseBlocks{
}},
steelwalllarge = new Wall("steelwall-large"){{
health = 110*4*wallHealthMultiplier;
width = height = 2;
size = 2;
}},
titaniumwalllarge = new Wall("titaniumwall-large"){{
health = 150*4*wallHealthMultiplier;
width = height = 2;
size = 2;
}},
diriumwalllarge = new Wall("duriumwall-large"){{
health = 190*4*wallHealthMultiplier;
width = height = 2;
size = 2;
}},
titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall"){{
health = 150*wallHealthMultiplier;
@ -62,7 +62,7 @@ public class DefenseBlocks{
reload = 12f;
health = 90;
powerUsed = 0.13f;
width = height = 2;
size = 2;
}
},
@ -78,6 +78,6 @@ public class DefenseBlocks{
openfx = Fx.dooropenlarge;
closefx = Fx.doorcloselarge;
health = 90*4*wallHealthMultiplier;
width = height = 2;
size = 2;
}};
}

View file

@ -41,12 +41,12 @@ public class DistributionBlocks{
}},
multiplexer = new Router("multiplexer"){{
width = height = 2;
size = 2;
capacity = 80;
}},
vault = new Vault("vault"){{
width = height = 3;
size = 3;
}},
unloader = new Unloader("unloader"){{

View file

@ -178,6 +178,7 @@ public class ProductionBlocks{
resource = Blocks.sand;
result = Item.quartz;
time = 5;
size = 2;
}
},
@ -215,15 +216,14 @@ public class ProductionBlocks{
},
nuclearReactor = new NuclearReactor("nuclearreactor"){
{
width = 3;
height = 3;
size = 3;
health = 600;
breaktime *= 2.3f;
}
},
weaponFactory = new WeaponFactory("weaponfactory"){
{
width = height = 2;
size = 2;
health = 250;
}
};

View file

@ -5,9 +5,11 @@ import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.effect.TeslaOrb;
import io.anuke.mindustry.graphics.Fx;
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.defense.LaserTurret;
import io.anuke.mindustry.world.blocks.types.defense.LiquidTurret;
import io.anuke.mindustry.world.blocks.types.defense.PowerTurret;
import io.anuke.mindustry.world.blocks.types.defense.Turret;
import io.anuke.ucore.core.Effects;
@ -17,16 +19,6 @@ import io.anuke.ucore.util.Mathf;
public class WeaponBlocks{
public static Block
turret = new Turret("turret"){
{
range = 52;
reload = 15f;
bullet = BulletType.stone;
health = 45;
ammo = Item.stone;
}
},
doubleturret = new Turret("doubleturret"){
{
range = 44;
@ -48,7 +40,7 @@ public class WeaponBlocks{
}
},
machineturret = new Turret("machineturret"){
gatlingturret = new Turret("gatlingturret"){
{
range = 65;
reload = 7f;
@ -58,19 +50,6 @@ public class WeaponBlocks{
}
},
shotgunturret = new Turret("shotgunturret"){
{
range = 50;
reload = 30f;
bullet = BulletType.iron;
ammo = Item.iron;
health = 70;
shots = 5;
inaccuracy = 15f;
shotDelayScale = 0.7f;
}
},
flameturret = new Turret("flameturret"){
{
range = 45f;
@ -82,7 +61,7 @@ public class WeaponBlocks{
}
},
sniperturret = new Turret("sniperturret"){
railgunturret = new Turret("railgunturret"){
{
shootsound = "railgun";
range = 120;
@ -94,7 +73,7 @@ public class WeaponBlocks{
}
},
mortarturret = new Turret("mortarturret"){
flakturret = new Turret("flakturret"){
{
shootsound = "bigshot";
rotatespeed = 0.2f;
@ -108,6 +87,7 @@ public class WeaponBlocks{
health = 110;
shootEffect = Fx.mortarshot;
shootShake = 2f;
size = 2;
}
},
@ -123,7 +103,7 @@ public class WeaponBlocks{
}
},
teslaturret = new PowerTurret("waveturret"){
teslaturret = new PowerTurret("teslaturret"){
{
shootsound = "tesla";
range = 70;
@ -141,6 +121,20 @@ public class WeaponBlocks{
new TeslaOrb(tile.drawx() + Angles.trnsx(entity.rotation, len), tile.drawy() + Angles.trnsy(entity.rotation, len), range, 9).add();
}
},
magmaturret = new LiquidTurret("magmaturret") {
{
shootsound = "flame2";
inaccuracy = 7f;
range = 90f;
reload = 7f;
bullet = BulletType.plasmaflame;
ammoLiquid = Liquid.lava;
liquidPerShot = 3f;
health = 180*3;
size = 2;
}
},
plasmaturret = new Turret("plasmaturret"){
{
@ -164,7 +158,7 @@ public class WeaponBlocks{
bullet = BulletType.chain;
ammo = Item.uranium;
health = 430;
width = height = 2;
size = 2;
shootCone = 9f;
ammoMultiplier = 8;
shots = 2;
@ -198,7 +192,7 @@ public class WeaponBlocks{
ammo = Item.uranium;
health = 800;
ammoMultiplier = 4;
width = height = 3;
size = 3;
rotatespeed = 0.07f;
shootCone = 9f;
shootEffect = Fx.titanshot;

View file

@ -11,6 +11,7 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world;
public class Floor extends Block{
protected TextureRegion tempRegion = new TextureRegion();
protected Predicate<Block> blends = block -> block != this;
protected boolean blend = true;
@ -50,10 +51,10 @@ public class Floor extends Block{
float rx = Mathf.clamp(dx*8, 0, 8-w);
float ry = Mathf.clamp(dy*8, 0, 8-h);
temp.setTexture(region.getTexture());
temp.setRegion(region.getRegionX()+x, region.getRegionY()+y+h, w, -h);
tempRegion.setTexture(region.getTexture());
tempRegion.setRegion(region.getRegionX()+x, region.getRegionY()+y+h, w, -h);
Draw.crect(temp, tile.worldx()-4 + rx, tile.worldy()-4 + ry, w, h);
Draw.crect(tempRegion, tile.worldx()-4 + rx, tile.worldy()-4 + ry, w, h);
}
}
}

View file

@ -66,7 +66,7 @@ public class Door extends Wall{
boolean anyEntities(Tile tile){
int x = tile.x, y = tile.y;
Block type = tile.block();
rect.setSize(type.width * tilesize, type.height * tilesize);
rect.setSize(type.size * tilesize, type.size * tilesize);
rect.setCenter(tile.drawx(), tile.drawy());
for(SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){

View file

@ -11,7 +11,7 @@ import java.io.IOException;
public abstract class LiquidTurret extends Turret implements LiquidAcceptor{
public Liquid ammoLiquid = Liquid.water;
public float liquidCapacity = 20f;
public float liquidCapacity = 60f;
public float liquidPerShot = 1f;
public LiquidTurret(String name) {

View file

@ -53,6 +53,7 @@ public class Turret extends Block{
protected float shootShake = 0f;
protected int soundReload = 0;
protected Translator tr = new Translator();
protected String base = null; //name of the region to draw under turret, usually null
public Turret(String name) {
super(name);
@ -83,10 +84,10 @@ public class Turret extends Block{
@Override
public void draw(Tile tile){
if(isMultiblock()){
Draw.rect("block-" + width + "x" + height, tile.drawx(), tile.drawy());
if(base == null) {
Draw.rect("block-" + size, tile.drawx(), tile.drawy());
}else{
Draw.rect("block", tile.drawx(), tile.drawy());
Draw.rect(base, tile.drawx(), tile.drawy());
}
}
@ -212,14 +213,14 @@ public class Turret extends Block{
protected void shoot(Tile tile){
TurretEntity entity = tile.entity();
tr.trns(entity.rotation, width * tilesize/2);
tr.trns(entity.rotation, size * tilesize/2);
for(int i = 0; i < shots; i ++){
if(Mathf.zero(shotDelayScale)){
bullet(tile, entity.rotation + Mathf.range(inaccuracy));
}else{
Timers.run(i * shotDelayScale, () -> {
tr.trns(entity.rotation, width * tilesize/2f);
tr.trns(entity.rotation, size * tilesize/2f);
bullet(tile, entity.rotation + Mathf.range(inaccuracy));
});
}

View file

@ -1,22 +1,23 @@
package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Layer;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
public class Drill extends Block{
protected final int timerDrill = timers++;
protected final int timerDump = timers++;
protected final Array<Tile> drawTiles = new Array<>();
protected Block resource;
protected Item result;
@ -41,11 +42,22 @@ public class Drill extends Block{
@Override
public void update(Tile tile){
TileEntity entity = tile.entity;
if((tile.floor() == resource || (resource.drops.equals(tile.floor().drops)))
&& entity.timer.get(timerDrill, 60 * time) && tile.entity.getItem(result) < capacity){
offloadNear(tile, result);
Effects.effect(drillEffect, tile.worldx(), tile.worldy());
int mines = 0;
if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(tempTiles)){
if(isValid(other)){
mines ++;
}
}
}else{
if(isValid(tile)) mines = 1;
}
if(mines > 0 && entity.timer.get(timerDrill, 60 * time) && tile.entity.getItem(result) < capacity){
for(int i = 0; i < mines; i ++) offloadNear(tile, result);
Effects.effect(drillEffect, tile.drawx(), tile.drawy());
}
if(entity.timer.get(timerDump, 30)){
@ -55,14 +67,27 @@ public class Drill extends Block{
@Override
public boolean isLayer(Tile tile){
return tile.floor() != resource && resource != null && !(resource.drops.equals(tile.floor().drops));
if(isMultiblock()){
for(Tile other : tile.getLinkedTiles(drawTiles)){
if(isValid(other)){
return false;
}
}
return true;
}else{
return !isValid(tile);
}
}
@Override
public void drawLayer(Tile tile){
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
Draw.rect("cross", tile.worldx(), tile.worldy());
Draw.rect("cross-" + size, tile.drawx(), tile.drawy());
Draw.color();
}
boolean isValid(Tile tile){
return tile.floor() == resource || (resource != null && resource.drops.equals(tile.floor().drops));
}
}

View file

@ -194,10 +194,10 @@ public class Generator extends PowerBlock{
if(target != null){
boolean interfering = isInterfering(target, rotation);
t1.trns(rotation * 90, target.block().width * tilesize / 2 + 2f +
(interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - tilesize / 2f * target.block().width + 1 : 0));
t1.trns(rotation * 90, target.block().size * tilesize / 2 + 2f +
(interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - tilesize / 2f * target.block().size + 1 : 0));
t2.trns(rotation * 90, width * tilesize / 2 + 2f);
t2.trns(rotation * 90, size * tilesize / 2 + 2f);
if(!interfering){
Draw.tint(Hue.mix(Color.GRAY, Color.WHITE, 0.904f + Mathf.sin(Timers.time(), 1.7f, 0.06f)));
@ -222,8 +222,8 @@ public class Generator extends PowerBlock{
float sclx = (relative == 1 || relative == 3) ? entity.laserThickness : 1f;
float scly = (relative == 1 || relative == 3) ? 1f : entity.laserThickness;
Draw.rect("laserfull",
tile.worldx() + Geometry.d4[relative].x * width * tilesize / 2f,
tile.worldy() + Geometry.d4[relative].y * width * tilesize / 2f , s * sclx, s * scly);
tile.worldx() + Geometry.d4[relative].x * size * tilesize / 2f,
tile.worldy() + Geometry.d4[relative].y * size * tilesize / 2f , s * sclx, s * scly);
}
Draw.color();

View file

@ -89,8 +89,8 @@ public class NuclearReactor extends LiquidPowerGenerator{
if(entity.heat > smokeThreshold){
float smoke = 1.0f + (entity.heat - smokeThreshold) / (1f - smokeThreshold); //ranges from 1.0 to 2.0
if(Mathf.chance(smoke / 20.0 * Timers.delta())){
Effects.effect(Fx.reactorsmoke, tile.worldx() + Mathf.range(width * tilesize / 2f),
tile.worldy() + Mathf.random(height * tilesize / 2f));
Effects.effect(Fx.reactorsmoke, tile.worldx() + Mathf.range(size * tilesize / 2f),
tile.worldy() + Mathf.random(size * tilesize / 2f));
}
}
@ -166,7 +166,7 @@ public class NuclearReactor extends LiquidPowerGenerator{
NuclearReactorEntity entity = tile.entity();
Draw.color(coolColor, hotColor, entity.heat);
Draw.rect("white", tile.drawx(), tile.drawy(), width * tilesize, height * tilesize);
Draw.rect("white", tile.drawx(), tile.drawy(), size * tilesize, size * tilesize);
if(entity.heat > flashThreshold){
float flash = 1f + ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;

View file

@ -16,8 +16,7 @@ public class CoreBlock extends StorageBlock {
health = 800;
solid = true;
destructible = true;
width = 3;
height = 3;
size = 3;
}
@Override