mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-08 01:43:59 +07:00
Down to less than 100 errors
This commit is contained in:
parent
73c0ebb75f
commit
4358658889
@ -76,10 +76,11 @@ public class Blocks implements ContentList{
|
||||
|
||||
//units
|
||||
commandCenter, draugFactory, spiritFactory, phantomFactory, wraithFactory, ghoulFactory, revenantFactory, daggerFactory, crawlerFactory, titanFactory,
|
||||
fortressFactory, repairPoint,
|
||||
fortressFactory, repairPoint
|
||||
|
||||
//upgrades
|
||||
dartPad, alphaPad, deltaPad, tauPad, omegaPad, javelinPad, tridentPad, glaivePad;
|
||||
//dartPad, alphaPad, deltaPad, tauPad, omegaPad, javelinPad, tridentPad, glaivePad;
|
||||
;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@ -1285,13 +1286,13 @@ public class Blocks implements ContentList{
|
||||
size = 5;
|
||||
}};
|
||||
|
||||
vault = new Vault("vault"){{
|
||||
vault = new StorageBlock("vault"){{
|
||||
requirements(Category.effect, ItemStack.with(Items.titanium, 250, Items.thorium, 125));
|
||||
size = 3;
|
||||
itemCapacity = 1000;
|
||||
}};
|
||||
|
||||
container = new Vault("container"){{
|
||||
container = new StorageBlock("container"){{
|
||||
requirements(Category.effect, ItemStack.with(Items.titanium, 100));
|
||||
size = 2;
|
||||
itemCapacity = 300;
|
||||
@ -1764,6 +1765,8 @@ public class Blocks implements ContentList{
|
||||
//endregion
|
||||
//region upgrades
|
||||
|
||||
//mechs are dead for now
|
||||
/*
|
||||
dartPad = new MechPad("dart-ship-pad"){{
|
||||
requirements(Category.upgrade, ItemStack.with(Items.lead, 100, Items.graphite, 50, Items.copper, 75));
|
||||
mech = UnitTypes.dart;
|
||||
@ -1818,7 +1821,7 @@ public class Blocks implements ContentList{
|
||||
mech = UnitTypes.glaive;
|
||||
size = 3;
|
||||
consumes.power(1.2f);
|
||||
}};
|
||||
}};*/
|
||||
|
||||
//endregion
|
||||
//region sandbox
|
||||
|
@ -59,7 +59,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
||||
}
|
||||
|
||||
if(baseFlammability < 0 || block != tile.block()){
|
||||
baseFlammability = tile.block().getFlammability(tile);
|
||||
baseFlammability = tile.getFlammability();
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
|
||||
if(tile != null){
|
||||
//unit block update
|
||||
tile.block().unitOn(tile, this);
|
||||
tile.unitOn(this);
|
||||
|
||||
//apply damage
|
||||
if(floor.damageTaken > 0f){
|
||||
|
@ -207,9 +207,9 @@ public class FloorRenderer implements Disposable{
|
||||
}
|
||||
|
||||
if(tile.block().cacheLayer == layer && layer == CacheLayer.walls && !(tile.isDarkened() && tile.rotation() >= 5)){
|
||||
tile.block().draw(tile);
|
||||
tile.block().drawBase(tile);
|
||||
}else if(floor.cacheLayer == layer && (world.isAccessible(tile.x, tile.y) || tile.block().cacheLayer != CacheLayer.walls || !tile.block().fillsTile)){
|
||||
floor.draw(tile);
|
||||
floor.drawBase(tile);
|
||||
}else if(floor.cacheLayer.ordinal() < layer.ordinal() && layer != CacheLayer.walls){
|
||||
floor.drawNonLayer(tile);
|
||||
}
|
||||
|
@ -186,18 +186,18 @@ public class MenuRenderer implements Disposable{
|
||||
batch.beginCache();
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
tile.floor().draw(tile);
|
||||
tile.floor().drawBase(tile);
|
||||
}
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
tile.overlay().draw(tile);
|
||||
tile.overlay().drawBase(tile);
|
||||
}
|
||||
|
||||
cacheFloor = batch.endCache();
|
||||
batch.beginCache();
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
tile.block().draw(tile);
|
||||
tile.block().drawBase(tile);
|
||||
}
|
||||
|
||||
cacheWall = batch.endCache();
|
||||
|
@ -155,7 +155,7 @@ public class MinimapRenderer implements Disposable{
|
||||
private int colorFor(Tile tile){
|
||||
if(tile == null) return 0;
|
||||
tile = tile.link();
|
||||
int bc = tile.block().minimapColor(tile);
|
||||
int bc = tile.minimapColor();
|
||||
Color color = Tmp.c1.set(bc == 0 ? MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.team()) : bc);
|
||||
color.mul(1f - Mathf.clamp(world.getDarkness(tile.x, tile.y) / 4f));
|
||||
|
||||
|
@ -50,15 +50,17 @@ public class OverlayRenderer{
|
||||
}
|
||||
|
||||
Groups.unit.each(unit -> {
|
||||
if(unit != player && unit.team() != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x(), unit.y())){
|
||||
Tmp.v1.set(unit.x(), unit.y()).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
if(!unit.isLocal() && unit.team() != player.team() && !rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f).setCenter(Core.camera.position.x, Core.camera.position.y).contains(unit.x(), unit.y())){
|
||||
Tmp.v1.set(unit.x(), unit.y()).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||
|
||||
Lines.stroke(1f, unit.team().color);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
Lines.stroke(1f, unit.team().color);
|
||||
Lines.lineAngle(Core.camera.position.x + Tmp.v1.x, Core.camera.position.y + Tmp.v1.y, Tmp.v1.angle(), 3f);
|
||||
Draw.reset();
|
||||
}
|
||||
});
|
||||
|
||||
//mech pads are gone
|
||||
/*
|
||||
if(ui.hudfrag.blockfrag.currentCategory == Category.upgrade){
|
||||
for(Tile mechpad : indexer.getAllied(player.team(), BlockFlag.mechPad)){
|
||||
if(!(mechpad.block() instanceof MechPad)) continue;
|
||||
@ -72,7 +74,7 @@ public class OverlayRenderer{
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(player.dead()) return; //dead players don't draw
|
||||
@ -82,7 +84,7 @@ public class OverlayRenderer{
|
||||
//draw config selected block
|
||||
if(input.frag.config.isShown()){
|
||||
Tile tile = input.frag.config.getSelectedTile();
|
||||
tile.block().drawConfigure(tile);
|
||||
tile.drawConfigure();
|
||||
}
|
||||
|
||||
input.drawTop();
|
||||
@ -122,7 +124,7 @@ public class OverlayRenderer{
|
||||
Tile tile = world.ltileWorld(vec.x, vec.y);
|
||||
|
||||
if(tile != null && tile.block() != Blocks.air && tile.team() == player.team()){
|
||||
tile.block().drawSelect(tile);
|
||||
tile.drawSelect();
|
||||
|
||||
if(Core.input.keyDown(Binding.rotateplaced) && tile.block().rotate && tile.interactable(player.team())){
|
||||
control.input.drawArrow(tile.block(), tile.x, tile.y, tile.rotation(), true);
|
||||
@ -143,7 +145,7 @@ public class OverlayRenderer{
|
||||
Draw.reset();
|
||||
|
||||
Tile tile = world.ltileWorld(v.x, v.y);
|
||||
if(tile != null && tile.interactable(player.team()) && tile.block().acceptStack(tile, player.unit().item(), player.unit().stack().amount, player.unit()) > 0){
|
||||
if(tile != null && tile.interactable(player.team()) && tile.acceptStack(player.unit().item(), player.unit().stack().amount, player.unit()) > 0){
|
||||
Lines.stroke(3f, Pal.gray);
|
||||
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Lines.stroke(1f, Pal.place);
|
||||
|
@ -136,7 +136,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
Item item = player.unit().item();
|
||||
int amount = player.unit().stack().amount;
|
||||
int accepted = tile.block().acceptStack(tile, item, amount, player.unit());
|
||||
int accepted = tile.acceptStack(item, amount, player.unit());
|
||||
player.unit().stack().amount -= accepted;
|
||||
|
||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||
@ -145,13 +145,13 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
|
||||
|
||||
for(int i = 0; i < sent; i++){
|
||||
tile.block().getStackOffset(tile, item, stackTrns);
|
||||
tile.getStackOffset(item, stackTrns);
|
||||
|
||||
createItemTransfer(item, player.x() + Angles.trnsx(player.unit().rotation() + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation() + 180f, backTrns),
|
||||
new Vec2(tile.x() + stackTrns.x, tile.y() + stackTrns.y), () -> {
|
||||
if(tile.block() != block || tile.entity == null || tile.items() == null) return;
|
||||
|
||||
tile.block().handleStack(tile, item, accepted, player.unit());
|
||||
tile.handleStack(item, accepted, player.unit());
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -161,7 +161,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(tile == null || player == null) return;
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.tapTile, tile, action -> {}))) throw new ValidateException(player, "Player cannot tap a tile.");
|
||||
tile.block().tapped(tile, player);
|
||||
tile.tapped(player);
|
||||
Core.app.post(() -> Events.fire(new TapEvent(tile, player)));
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(tile == null) return;
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.configure, tile, action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile.");
|
||||
tile.block().configured(tile, player, value);
|
||||
tile.configured(player, value);
|
||||
Core.app.post(() -> Events.fire(new TapConfigEvent(tile, player, value)));
|
||||
}
|
||||
|
||||
@ -567,7 +567,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
//check if tapped block is configurable
|
||||
if(tile.block().configurable && tile.interactable(player.team())){
|
||||
consumed = true;
|
||||
if(((!frag.config.isShown() && tile.block().shouldShowConfigure(tile, player)) //if the config fragment is hidden, show
|
||||
if(((!frag.config.isShown() && tile.shouldShowConfigure(player)) //if the config fragment is hidden, show
|
||||
//alternatively, the current selected block can 'agree' to switch config tiles
|
||||
|| (frag.config.isShown() && frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile)))){
|
||||
Sounds.click.at(tile);
|
||||
@ -750,7 +750,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
ItemStack stack = player.unit().stack();
|
||||
|
||||
if(tile.block().acceptStack(tile, stack.item, stack.amount, player.unit()) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.unit().stack().amount > 0 && tile.interactable(player.team())){
|
||||
if(tile.acceptStack(stack.item, stack.amount, player.unit()) > 0 && tile.interactable(player.team()) && tile.block().hasItems && player.unit().stack().amount > 0 && tile.interactable(player.team())){
|
||||
Call.transferInventory(player, tile);
|
||||
}else{
|
||||
Call.dropItem(player.angleTo(x, y));
|
||||
@ -1003,7 +1003,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(dst(moveTarget) <= 2f * Time.delta()){
|
||||
if(tapping && !dead()){
|
||||
Tile tile = ((Tilec)moveTarget).tile;
|
||||
tile.block().tapped(tile, this);
|
||||
tile.tapped(this);
|
||||
}
|
||||
|
||||
moveTarget = null;
|
||||
|
@ -48,23 +48,23 @@ public class BlockConfigFragment extends Fragment{
|
||||
|
||||
table.visible(true);
|
||||
table.clear();
|
||||
tile.block().buildConfiguration(tile, table);
|
||||
tile.buildConfiguration(table);
|
||||
table.pack();
|
||||
table.setTransform(true);
|
||||
table.actions(Actions.scaleTo(0f, 1f), Actions.visible(true),
|
||||
Actions.scaleTo(1f, 1f, 0.07f, Interpolation.pow3Out));
|
||||
|
||||
table.update(() -> {
|
||||
if(configTile != null && configTile.block().shouldHideConfigure(configTile, player)){
|
||||
if(configTile != null && configTile.shouldHideConfigure(player)){
|
||||
hideConfig();
|
||||
return;
|
||||
}
|
||||
|
||||
table.setOrigin(Align.center);
|
||||
if(configTile == null || configTile.block() == Blocks.air || configTile.block() != configBlock){
|
||||
if(configTile == null || configTile.block() == Blocks.air || !configTile.isValid()){
|
||||
hideConfig();
|
||||
}else{
|
||||
configTile.block().updateTableAlign(tile, table);
|
||||
configTile.updateTableAlign(table);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ public class BlockInventoryFragment extends Fragment{
|
||||
int fa = amount;
|
||||
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile.tile(), action -> {
|
||||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile, action -> {
|
||||
action.item = item;
|
||||
action.itemAmount = fa;
|
||||
}))) throw new ValidateException(player, "Player cannot request items.");
|
||||
|
||||
int removed = tile.block().removeStack(tile, item, amount);
|
||||
int removed = tile.removeStack(item, amount);
|
||||
|
||||
player.unit().addItem(item, removed);
|
||||
Events.fire(new WithdrawEvent(tile, player, item, amount));
|
||||
@ -96,7 +96,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
table.touchable(Touchable.enabled);
|
||||
table.update(() -> {
|
||||
|
||||
if(state.is(State.menu) || tile == null || tile.entity == null || !tile.block().isAccessible() || tile.items().total() == 0){
|
||||
if(state.is(State.menu) || tile == null || !tile.isValid() || !tile.block().isAccessible() || tile.items().total() == 0){
|
||||
hide();
|
||||
}else{
|
||||
if(holding && lastItem != null){
|
||||
@ -144,7 +144,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
l.setEnabled(canPick);
|
||||
|
||||
Element image = itemImage(item.icon(Cicon.xlarge), () -> {
|
||||
if(tile == null || tile.entity == null){
|
||||
if(tile == null || !tile.isValid()){
|
||||
return "";
|
||||
}
|
||||
return round(tile.items().get(item));
|
||||
@ -154,7 +154,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
image.addListener(new InputListener(){
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||
if(!canPick.get() || tile == null || tile.entity == null || tile.items() == null || !tile.items().has(item)) return false;
|
||||
if(!canPick.get() || tile == null || !tile.isValid() || tile.items() == null || !tile.items().has(item)) return false;
|
||||
int amount = Math.min(1, player.unit().maxAccepted(item));
|
||||
if(amount > 0){
|
||||
Call.requestItem(player, tile, item, amount);
|
||||
|
@ -90,7 +90,7 @@ public class PlacementFragment extends Fragment{
|
||||
scrollPositions.put(currentCategory, blockPane.getScrollY());
|
||||
|
||||
if(Core.input.keyDown(Binding.pick) && player.isBuilder()){ //mouse eyedropper select
|
||||
Tile tile = world.ltileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Tilec tile = world.entWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
Block tryRecipe = tile == null ? null : tile.block();
|
||||
|
||||
for(BuildRequest req : player.builder().requests()){
|
||||
@ -341,7 +341,9 @@ public class PlacementFragment extends Fragment{
|
||||
topTable.row();
|
||||
topTable.table(t -> {
|
||||
t.left().defaults().left();
|
||||
lastDisplay.display(hoverTile, t);
|
||||
if(hoverTile.entity != null){
|
||||
hoverTile.entity.display(t);
|
||||
}
|
||||
}).left().growX();
|
||||
}
|
||||
}
|
||||
@ -451,12 +453,7 @@ public class PlacementFragment extends Fragment{
|
||||
|
||||
//setup hovering tile
|
||||
if(!Core.scene.hasMouse() && topTable.hit(v.x, v.y, false) == null){
|
||||
Tile tile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
if(tile != null){
|
||||
hoverTile = tile.link();
|
||||
}else{
|
||||
hoverTile = null;
|
||||
}
|
||||
hoverTile = world.tileWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||
}else{
|
||||
hoverTile = null;
|
||||
}
|
||||
|
@ -252,6 +252,10 @@ public class Block extends UnlockableContent{
|
||||
return sum;
|
||||
}
|
||||
|
||||
public TextureRegion getDisplayIcon(Tile tile){
|
||||
return tile.entity == null ? icon(Cicon.medium) : tile.entity.getDisplayIcon();
|
||||
}
|
||||
|
||||
public String getDisplayName(Tile tile){
|
||||
return tile.entity == null ? localizedName : tile.entity.getDisplayName();
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class Build{
|
||||
}
|
||||
|
||||
if(type.isMultiblock()){
|
||||
if(type.canReplace(tile.block()) && tile.block().size == type.size && type.canPlaceOn(tile) && tile.interactable(team)){
|
||||
if(type.canReplace(tile.block()) && tile.size == type.size && type.canPlaceOn() && tile.interactable(team)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ public class Build{
|
||||
&& tile.floor().placeableOn
|
||||
&& ((type.canReplace(tile.block())
|
||||
&& !(type == tile.block() && rotation == tile.rotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile);
|
||||
&& tile.isMultiblock() == type.isMultiblock() && type.canPlaceOn();
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,6 +150,6 @@ public class Build{
|
||||
/** Returns whether the tile at this position is breakable by this team */
|
||||
public static boolean validBreak(Team team, int x, int y){
|
||||
Tile tile = world.tile(x, y);
|
||||
return tile != null && tile.block().canBreak(tile) && tile.breakable() && tile.interactable(team);
|
||||
return tile != null && tile.canBreak() && tile.breakable() && tile.interactable(team);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class CachedTile extends Tile{
|
||||
@Override
|
||||
protected void preChanged(){
|
||||
//this basically overrides the old tile code and doesn't remove from proximity
|
||||
team = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,8 @@ public class ConsumeItems extends Consume{
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
for(ItemStack stack : items){
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
||||
table.add(new ReqImage(new ItemImage(stack.item.icon(Cicon.medium), stack.amount),
|
||||
() -> tile.items() != null && tile.items().has(stack.item, stack.amount))).size(8 * 4).padRight(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,16 +439,16 @@ public class ApplicationTests{
|
||||
|
||||
assertNotNull(tile.entity, "Tile should have an entity, but does not: " + tile);
|
||||
|
||||
int deposited = tile.block().acceptStack(tile, item, capacity - 1, unit);
|
||||
int deposited = tile.acceptStack(item, capacity - 1, unit);
|
||||
assertEquals(capacity - 1, deposited);
|
||||
|
||||
tile.block().handleStack(tile, item, capacity - 1, unit);
|
||||
tile.handleStack(item, capacity - 1, unit);
|
||||
assertEquals(tile.entity.items().get(item), capacity - 1);
|
||||
|
||||
int overflow = tile.block().acceptStack(tile, item, 10, unit);
|
||||
int overflow = tile.acceptStack(item, 10, unit);
|
||||
assertEquals(1, overflow);
|
||||
|
||||
tile.block().handleStack(tile, item, 1, unit);
|
||||
tile.handleStack(item, 1, unit);
|
||||
assertEquals(capacity, tile.entity.items().get(item));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user