Fixed core errors
This commit is contained in:
@@ -301,6 +301,7 @@ public class TechTree implements ContentList{
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
node(dartPad, () -> {
|
||||
node(deltaPad, () -> {
|
||||
|
||||
@@ -316,7 +317,7 @@ public class TechTree implements ContentList{
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});*/
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,6 +100,7 @@ public class ContentLoader{
|
||||
|
||||
/** Calls Content#load() on everything. Use only after all modules have been created on the client.*/
|
||||
public void load(){
|
||||
Log.info("CALLING LOAD()");
|
||||
initialize(Content::load);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class EditorTile extends Tile{
|
||||
if(block == type) return;
|
||||
op(OpType.block, block.id);
|
||||
if(rotation != 0) op(OpType.rotation, rotation);
|
||||
if(team != 0) op(OpType.team, team);
|
||||
if(team() != Team.derelict) op(OpType.team, team().id);
|
||||
super.setBlock(type);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
public enum EditorTool{
|
||||
zoom,
|
||||
@@ -16,7 +15,7 @@ public enum EditorTool{
|
||||
public void touched(MapEditor editor, int x, int y){
|
||||
if(!Structs.inBounds(x, y, editor.width(), editor.height())) return;
|
||||
|
||||
Tile tile = editor.tile(x, y).link();
|
||||
Tile tile = editor.tile(x, y);
|
||||
editor.drawBlock = tile.block() == Blocks.air ? tile.overlay() == Blocks.air ? tile.floor() : tile.overlay() : tile.block();
|
||||
}
|
||||
},
|
||||
@@ -63,7 +62,7 @@ public enum EditorTool{
|
||||
editor.drawBlocks(x, y, true, tile -> true);
|
||||
}else if(mode == 2){
|
||||
//draw teams
|
||||
editor.drawCircle(x, y, tile -> tile.link().setTeam(editor.drawTeam));
|
||||
editor.drawCircle(x, y, tile -> tile.setTeam(editor.drawTeam));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,7 +107,7 @@ public enum EditorTool{
|
||||
//mode 0 or 1, fill everything with the floor/tile or replace it
|
||||
if(mode == 0 || mode == -1){
|
||||
//can't fill parts or multiblocks
|
||||
if(tile.block() instanceof BlockPart || tile.block().isMultiblock()){
|
||||
if(tile.block().isMultiblock()){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -137,10 +136,10 @@ public enum EditorTool{
|
||||
}else if(mode == 1){ //mode 1 is team fill
|
||||
|
||||
//only fill synthetic blocks, it's meaningless otherwise
|
||||
if(tile.link().synthetic()){
|
||||
if(tile.synthetic()){
|
||||
Team dest = tile.team();
|
||||
if(dest == editor.drawTeam) return;
|
||||
fill(editor, x, y, false, t -> t.getTeamID() == (int)dest.id && t.link().synthetic(), t -> t.setTeam(editor.drawTeam));
|
||||
fill(editor, x, y, false, t -> t.getTeamID() == (int)dest.id && t.synthetic(), t -> t.setTeam(editor.drawTeam));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,22 +70,7 @@ public class MapEditor{
|
||||
//adds missing blockparts
|
||||
//TODO remove, may not be necessary with blockpart refactor later
|
||||
public void checkLinkedTiles(){
|
||||
Tiles tiles = world.tiles;
|
||||
|
||||
//clear old parts
|
||||
for(Tile tile : tiles){
|
||||
if(tile.block() instanceof BlockPart){
|
||||
tile.setBlock(Blocks.air);
|
||||
}
|
||||
}
|
||||
|
||||
//re-add them
|
||||
for(Tile tile : tiles){
|
||||
if(tile.block().isMultiblock()){
|
||||
tile.setBlock(tile.block(), tile.team(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
//TODO actually remove
|
||||
}
|
||||
|
||||
public void load(Runnable r){
|
||||
@@ -152,6 +137,7 @@ public class MapEditor{
|
||||
int offsetx = -(drawBlock.size - 1) / 2;
|
||||
int offsety = -(drawBlock.size - 1) / 2;
|
||||
|
||||
//TODO this is completely unnecessary now!
|
||||
for(int dx = 0; dx < drawBlock.size; dx++){
|
||||
for(int dy = 0; dy < drawBlock.size; dy++){
|
||||
int worldx = dx + offsetx + x;
|
||||
@@ -163,7 +149,7 @@ public class MapEditor{
|
||||
Block block = tile.block();
|
||||
|
||||
//bail out if there's anything blocking the way
|
||||
if(block.isMultiblock() || block instanceof BlockPart){
|
||||
if(block.isMultiblock()){
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,9 +166,10 @@ public class MapEditor{
|
||||
if(!tester.get(tile)) return;
|
||||
|
||||
//remove linked tiles blocking the way
|
||||
if(!isFloor && (tile.isLinked() || tile.block().isMultiblock())){
|
||||
tile.link().remove();
|
||||
}
|
||||
//TODO also unnecessary
|
||||
//if(!isFloor && (tile.isLinked() || tile.block().isMultiblock())){
|
||||
// tile.link().remove();
|
||||
//}
|
||||
|
||||
if(isFloor){
|
||||
tile.setFloor(drawBlock.asFloor());
|
||||
|
||||
@@ -119,7 +119,7 @@ public class MapRenderer implements Disposable{
|
||||
int idxWall = (wx % chunkSize) + (wy % chunkSize) * chunkSize;
|
||||
int idxDecal = (wx % chunkSize) + (wy % chunkSize) * chunkSize + chunkSize * chunkSize;
|
||||
|
||||
if(wall != Blocks.air && (wall.synthetic() || wall instanceof BlockPart)){
|
||||
if(wall != Blocks.air && wall.synthetic()){
|
||||
region = !Core.atlas.isFound(wall.editorIcon()) ? Core.atlas.find("clear-editor") : wall.editorIcon();
|
||||
|
||||
if(wall.rotate){
|
||||
|
||||
@@ -26,7 +26,7 @@ class AllDefs{
|
||||
}
|
||||
|
||||
@GroupDef(Tilec.class)
|
||||
class gtile{
|
||||
class tile{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Damage{
|
||||
tr.trns(angle, length);
|
||||
Intc2 collider = (cx, cy) -> {
|
||||
Tilec tile = world.ent(cx, cy);
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.team() != team && tile.collide(hitter)){
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team() != team && tile.collide(hitter)){
|
||||
tile.collision(hitter);
|
||||
collidedBlocks.add(tile.pos());
|
||||
hitter.type().hit(hitter, tile.x(), tile.y());
|
||||
|
||||
@@ -73,12 +73,12 @@ public class Units{
|
||||
}
|
||||
|
||||
/** Returns the neareset ally tile in a range. */
|
||||
public static Tilec findAllyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||
public static Tilec findAllyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){
|
||||
return indexer.findTile(team, x, y, range, pred);
|
||||
}
|
||||
|
||||
/** Returns the neareset enemy tile in a range. */
|
||||
public static Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||
public static Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){
|
||||
if(team == Team.derelict) return null;
|
||||
|
||||
return indexer.findEnemyTile(team, x, y, range, pred);
|
||||
@@ -95,7 +95,7 @@ public class Units{
|
||||
}
|
||||
|
||||
/** Returns the closest target enemy. First, units are checked, then tile entities. */
|
||||
public static Teamc closestTarget(Team team, float x, float y, float range, Boolf<Unitc> unitPred, Boolf<Tile> tilePred){
|
||||
public static Teamc closestTarget(Team team, float x, float y, float range, Boolf<Unitc> unitPred, Boolf<Tilec> tilePred){
|
||||
if(team == Team.derelict) return null;
|
||||
|
||||
Unitc unit = closestEnemy(team, x, y, range, unitPred);
|
||||
|
||||
@@ -107,7 +107,7 @@ abstract class BuilderComp implements Unitc, DrawLayerFlyingc{
|
||||
}else{
|
||||
if(entity.construct(this, core, 1f / entity.buildCost * Time.delta() * buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
|
||||
if(current.hasConfig){
|
||||
Call.onTileConfig(null, tile, current.config);
|
||||
Call.onTileConfig(null, tile.entity, current.config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ abstract class FireComp implements Timedc, Posc, Firec{
|
||||
}
|
||||
|
||||
if(baseFlammability < 0 || block != tile.block()){
|
||||
baseFlammability = tile.getFlammability();
|
||||
baseFlammability = tile.entity == null ? 0 : tile.entity.getFlammability();
|
||||
block = tile.block();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
|
||||
Tilec core = closestCore();
|
||||
|
||||
if(core != null && mineTile != null && mineTile.drop() != null && !acceptsItem(mineTile.drop()) && dst(core) < mineTransferRange){
|
||||
int accepted = core.tile().block().acceptStack(core.tile(), item(), stack().amount, this);
|
||||
int accepted = core.acceptStack(item(), stack().amount, this);
|
||||
if(accepted > 0){
|
||||
Call.transferItemTo(item(), accepted,
|
||||
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
||||
@@ -60,7 +60,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
|
||||
if(mineTimer >= 50f + item.hardness*10f){
|
||||
mineTimer = 0;
|
||||
|
||||
if(dst(core) < mineTransferRange && core.tile().block().acceptStack(core.tile(), item, 1, this) == 1 && offloadImmediately()){
|
||||
if(dst(core) < mineTransferRange && core.acceptStack(item, 1, this) == 1 && offloadImmediately()){
|
||||
Call.transferItemTo(item, 1,
|
||||
mineTile.worldx() + Mathf.range(tilesize / 2f),
|
||||
mineTile.worldy() + Mathf.range(tilesize / 2f), core.tile());
|
||||
|
||||
@@ -78,7 +78,7 @@ abstract class PuddleComp implements Posc, DrawLayerFloorOverc, Puddlec{
|
||||
}
|
||||
});
|
||||
|
||||
if(liquid.temperature > 0.7f && (tile.link().entity != null) && Mathf.chance(0.3 * Time.delta())){
|
||||
if(liquid.temperature > 0.7f && (tile.entity != null) && Mathf.chance(0.3 * Time.delta())){
|
||||
Fires.create(tile);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,9 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
|
||||
|
||||
if(tile != null){
|
||||
//unit block update
|
||||
tile.unitOn(this);
|
||||
if(tile.entity != null){
|
||||
tile.entity.unitOn(this);
|
||||
}
|
||||
|
||||
//apply damage
|
||||
if(floor.damageTaken > 0f){
|
||||
|
||||
@@ -19,6 +19,7 @@ import mindustry.ctype.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.Schematic.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.input.Placement.*;
|
||||
import mindustry.io.*;
|
||||
@@ -318,15 +319,15 @@ public class Schematics implements Loadable{
|
||||
boolean found = false;
|
||||
for(int cx = x; cx <= x2; cx++){
|
||||
for(int cy = y; cy <= y2; cy++){
|
||||
Tile linked = world.ltile(cx, cy);
|
||||
Tilec linked = world.ent(cx, cy);
|
||||
|
||||
if(linked != null && linked.entity != null && linked.entity.block().isVisible() && !(linked.block() instanceof BuildBlock)){
|
||||
if(linked != null &&linked.block().isVisible() && !(linked.block() instanceof BuildBlock)){
|
||||
int top = linked.block().size/2;
|
||||
int bot = linked.block().size % 2 == 1 ? -linked.block().size/2 : -(linked.block().size - 1)/2;
|
||||
minx = Math.min(linked.x + bot, minx);
|
||||
miny = Math.min(linked.y + bot, miny);
|
||||
maxx = Math.max(linked.x + top, maxx);
|
||||
maxy = Math.max(linked.y + top, maxy);
|
||||
minx = Math.min(linked.tileX() + bot, minx);
|
||||
miny = Math.min(linked.tileY() + bot, miny);
|
||||
maxx = Math.max(linked.tileX() + top, maxx);
|
||||
maxy = Math.max(linked.tileY() + top, maxy);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -346,13 +347,13 @@ public class Schematics implements Loadable{
|
||||
IntSet counted = new IntSet();
|
||||
for(int cx = ox; cx <= ox2; cx++){
|
||||
for(int cy = oy; cy <= oy2; cy++){
|
||||
Tile tile = world.ltile(cx, cy);
|
||||
Tilec tile = world.ent(cx, cy);
|
||||
|
||||
if(tile != null && tile.entity != null && !counted.contains(tile.pos()) && !(tile.block() instanceof BuildBlock)
|
||||
&& (tile.entity.block().isVisible() || (tile.entity.block() instanceof CoreBlock && Core.settings.getBool("coreselect")))){
|
||||
Object config = tile.entity.config();
|
||||
if(tile != null && !counted.contains(tile.pos()) && !(tile.block() instanceof BuildBlock)
|
||||
&& (tile.block().isVisible() || (tile.block() instanceof CoreBlock && Core.settings.getBool("coreselect")))){
|
||||
Object config = tile.config();
|
||||
|
||||
tiles.add(new Stile(tile.block(), tile.x + offsetX, tile.y + offsetY, config, tile.rotation()));
|
||||
tiles.add(new Stile(tile.block(), tile.tileX() + offsetX, tile.tileY() + offsetY, config, (byte)tile.rotation()));
|
||||
counted.add(tile.pos());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class Tutorial{
|
||||
static void placeBlocks(){
|
||||
Tilec core = state.teams.playerCores().first();
|
||||
for(int i = 0; i < blocksToBreak; i++){
|
||||
world.ltile(core.tile().x + blockOffset, core.tile().y + i).remove();
|
||||
world.tile(core.tile().x + blockOffset, core.tile().y + i).remove();
|
||||
world.tile(core.tile().x + blockOffset, core.tile().y + i).setBlock(Blocks.scrapWall, state.rules.defaultTeam);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
@@ -31,6 +32,7 @@ public class BlockRenderer implements Disposable{
|
||||
private float brokenFade = 0f;
|
||||
private FrameBuffer shadows = new FrameBuffer(2, 2);
|
||||
private FrameBuffer fog = new FrameBuffer(2, 2);
|
||||
private Array<Tilec> outArray2 = new Array<>();
|
||||
private Array<Tile> outArray = new Array<>();
|
||||
private Array<Tile> shadowEvents = new Array<>();
|
||||
|
||||
@@ -220,9 +222,9 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
if(tile.entity != null && tile.entity.power() != null && tile.entity.power().links.size > 0){
|
||||
for(Tile other : block.getPowerConnections(tile, outArray)){
|
||||
for(Tilec other : tile.entity.getPowerConnections(outArray2)){
|
||||
if(other.block().layer == Layer.power){
|
||||
addRequest(other, Layer.power);
|
||||
addRequest(other.tile(), Layer.power);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,16 +259,16 @@ public class BlockRenderer implements Disposable{
|
||||
Block block = request.tile.block();
|
||||
|
||||
if(request.layer == Layer.block){
|
||||
block.draw(request.tile);
|
||||
block.drawBase(request.tile);
|
||||
if(request.tile.entity != null && request.tile.entity.damaged()){
|
||||
block.drawCracks(request.tile);
|
||||
request.tile.entity.drawCracks();
|
||||
}
|
||||
if(block.synthetic() && request.tile.team() != player.team()){
|
||||
block.drawTeam(request.tile);
|
||||
request.tile.entity.drawTeam();
|
||||
}
|
||||
|
||||
}else if(request.layer == Layer.lights){
|
||||
block.drawLight(request.tile);
|
||||
request.tile.entity.drawLight();
|
||||
}else if(request.layer == block.layer){
|
||||
block.drawLayer(request.tile);
|
||||
}else if(request.layer == block.layer2){
|
||||
|
||||
@@ -154,8 +154,7 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
private int colorFor(Tile tile){
|
||||
if(tile == null) return 0;
|
||||
tile = tile.link();
|
||||
int bc = tile.minimapColor();
|
||||
int bc = tile.block().minimapColor(tile);
|
||||
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));
|
||||
|
||||
|
||||
@@ -7,14 +7,10 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -83,7 +79,7 @@ public class OverlayRenderer{
|
||||
|
||||
//draw config selected block
|
||||
if(input.frag.config.isShown()){
|
||||
Tile tile = input.frag.config.getSelectedTile();
|
||||
Tilec tile = input.frag.config.getSelectedTile();
|
||||
tile.drawConfigure();
|
||||
}
|
||||
|
||||
@@ -121,15 +117,15 @@ public class OverlayRenderer{
|
||||
//draw selected block
|
||||
if(input.block == null && !Core.scene.hasMouse()){
|
||||
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
Tile tile = world.ltileWorld(vec.x, vec.y);
|
||||
Tilec tile = world.entWorld(vec.x, vec.y);
|
||||
|
||||
if(tile != null && tile.block() != Blocks.air && tile.team() == player.team()){
|
||||
if(tile != null && tile.team() == player.team()){
|
||||
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);
|
||||
control.input.drawArrow(tile.block(), tile.tileX(), tile.tileY(), tile.rotation(), true);
|
||||
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
||||
Fill.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize/2f);
|
||||
Fill.square(tile.x(), tile.y(), tile.block().size * tilesize/2f);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
@@ -144,12 +140,12 @@ public class OverlayRenderer{
|
||||
Lines.circle(v.x, v.y, 6 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Draw.reset();
|
||||
|
||||
Tile tile = world.ltileWorld(v.x, v.y);
|
||||
Tilec tile = world.entWorld(v.x, v.y);
|
||||
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.square(tile.x(), tile.y(), tile.block().size * tilesize / 2f + 3 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Lines.stroke(1f, Pal.place);
|
||||
Lines.square(tile.drawx(), tile.drawy(), tile.block().size * tilesize / 2f + 2 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Lines.square(tile.x(), tile.y(), tile.block().size * tilesize / 2f + 2 + Mathf.absin(Time.time(), 5f, 1f));
|
||||
Draw.reset();
|
||||
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
if(cursor != null){
|
||||
if(cursor.entity != null){
|
||||
cursorType = cursor.block().getCursor(cursor.entity);
|
||||
cursorType = cursor.entity.getCursor();
|
||||
}
|
||||
|
||||
if(isPlacing() || !selectRequests.isEmpty()){
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true, unreliable = true)
|
||||
public static void rotateBlock(Playerc player, Tilec tile, boolean direction){
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.rotate, tile, action -> action.rotation = Mathf.mod(tile.rotation() + Mathf.sign(direction), 4)))){
|
||||
!netServer.admins.allowAction(player, ActionType.rotate, tile.tile(), action -> action.rotation = Mathf.mod(tile.rotation() + Mathf.sign(direction), 4)))){
|
||||
throw new ValidateException(player, "Player cannot rotate a block.");
|
||||
}
|
||||
|
||||
@@ -123,17 +123,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
@Remote(targets = Loc.both, forward = true, called = Loc.server)
|
||||
public static void transferInventory(Playerc player, Tilec tile){
|
||||
if(player == null) return;
|
||||
if(player == null || tile == null) return;
|
||||
if(net.server() && (player.unit().stack().amount <= 0 || !Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.depositItem, tile, action -> {
|
||||
!netServer.admins.allowAction(player, ActionType.depositItem, tile.tile(), action -> {
|
||||
action.itemAmount = player.unit().stack().amount;
|
||||
action.item = player.unit().item();
|
||||
}))){
|
||||
throw new ValidateException(player, "Player cannot transfer an item.");
|
||||
}
|
||||
|
||||
if(tile.entity == null) return;
|
||||
|
||||
Item item = player.unit().item();
|
||||
int amount = player.unit().stack().amount;
|
||||
int accepted = tile.acceptStack(item, amount, player.unit());
|
||||
@@ -149,7 +147,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
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;
|
||||
if(tile.block() != block || !tile.isValid() || tile.items() == null) return;
|
||||
|
||||
tile.handleStack(item, accepted, player.unit());
|
||||
});
|
||||
@@ -160,7 +158,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public static void onTileTapped(Playerc player, Tilec tile){
|
||||
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.");
|
||||
!netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile.");
|
||||
tile.tapped(player);
|
||||
Core.app.post(() -> Events.fire(new TapEvent(tile, player)));
|
||||
}
|
||||
@@ -169,7 +167,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public static void onTileConfig(Playerc player, Tilec tile, @Nullable Object value){
|
||||
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.");
|
||||
!netServer.admins.allowAction(player, ActionType.configure, tile.tile(), action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile.");
|
||||
tile.configured(player, value);
|
||||
Core.app.post(() -> Events.fire(new TapConfigEvent(tile, player, value)));
|
||||
}
|
||||
@@ -569,14 +567,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
consumed = true;
|
||||
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)))){
|
||||
|| (frag.config.isShown() && frag.config.getSelectedTile().onConfigureTileTapped(tile)))){
|
||||
Sounds.click.at(tile);
|
||||
frag.config.showConfig(tile);
|
||||
}
|
||||
//otherwise...
|
||||
}else if(!frag.config.hasConfigMouse()){ //make sure a configuration fragment isn't on the cursor
|
||||
//then, if it's shown and the current block 'agrees' to hide, hide it.
|
||||
if(frag.config.isShown() && frag.config.getSelectedTile().block().onConfigureTileTapped(frag.config.getSelectedTile(), tile)){
|
||||
if(frag.config.isShown() && frag.config.getSelectedTile().onConfigureTileTapped(tile)){
|
||||
consumed = true;
|
||||
frag.config.hideConfig();
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(tile == null || tile.entity == null) return false;
|
||||
|
||||
tryDropItems(tile.entity.tile(), Core.input.mouseWorld(screenX, screenY).x, Core.input.mouseWorld(screenX, screenY).y);
|
||||
tryDropItems(tile.entity, Core.input.mouseWorld(screenX, screenY).x, Core.input.mouseWorld(screenX, screenY).y);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -563,7 +563,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}else if(mode == breaking && validBreak(linked.x,linked.y) && !hasRequest(linked)){
|
||||
//add to selection queue if it's a valid BREAK position
|
||||
selectRequests.add(new BuildRequest(linked.x, linked.y));
|
||||
}else if(!canTapPlayer(worldx, worldy) && !tileTapped(linked)){
|
||||
}else if(!canTapPlayer(worldx, worldy) && !tileTapped(linked.entity)){
|
||||
tryBeginMine(cursor);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,9 @@ public class Administration{
|
||||
}
|
||||
|
||||
/** @return whether this action is allowed by the action filters. */
|
||||
public boolean allowAction(Playerc player, ActionType type, Tilec tile, Cons<PlayerAction> setter){
|
||||
public boolean allowAction(Playerc player, ActionType type, Tile tile, Cons<PlayerAction> setter){
|
||||
PlayerAction act = Pools.obtain(PlayerAction.class, PlayerAction::new);
|
||||
setter.get(act.set(player, type, tile.tile()));
|
||||
setter.get(act.set(player, type, tile));
|
||||
for(ActionFilter filter : actionFilters){
|
||||
if(!filter.allow(act)){
|
||||
Pools.free(act);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
int fa = amount;
|
||||
|
||||
if(net.server() && (!Units.canInteract(player, tile) ||
|
||||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile, action -> {
|
||||
!netServer.admins.allowAction(player, ActionType.withdrawItem, tile.tile(), action -> {
|
||||
action.item = item;
|
||||
action.itemAmount = fa;
|
||||
}))) throw new ValidateException(player, "Player cannot request items.");
|
||||
|
||||
@@ -532,17 +532,21 @@ public class Block extends UnlockableContent{
|
||||
|
||||
//attempt to find the first declared class and use it as the entity type
|
||||
try{
|
||||
Class<?>[] classes = getClass().getDeclaredClasses();
|
||||
Class<?> current = getClass();
|
||||
|
||||
if(current.isAnonymousClass()){
|
||||
current = current.getSuperclass();
|
||||
}
|
||||
|
||||
while(entityType == null && Block.class.isAssignableFrom(current)){
|
||||
//first class that is subclass of Tilec
|
||||
Class<?> type = Structs.find(classes, Tilec.class::isAssignableFrom);
|
||||
Class<?> type = Structs.find(current.getDeclaredClasses(), Tilec.class::isAssignableFrom);
|
||||
if(type != null){
|
||||
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getConstructor();
|
||||
//these are inner classes, so they have an implicit parameter generated
|
||||
Constructor<? extends Tilec> cons = (Constructor<? extends Tilec>)type.getDeclaredConstructor(type.getDeclaringClass());
|
||||
entityType = () -> {
|
||||
try{
|
||||
return cons.newInstance();
|
||||
return cons.newInstance(this);
|
||||
}catch(Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class Build{
|
||||
}
|
||||
|
||||
if(type.isMultiblock()){
|
||||
if(type.canReplace(tile.block()) && tile.size == type.size && type.canPlaceOn() && tile.interactable(team)){
|
||||
if(type.canReplace(tile.block()) && tile.block().size == type.size && type.canPlaceOn(tile) && 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.isMultiblock() == type.isMultiblock() && type.canPlaceOn();
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.canBreak() && tile.breakable() && tile.interactable(team);
|
||||
return tile != null && tile.block().canBreak(tile) && tile.breakable() && tile.interactable(team);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.world;
|
||||
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
/**
|
||||
@@ -14,11 +13,6 @@ public class CachedTile extends Tile{
|
||||
super(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Team team(){
|
||||
return Team.get(getTeamID());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void preChanged(){
|
||||
//this basically overrides the old tile code and doesn't remove from proximity
|
||||
|
||||
@@ -59,6 +59,11 @@ public class MendProjector extends Block{
|
||||
stats.add(BlockStat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
||||
}
|
||||
|
||||
public class MendEntity extends TileEntity{
|
||||
float heat;
|
||||
float charge = Mathf.random(reload);
|
||||
@@ -86,11 +91,6 @@ public class MendProjector extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
float realRange = range + phaseHeat * phaseRangeBoost;
|
||||
|
||||
@@ -34,7 +34,8 @@ public class ConsumeItemFilter extends Consume{
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
content.items().each(i -> filter.get(i) && (!state.isCampaign() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items() != null && tile.entity.items().has(item))));
|
||||
content.items().each(i -> filter.get(i) && (!state.isCampaign() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1),
|
||||
() -> tile.items() != null && tile.items().has(item))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
|
||||
@Override
|
||||
public void build(Tilec tile, Table table){
|
||||
table.add(new ReqImage(liquid.icon(Cicon.medium), () -> valid(tile.entity))).size(8 * 4);
|
||||
table.add(new ReqImage(liquid.icon(Cicon.medium), () -> valid(tile))).size(8 * 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
public void build(Tilec tile, Table table){
|
||||
Array<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.get(l));
|
||||
MultiReqImage image = new MultiReqImage();
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.liquids() != null && tile.entity.liquids().get(liquid) >= use(tile.entity))));
|
||||
list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.liquids() != null && tile.liquids().get(liquid) >= use(tile))));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ConsumePower extends Consume{
|
||||
return (1f-entity.power().status)*capacity;
|
||||
}else{
|
||||
try{
|
||||
return usage * Mathf.num(entity.block().shouldConsume(entity.tile()));
|
||||
return usage * Mathf.num(entity.shouldConsume());
|
||||
}catch(Exception e){
|
||||
//HACK an error will only happen with a bar that is checking its requested power, and the entity is null/a different class
|
||||
return 0;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ConsumeModule extends BlockModule{
|
||||
boolean prevValid = valid();
|
||||
valid = true;
|
||||
optionalValid = true;
|
||||
boolean docons = entity.block().shouldConsume(entity.tile()) && entity.block().productionValid(entity.tile());
|
||||
boolean docons = entity.shouldConsume() && entity.productionValid();
|
||||
|
||||
for(Consume cons : entity.block().consumes.all()){
|
||||
if(cons.isOptional()) continue;
|
||||
@@ -50,7 +50,7 @@ public class ConsumeModule extends BlockModule{
|
||||
}
|
||||
|
||||
public boolean valid(){
|
||||
return valid && entity.block().shouldConsume(entity.tile());
|
||||
return valid && entity.shouldConsume();
|
||||
}
|
||||
|
||||
public boolean optionalValid(){
|
||||
|
||||
Reference in New Issue
Block a user