Merge branch 'master' into crater

# Conflicts:
#	core/assets/sprites/sprites.atlas
#	core/assets/sprites/sprites.png
#	core/assets/sprites/sprites2.png
#	core/assets/sprites/sprites3.png
This commit is contained in:
Patrick 'Quezler' Mounier
2020-04-23 21:10:48 +02:00
140 changed files with 6579 additions and 6547 deletions

View File

@@ -90,10 +90,6 @@ public class Block extends UnlockableContent{
public CacheLayer cacheLayer = CacheLayer.normal;
/** Special flag; if false, floor will be drawn under this block even if it is cached. */
public boolean fillsTile = true;
/** Layer to draw extra stuff on. */
public Layer layer = null;
/** Extra layer to draw extra extra stuff on. */
public Layer layer2 = null;
/** whether this block can be replaced in all cases */
public boolean alwaysReplace = false;
/** The block group. Unless {@link #canReplace} is overriden, blocks in the same group can replace each other. */
@@ -204,14 +200,6 @@ public class Block extends UnlockableContent{
return sum / size / size;
}
public void drawLayer(Tile tile){
if(tile.entity != null) tile.entity.drawLayer();
}
public void drawLayer2(Tile tile){
if(tile.entity != null) tile.entity.drawLayer2();
}
/** Drawn when you are placing a block. */
public void drawPlace(int x, int y, int rotation, boolean valid){
}

View File

@@ -36,7 +36,6 @@ public class BuildBlock extends Block{
this.size = size;
update = true;
health = 20;
layer = Layer.placement;
consumesTap = true;
solidifes = true;
buildBlocks[size - 1] = this;
@@ -180,23 +179,22 @@ public class BuildBlock extends Block{
if(Core.atlas.isFound(previous.icon(Cicon.full))){
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? tile.rotation() * 90 : 0);
}
}
@Override
public void drawLayer(){
Shaders.blockbuild.color = Pal.accent;
Draw.draw(Layer.blockBuilding, () -> {
Shaders.blockbuild.color = Pal.accent;
Block target = cblock == null ? previous : cblock;
Block target = cblock == null ? previous : cblock;
if(target == null) return;
if(target != null){
for(TextureRegion region : target.getGeneratedIcons()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = progress;
for(TextureRegion region : target.getGeneratedIcons()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = progress;
Draw.rect(region, x, y, target.rotate ? tile.rotation() * 90 : 0);
Draw.flush();
}
Draw.rect(region, x, y, target.rotate ? tile.rotation() * 90 : 0);
Draw.flush();
}
}
});
}
public boolean construct(Unitc builder, @Nullable Tilec core, float amount, boolean configured){

View File

@@ -26,7 +26,7 @@ public class ItemSelection{
for(T item : items){
if(!data.isUnlocked(item) && state.isCampaign()) continue;
ImageButton button = cont.addImageButton(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get();
ImageButton button = cont.button(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get();
button.changed(() -> consumer.get(button.isChecked() ? item : null));
button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Cicon.small));
button.update(() -> button.setChecked(holder.get() == item));
@@ -40,7 +40,7 @@ public class ItemSelection{
if(i % 4 != 0){
int remaining = 4 - (i % 4);
for(int j = 0; j < remaining; j++){
cont.addImage(Styles.black6);
cont.image(Styles.black6);
}
}

View File

@@ -22,21 +22,11 @@ public class ShockMine extends Block{
destructible = true;
solid = false;
targetable = false;
layer = Layer.overlay;
rebuildable = false;
}
public class ShockMineEntity extends TileEntity{
@Override
public void drawLayer(){
super.draw();
Draw.color(team.color);
Draw.alpha(0.22f);
Fill.rect(x, y, 2f, 2f);
Draw.color();
}
@Override
public void drawTeam(){
//no
@@ -44,7 +34,11 @@ public class ShockMine extends Block{
@Override
public void draw(){
//nope
super.draw();
Draw.color(team.color);
Draw.alpha(0.22f);
Fill.rect(x, y, 2f, 2f);
Draw.color();
}
@Override

View File

@@ -50,8 +50,8 @@ public class LiquidTurret extends Turret{
public class LiquidTurretEntity extends TurretEntity{
@Override
public void drawLayer(){
super.drawLayer();
public void draw(){
super.draw();
if(Core.atlas.isFound(reg(liquidRegion))){
Draw.color(liquids.current().color);

View File

@@ -68,7 +68,6 @@ public abstract class Turret extends Block{
priority = TargetPriority.turret;
update = true;
solid = true;
layer = Layer.turret;
group = BlockGroup.turrets;
flags = EnumSet.of(BlockFlag.turret);
outlineIcon = true;
@@ -127,10 +126,9 @@ public abstract class Turret extends Block{
public void draw(){
Draw.rect(baseRegion, x, y);
Draw.color();
}
@Override
public void drawLayer(){
Draw.z(Layer.turret);
tr2.trns(rotation, -recoil);
drawer.get(this);

View File

@@ -10,8 +10,8 @@ import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.io.*;
import mindustry.content.*;
import mindustry.gen.*;
import mindustry.entities.units.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
@@ -36,7 +36,6 @@ public class Conveyor extends Block implements Autotiler{
super(name);
rotate = true;
update = true;
layer = Layer.overlay;
group = BlockGroup.transportation;
hasItems = true;
itemCapacity = 4;
@@ -129,6 +128,19 @@ public class Conveyor extends Block implements Autotiler{
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
Draw.rect(regions[Mathf.clamp(blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], x, y,
tilesize * blendsclx, tilesize * blendscly, rotation * 90);
//TODO is clustering necessary? does it create garbage?
Draw.z(Layer.blockOver);
for(int i = 0; i < len; i++){
Item item = ids[i];
tr1.trns(rotation * 90, tilesize, 0);
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
Draw.rect(item.icon(Cicon.medium),
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
(tile.y * tilesize + tr1.y * ys[i] + tr2.y), itemSize, itemSize);
}
}
@Override
@@ -152,21 +164,6 @@ public class Conveyor extends Block implements Autotiler{
}
}
@Override
public void drawLayer(){
byte rotation = tile.rotation();
for(int i = 0; i < len; i++){
Item item = ids[i];
tr1.trns(rotation * 90, tilesize, 0);
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
Draw.rect(item.icon(Cicon.medium),
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
(tile.y * tilesize + tr1.y * ys[i] + tr2.y), itemSize, itemSize);
}
}
@Override
public void unitOn(Unitc unit){
if(clogHeat > 0.5f){

View File

@@ -29,7 +29,6 @@ public class CraterConveyor extends Block implements Autotiler{
rotate = true;
update = true;
layer = Layer.overlay;
group = BlockGroup.transportation;
hasItems = true;
itemCapacity = 8;
@@ -87,13 +86,32 @@ public class CraterConveyor extends Block implements Autotiler{
@Override
public void draw(){
draw(blendbit1);
if(blendbit2 == 0) return;
draw(blendbit2);
}
Draw.rect(regions[Mathf.clamp(blendbit1, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);
if(blendbit2 != 0) Draw.rect(regions[Mathf.clamp(blendbit2, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);;
private void draw(int bit){
Draw.rect(regions[Mathf.clamp(bit, 0, regions.length - 1)], x, y, tilesize * blendsclx, tilesize * blendscly, rotation() * 90);
Draw.z(Layer.blockOver);
if(link == -1) return;
// offset
Tile from = world.tile(link);
Tmp.v1.set(from);
Tmp.v2.set(tile);
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear);
// fixme
float a = (from.rotation()%4) * 90;
float b = (tile.rotation()%4) * 90;
if((from.rotation()%4) == 3 && (tile.rotation()%4) == 0) a = -1 * 90;
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
// crater
Draw.rect(regions[7], Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interpolation.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
// item
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f);
Drawf.shadow(Tmp.v1.x, Tmp.v1.y, size * 1.2f);
Draw.rect(items.first().icon(Cicon.medium), Tmp.v1.x, Tmp.v1.y, size, size, 0);
}
@Override
@@ -157,31 +175,6 @@ public class CraterConveyor extends Block implements Autotiler{
}
}
@Override
public void drawLayer(){
if(link == -1) return;
// offset
Tile from = world.tile(link);
Tmp.v1.set(from);
Tmp.v2.set(tile);
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interpolation.linear);
// fixme
float a = (from.rotation()%4) * 90;
float b = (tile.rotation()%4) * 90;
if((from.rotation()%4) == 3 && (tile.rotation()%4) == 0) a = -1 * 90;
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
// crater
Draw.rect(regions[7], Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interpolation.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
// item
float size = itemSize * Mathf.lerp(Math.min((float)items.total() / itemCapacity, 1), 1f, 0.4f);
Drawf.shadow(Tmp.v1.x, Tmp.v1.y, size * 1.2f);
Draw.rect(items.first().icon(Cicon.medium), Tmp.v1.x, Tmp.v1.y, size, size, 0);
}
@Override
public int getMaximumAccepted(Item item){
return Mathf.round(super.getMaximumAccepted(item) * timeScale); // increased item capacity while boosted

View File

@@ -4,6 +4,7 @@ import arc.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.math.geom.*;
import mindustry.graphics.*;
import mindustry.world.*;
import static mindustry.Vars.*;
@@ -17,7 +18,11 @@ public class ExtendingItemBridge extends ItemBridge{
public class ExtendingItemBridgeEntity extends ItemBridgeEntity{
@Override
public void drawLayer(){
public void draw(){
super.draw();
Draw.z(Layer.power);
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;

View File

@@ -32,7 +32,6 @@ public class ItemBridge extends Block{
update = true;
solid = true;
hasPower = true;
layer = Layer.power;
expanded = true;
itemCapacity = 10;
configurable = true;
@@ -230,7 +229,11 @@ public class ItemBridge extends Block{
}
@Override
public void drawLayer(){
public void draw(){
super.draw();
Draw.z(Layer.power);
Tile other = world.tile(link);
if(!linkValid(tile, other)) return;

View File

@@ -37,10 +37,9 @@ public class MassDriver extends Block{
solid = true;
configurable = true;
hasItems = true;
layer = Layer.turret;
hasPower = true;
outlineIcon = true;
//point2 is relative
//point2 is relative
config(Point2.class, (tile, point) -> ((MassDriverEntity)tile).link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY()));
config(Integer.class, (tile, point) -> ((MassDriverEntity)tile).link = point);
}
@@ -187,10 +186,9 @@ public class MassDriver extends Block{
@Override
public void draw(){
Draw.rect(baseRegion, x, y);
}
@Override
public void drawLayer(){
Draw.z(Layer.turret);
Draw.rect(region,
x + Angles.trnsx(rotation + 180f, reload * knockback),
y + Angles.trnsy(rotation + 180f, reload * knockback), rotation - 90);

View File

@@ -17,15 +17,14 @@ import mindustry.world.blocks.payloads.*;
import static mindustry.Vars.*;
//TODO rename
public class MassConveyor extends Block{
public class PayloadConveyor extends Block{
public float moveTime = 70f;
public TextureRegion topRegion, edgeRegion;
public Interpolation interp = Interpolation.pow5;
public MassConveyor(String name){
public PayloadConveyor(String name){
super(name);
layer = Layer.overlay;
size = 3;
rotate = true;
update = true;
@@ -57,7 +56,7 @@ public class MassConveyor extends Block{
}
}
public class MassConveyorEntity extends TileEntity{
public class PayloadConveyorEntity extends TileEntity{
public @Nullable Payload item;
public float progress, itemRotation, animation;
public @Nullable Tilec next;
@@ -87,7 +86,7 @@ public class MassConveyor extends Block{
progress = Time.time() % moveTime;
//TODO DEBUG
if(Core.input.keyTap(KeyCode.G) && world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == this){
if(Core.input.keyTap(KeyCode.g) && world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y) == this){
item = new UnitPayload((Mathf.chance(0.5) ? UnitTypes.wraith : UnitTypes.dagger).create(Team.sharded));
itemRotation = rotation() * 90;
animation = 0f;
@@ -161,14 +160,8 @@ public class MassConveyor extends Block{
Draw.rect(edgeRegion, x, y, i * 90);
}
}
}
@Override
public void drawLayer(){
//fract:
//0: arriving
//0.5: middle
//1: leaving
Draw.z(Layer.blockOver);
if(animation > fract()){
animation = Mathf.lerp(animation, 0.8f, 0.15f);
@@ -177,7 +170,7 @@ public class MassConveyor extends Block{
animation = Math.max(animation, fract());
float fract = animation;
float rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
rot = Mathf.slerp(itemRotation, rotation() * 90, fract);
if(fract < 0.5f){
Tmp.v1.trns(itemRotation + 180, (0.5f - fract) * tilesize * size);

View File

@@ -11,15 +11,12 @@ public class TreeBlock extends Block{
public TreeBlock(String name){
super(name);
solid = true;
layer = Layer.power;
expanded = true;
}
@Override
public void drawBase(Tile tile){}
@Override
public void drawLayer(Tile tile){
public void drawBase(Tile tile){
Draw.z(Layer.power + 1);
Draw.rect(region, tile.worldx(), tile.worldy(), Mathf.randomSeed(tile.pos(), 0, 4) * 90);
}
}

View File

@@ -102,24 +102,26 @@ public class BlockForge extends Block{
}
if(recipe != null){
TextureRegion region = recipe.icon(Cicon.full);
Draw.draw(Layer.blockOver, () -> {
TextureRegion region = recipe.icon(Cicon.full);
Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f;
Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f;
Draw.shader(Shaders.build);
Draw.rect(region, x, y);
Draw.shader();
Draw.shader(Shaders.build);
Draw.rect(region, x, y);
Draw.shader();
Draw.color(Pal.accent);
Draw.alpha(heat);
Draw.color(Pal.accent);
Draw.alpha(heat);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Draw.reset();
Draw.reset();
});
}
}

View File

@@ -2,9 +2,8 @@ package mindustry.world.blocks.legacy;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.world.*;
public class LegacyCommandCenter extends Block{
public class LegacyCommandCenter extends LegacyBlock{
public LegacyCommandCenter(String name){
super(name);

View File

@@ -2,9 +2,8 @@ package mindustry.world.blocks.legacy;
import arc.util.io.*;
import mindustry.gen.*;
import mindustry.world.*;
public class LegacyUnitFactory extends Block{
public class LegacyUnitFactory extends LegacyBlock{
public LegacyUnitFactory(String name){
super(name);

View File

@@ -87,7 +87,7 @@ public class MessageBlock extends Block{
@Override
public void buildConfiguration(Table table){
table.addImageButton(Icon.pencil, () -> {
table.button(Icon.pencil, () -> {
if(mobile){
Core.input.getTextInput(new TextInput(){{
text = message;
@@ -112,7 +112,7 @@ public class MessageBlock extends Block{
return true;
});
a.setMaxLength(maxTextLength);
dialog.buttons.addButton("$ok", () -> {
dialog.buttons.button("$ok", () -> {
tile.configure(a.getText());
dialog.hide();
}).size(130f, 60f);

View File

@@ -49,7 +49,7 @@ public class LightBlock extends Block{
@Override
public void buildConfiguration(Table table){
table.addImageButton(Icon.pencil, () -> {
table.button(Icon.pencil, () -> {
ui.picker.show(Tmp.c1.set(color).a(0.5f), false, res -> {
color = res.rgba();
lastColor = color;

View File

@@ -33,7 +33,6 @@ public class PowerNode extends PowerBlock{
public PowerNode(String name){
super(name);
expanded = true;
layer = Layer.power;
configurable = true;
consumesPower = false;
outputsPower = false;
@@ -372,10 +371,12 @@ public class PowerNode extends PowerBlock{
}
@Override
public void drawLayer(){
public void draw(){
super.draw();
if(Core.settings.getInt("lasersopacity") == 0) return;
Tilec entity = tile.ent();
Draw.z(Layer.power);
for(int i = 0; i < power.links.size; i++){
Tilec link = world.ent(power.links.get(i));

View File

@@ -57,7 +57,6 @@ public class Drill extends Block{
super(name);
update = true;
solid = true;
layer = Layer.overlay;
group = BlockGroup.drills;
hasLiquids = true;
liquidCapacity = 5f;
@@ -139,7 +138,7 @@ public class Drill extends Block{
for(int i = 0; i < list.size; i++){
Block item = list.get(i);
l.addImage(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
l.add(item.localizedName).left().padLeft(1).padRight(4);
if(i % 5 == 4){
l.row();

View File

@@ -3,7 +3,6 @@ package mindustry.world.blocks.production;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.graphics.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
@@ -20,7 +19,6 @@ public class Pump extends LiquidBlock{
public Pump(String name){
super(name);
layer = Layer.overlay;
group = BlockGroup.liquids;
floating = true;
}

View File

@@ -31,7 +31,6 @@ public class CoreBlock extends StorageBlock{
flags = EnumSet.of(BlockFlag.core, BlockFlag.producer);
activeSound = Sounds.respawning;
activeSoundVolume = 1f;
layer = Layer.overlay;
}
@Remote(called = Loc.server)
@@ -194,9 +193,13 @@ public class CoreBlock extends StorageBlock{
}
@Override
public void drawLayer(){
public void draw(){
super.draw();
if(heat > 0.001f){
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
Draw.draw(Layer.blockOver, () -> {
Drawf.drawRespawn(this, heat, progress, time, unitType, lastRequested);
});
}
}

View File

@@ -84,7 +84,7 @@ public class CommandCenter extends Block{
Table buttons = new Table();
for(UnitCommand cmd : UnitCommand.all){
buttons.addImageButton(commandRegions[cmd.ordinal()], Styles.clearToggleTransi, () -> tile.configure(cmd.ordinal()))
buttons.button(commandRegions[cmd.ordinal()], Styles.clearToggleTransi, () -> tile.configure(cmd.ordinal()))
.size(44).group(group).update(b -> b.setChecked(command == cmd));
}
table.add(buttons);

View File

@@ -31,8 +31,6 @@ public class RepairPoint extends Block{
update = true;
solid = true;
flags = EnumSet.of(BlockFlag.repair);
layer = Layer.turret;
layer2 = Layer.power;
hasPower = true;
outlineIcon = true;
}
@@ -75,17 +73,12 @@ public class RepairPoint extends Block{
@Override
public void draw(){
Draw.rect(baseRegion, x, y);
}
@Override
public void drawLayer(){
Draw.z(Layer.turret);
Draw.rect(region, x, y, rotation - 90);
}
@Override
public void drawLayer2(){
if(target != null &&
Angles.angleDist(angleTo(target), rotation) < 30f){
if(target != null && Angles.angleDist(angleTo(target), rotation) < 30f){
Draw.z(Layer.power);
float ang = angleTo(target);
float len = 5f;

View File

@@ -28,7 +28,7 @@ public class AmmoListValue<T extends UnlockableContent> implements StatValue{
table.row();
for(T t : map.keys()){
BulletType type = map.get(t);
table.addImage(icon(t)).size(3 * 8).padRight(4).right().top();
table.image(icon(t)).size(3 * 8).padRight(4).right().top();
table.add(t.localizedName).padRight(10).left().top();
table.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();

View File

@@ -32,7 +32,7 @@ public class BoosterListValue implements StatValue{
for(Liquid liquid : content.liquids()){
if(!filter.get(liquid)) continue;
c.addImage(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top();
c.image(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top();
c.add(liquid.localizedName).padRight(10).left().top();
c.table(Tex.underline, bt -> {
bt.left().defaults().padRight(3).left();