Research block tweaks / Merged in #1927
@ -582,6 +582,7 @@ blocks.shots = Shots
|
||||
blocks.reload = Shots/Second
|
||||
blocks.ammo = Ammo
|
||||
|
||||
bar.corereq = Core Required
|
||||
bar.drilltierreq = Better Drill Required
|
||||
bar.drillspeed = Drill Speed: {0}/s
|
||||
bar.pumpspeed = Pump Speed: {0}/s
|
||||
|
@ -251,3 +251,4 @@
|
||||
63493=multiplicative-reconstructor|block-multiplicative-reconstructor-medium
|
||||
63492=exponential-reconstructor|block-exponential-reconstructor-medium
|
||||
63491=tetrative-reconstructor|block-tetrative-reconstructor-medium
|
||||
63490=resupply-point|block-resupply-point-medium
|
||||
|
Before Width: | Height: | Size: 773 B After Width: | Height: | Size: 780 B |
Before Width: | Height: | Size: 652 KiB After Width: | Height: | Size: 655 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 295 KiB |
Before Width: | Height: | Size: 926 KiB After Width: | Height: | Size: 934 KiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 290 KiB |
Before Width: | Height: | Size: 969 KiB After Width: | Height: | Size: 982 KiB |
@ -1845,7 +1845,7 @@ public class Blocks implements ContentList{
|
||||
}};
|
||||
|
||||
dataProcessor = new ResearchBlock("data-processor"){{
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 350, Items.silicon, 140, Items.lead, 200, Items.titanium, 150));
|
||||
requirements(Category.effect, BuildVisibility.campaignOnly, ItemStack.with(Items.copper, 200, Items.lead, 100));
|
||||
|
||||
size = 3;
|
||||
}};
|
||||
|
@ -382,37 +382,6 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showExceptions(String text, String... messages){
|
||||
loadfrag.hide();
|
||||
new Dialog(""){{
|
||||
|
||||
setFillParent(true);
|
||||
cont.margin(15);
|
||||
cont.add("$error.title").colspan(2);
|
||||
cont.row();
|
||||
cont.image().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
|
||||
cont.row();
|
||||
cont.add(text).colspan(2).wrap().growX().center().get().setAlignment(Align.center);
|
||||
cont.row();
|
||||
|
||||
//cont.pane(p -> {
|
||||
for(int i = 0; i < messages.length; i += 2){
|
||||
String btext = messages[i];
|
||||
String details = messages[i + 1];
|
||||
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(details).color(Color.lightGray).left()), true);
|
||||
|
||||
cont.add(btext).right();
|
||||
cont.button("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().left();
|
||||
cont.row();
|
||||
cont.add(col).colspan(2).pad(2);
|
||||
cont.row();
|
||||
}
|
||||
//}).colspan(2);
|
||||
|
||||
cont.button("$ok", this::hide).size(300, 50).fillX().colspan(2);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showText(String titleText, String text){
|
||||
showText(titleText, text, Align.center);
|
||||
}
|
||||
|
@ -235,6 +235,7 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
if(block != Blocks.air){
|
||||
block.drawBase(tile);
|
||||
Draw.reset();
|
||||
Draw.z(Layer.block);
|
||||
|
||||
if(entity != null){
|
||||
|
@ -54,12 +54,8 @@ public class Scripts implements Disposable{
|
||||
public String runConsole(String text){
|
||||
try{
|
||||
Object o = context.evaluateString(scope, text, "console.js", 1, null);
|
||||
if(o instanceof NativeJavaObject){
|
||||
o = ((NativeJavaObject)o).unwrap();
|
||||
}
|
||||
if(o instanceof Undefined){
|
||||
o = "undefined";
|
||||
}
|
||||
if(o instanceof NativeJavaObject) o = ((NativeJavaObject)o).unwrap();
|
||||
if(o instanceof Undefined) o = "undefined";
|
||||
return String.valueOf(o);
|
||||
}catch(Throwable t){
|
||||
return getError(t);
|
||||
|
@ -18,6 +18,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.MultiPacker.*;
|
||||
@ -276,7 +277,7 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Returns whether ot not this block can be place on the specified */
|
||||
public boolean canPlaceOn(Tile tile){
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class Build{
|
||||
}
|
||||
|
||||
if(type.isMultiblock()){
|
||||
if((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>ent().cblock == type)) && tile.block().size == type.size && type.canPlaceOn(tile) && tile.interactable(team)){
|
||||
if((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>ent().cblock == type)) && tile.block().size == type.size && type.canPlaceOn(tile, team) && tile.interactable(team)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class Build{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!type.canPlaceOn(tile)){
|
||||
if(!type.canPlaceOn(tile, team)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ public class Build{
|
||||
&& (!type.requiresWater || tile.floor().liquidDrop == Liquids.water)
|
||||
&& (((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>ent().cblock == type))
|
||||
&& !(type == tile.block() && rotation == tile.rotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile);
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile, team);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,27 @@
|
||||
package mindustry.world.blocks.campaign;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
public class ResearchBlock extends Block{
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ResearchBlock extends StorageBlock{
|
||||
public float researchSpeed = 1f;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
|
||||
public ResearchBlock(String name){
|
||||
super(name);
|
||||
@ -19,6 +31,7 @@ public class ResearchBlock extends Block{
|
||||
hasPower = true;
|
||||
hasItems = true;
|
||||
configurable = true;
|
||||
itemCapacity = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,7 +39,29 @@ public class ResearchBlock extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class ResearchBlockEntity extends TileEntity{
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
if(tile == null) return false;
|
||||
|
||||
//only allow placing next to cores
|
||||
for(Point2 edge : Edges.getEdges(size)){
|
||||
Tile other = tile.getNearby(edge);
|
||||
if(other != null && other.block() instanceof CoreBlock && other.team() == team){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
boolean hasCore = canPlaceOn(world.tile(x, y), player.team());
|
||||
if(!hasCore){
|
||||
drawPlaceText(Core.bundle.get("bar.corereq"), x, y, valid);
|
||||
}
|
||||
}
|
||||
|
||||
public class ResearchBlockEntity extends StorageBlockEntity{
|
||||
public @Nullable UnlockableContent researching;
|
||||
|
||||
@Override
|
||||
@ -39,6 +74,21 @@ public class ResearchBlock extends Block{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
Draw.mixcol(Color.white, Mathf.absin(10f, 0.2f));
|
||||
Draw.rect(topRegion, x, y);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Tilec source, Item item){
|
||||
//research blocks can only transfer items to the core
|
||||
return linkedCore != null && super.acceptItem(source, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configTapped(){
|
||||
//TODO select target
|
||||
|
@ -337,7 +337,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
for(int i = 0; i < amount; i++){
|
||||
int val = read.i();
|
||||
byte id = (byte)(val >> 24);
|
||||
short id = (short)(((byte)(val >> 24)) & 0xff);
|
||||
float x = (float)((byte)(val >> 16)) / 127f;
|
||||
float y = ((float)((byte)(val >> 8)) + 128f) / 255f;
|
||||
if(i < capacity){
|
||||
|
@ -112,7 +112,7 @@ public class ItemBridge extends Block{
|
||||
return false;
|
||||
}
|
||||
|
||||
return other.block() == tile.block() && (other.team() == tile.team() || tile.block() != this) && (!checkDouble || other.<ItemBridgeEntity>ent().link != tile.pos());
|
||||
return (other.block() == tile.block() || (!(tile.block() instanceof ItemBridge) && other.block() == this)) && (other.team() == tile.team() || tile.block() != this) && (!checkDouble || other.<ItemBridgeEntity>ent().link != tile.pos());
|
||||
}
|
||||
|
||||
public Tile findLink(int x, int y){
|
||||
@ -140,6 +140,51 @@ public class ItemBridge extends Block{
|
||||
lastPlaced = tile.pos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
if(linkValid(tile, world.tile(link))){
|
||||
drawInput(world.tile(link));
|
||||
}else{
|
||||
incoming.each(pos -> drawInput(world.tile(pos)));
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
private void drawInput(Tile other){
|
||||
if(!linkValid(tile, other, false)) return;
|
||||
boolean linked = other.pos() == link;
|
||||
if(!linked && !(other.<ItemBridgeEntity>ent().link == tile.pos())) return;
|
||||
|
||||
Tmp.v2.trns(tile.angleTo(other), 2f);
|
||||
float tx = tile.drawx(), ty = tile.drawy();
|
||||
float ox = other.drawx(), oy = other.drawy();
|
||||
float alpha = Math.abs((linked ? 100 : 0)-(Time.time() * 2f) % 100f) / 100f;
|
||||
float x = Mathf.lerp(ox, tx, alpha);
|
||||
float y = Mathf.lerp(oy, ty, alpha);
|
||||
|
||||
Tile otherLink = linked ? other : tile;
|
||||
int rel = (linked ? tile : other).absoluteRelativeTo(otherLink.x, otherLink.y);
|
||||
|
||||
//draw "background"
|
||||
Draw.color(Pal.gray);
|
||||
Lines.stroke(2.5f);
|
||||
Lines.square(ox, oy, 2f, 45f);
|
||||
Lines.stroke(2.5f);
|
||||
Lines.line(tx + Tmp.v2.x, ty + Tmp.v2.y, ox - Tmp.v2.x, oy - Tmp.v2.y);
|
||||
|
||||
//draw foreground colors
|
||||
Draw.color(linked ? Pal.place : Pal.accent);
|
||||
Lines.stroke(1f);
|
||||
Lines.line(tx + Tmp.v2.x, ty + Tmp.v2.y, ox - Tmp.v2.x, oy - Tmp.v2.y);
|
||||
|
||||
Lines.square(ox, oy, 2f, 45f);
|
||||
Draw.mixcol(Draw.getColor(), 1f);
|
||||
Draw.color();
|
||||
Draw.rect(arrowRegion, x, y, rel * 90);
|
||||
Draw.mixcol();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawConfigure(){
|
||||
Drawf.select(x, y, tile.block().size * tilesize / 2f + 2f, Pal.accent);
|
||||
|
@ -5,6 +5,7 @@ import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
@ -30,7 +31,7 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile){
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
//make sure there's heat at this location
|
||||
return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > 0.01f;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
@ -97,7 +98,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile){
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
if(isMultiblock()){
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
if(canMine(other)){
|
||||
|
@ -3,6 +3,7 @@ package mindustry.world.blocks.production;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
@ -60,7 +61,7 @@ public class Pump extends LiquidBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile){
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
if(isMultiblock()){
|
||||
Liquid last = null;
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
|
@ -8,6 +8,7 @@ import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@ -61,7 +62,7 @@ public class SolidPump extends Pump{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile){
|
||||
public boolean canPlaceOn(Tile tile, Team team){
|
||||
if(isMultiblock()){
|
||||
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
|
||||
if(canPump(other)){
|
||||
|