Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2018-11-15 12:40:29 -05:00
20 changed files with 1070 additions and 353 deletions

View File

@@ -131,7 +131,7 @@ public class Recipes implements ContentList{
new Recipe(power, PowerBlocks.thoriumReactor, new ItemStack(Items.lead, 600), new ItemStack(Items.silicon, 400), new ItemStack(Items.densealloy, 300), new ItemStack(Items.thorium, 300));
new Recipe(power, PowerBlocks.rtgGenerator, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 150), new ItemStack(Items.phasefabric, 50), new ItemStack(Items.plastanium, 150), new ItemStack(Items.thorium, 100));
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 40), new ItemStack(Items.silicon, 50));
new Recipe(distribution, StorageBlocks.unloader, new ItemStack(Items.densealloy, 50), new ItemStack(Items.silicon, 60));
new Recipe(distribution, StorageBlocks.container, new ItemStack(Items.densealloy, 200));
new Recipe(distribution, StorageBlocks.vault, new ItemStack(Items.densealloy, 500), new ItemStack(Items.thorium, 250));
//core disabled due to being broken

View File

@@ -17,16 +17,16 @@ public class StorageBlocks extends BlockList implements ContentList{
vault = new Vault("vault"){{
size = 3;
itemCapacity = 1000;
itemCapacity = 900;
}};
container = new Vault("container"){{
size = 2;
itemCapacity = 250;
itemCapacity = 200;
}};
unloader = new SortedUnloader("unloader"){{
speed = 5;
speed = 12f;
}};
}
}

View File

@@ -4,9 +4,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Threads.ThreadInfoProvider;
public class ThreadHandler implements ThreadInfoProvider{
public class ThreadHandler{
private long lastFrameTime;
public ThreadHandler(){
@@ -52,14 +51,4 @@ public class ThreadHandler implements ThreadInfoProvider{
}
}
@Override
public boolean isOnLogicThread() {
return true;
}
@Override
public boolean isOnGraphicsThread() {
return true;
}
}

View File

@@ -28,7 +28,6 @@ import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
import io.anuke.ucore.scene.ui.TooltipManager;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Threads;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.ucore.scene.actions.Actions.*;
@@ -240,8 +239,6 @@ public class UI extends SceneModule{
}
public void showInfoFade(String info){
Threads.assertGraphics();
Table table = new Table();
table.setFillParent(true);
table.actions(Actions.fadeOut(7f, Interpolation.fade), Actions.removeActor());
@@ -250,9 +247,7 @@ public class UI extends SceneModule{
}
public void showInfo(String info){
Threads.assertGraphics();
new Dialog("$text.info.title", "dialog"){{
new Dialog("", "dialog"){{
getCell(content()).growX();
content().margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
buttons().addButton("$text.ok", this::hide).size(90, 50).pad(4);
@@ -260,9 +255,7 @@ public class UI extends SceneModule{
}
public void showInfo(String info, Runnable clicked){
Threads.assertGraphics();
new Dialog("$text.info.title", "dialog"){{
new Dialog("", "dialog"){{
getCell(content()).growX();
content().margin(15).add(info).width(400f).wrap().get().setAlignment(Align.center, Align.center);
buttons().addButton("$text.ok", () -> {

View File

@@ -13,7 +13,6 @@ import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.function.Predicate;
import io.anuke.ucore.util.EnumSet;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Threads;
import static io.anuke.mindustry.Vars.*;
@@ -63,45 +62,20 @@ public class Units{
/**Can be called from any thread.*/
public static boolean anyEntities(Rectangle rect){
if(Threads.isLogic()){
boolResult = false;
boolResult = false;
Units.getNearby(rect, unit -> {
if(boolResult) return;
if(!unit.isFlying()){
unit.getHitbox(hitrect);
Units.getNearby(rect, unit -> {
if(boolResult) return;
if(!unit.isFlying()){
unit.getHitbox(hitrect);
if(hitrect.overlaps(rect)){
boolResult = true;
}
if(hitrect.overlaps(rect)){
boolResult = true;
}
});
return boolResult;
}else{
boolResultGraphics = false;
for(EntityGroup<? extends BaseUnit> g : unitGroups){
g.forEach(u -> {
if(u.isFlying()) return;
u.getHitbox(rectGraphics);
if(rectGraphics.overlaps(rect)){
boolResultGraphics = true;
}
});
if(boolResultGraphics) return true;
}
});
playerGroup.forEach(u -> {
if(u.isFlying()) return;
u.getHitbox(rectGraphics);
if(rectGraphics.overlaps(rect)){
boolResultGraphics = true;
}
});
return boolResultGraphics;
}
return boolResult;
}
/**Returns whether there are any entities on this tile, with the hitbox expanded.*/

View File

@@ -300,10 +300,6 @@ public interface BuilderTrait extends Entity{
float x1 = tmptr[0].x, y1 = tmptr[0].y,
x3 = tmptr[1].x, y3 = tmptr[1].y;
Translator close = Geometry.findClosest(unit.x, unit.y, tmptr);
float x2 = close.x, y2 = close.y;
Draw.alpha(0.3f + Mathf.absin(Timers.time(), 0.9f, 0.2f));
Draw.alpha(1f);

View File

@@ -320,10 +320,8 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
if(target != null) behavior();
if(!isWave && !isFlying()){
x = Mathf.clamp(x, tilesize/2f, world.width() * tilesize - tilesize/2f);
y = Mathf.clamp(y, tilesize/2f, world.height() * tilesize - tilesize/2f);
}
x = Mathf.clamp(x, tilesize, world.width() * tilesize - tilesize);
y = Mathf.clamp(y, tilesize, world.height() * tilesize - tilesize);
}
@Override

View File

@@ -20,7 +20,6 @@ import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Pooling;
import io.anuke.ucore.util.Threads;
import java.io.IOException;
@@ -51,7 +50,6 @@ public class Net{
public static void showError(Throwable e){
if(!headless){
Threads.assertGraphics();
Throwable t = e;
while(t.getCause() != null){

View File

@@ -97,7 +97,7 @@ public class PlayerListFragment extends Fragment{
button.labelWrap("[#" + player.color.toString().toUpperCase() + "]" + player.name).width(170f).pad(10);
button.add().grow();
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5);
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5).get().updateVisibility();
if((Net.server() || players[0].isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())){
button.add().growY();
@@ -124,10 +124,11 @@ public class PlayerListFragment extends Fragment{
}else{
ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> netServer.admins.adminPlayer(id, player.usid));
}
}).update(b -> {
b.setChecked(player.isAdmin);
b.setDisabled(Net.client());
}).get().setTouchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled);
})
.update(b -> b.setChecked(player.isAdmin))
.disabled(b -> Net.client())
.touchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled)
.checked(player.isAdmin);
t.addImageButton("icon-zoom-small", 14 * 2, () -> ui.showError("Currently unimplemented.")/*Call.onAdminRequest(player, AdminAction.trace)*/);

View File

@@ -90,7 +90,7 @@ public abstract class BaseBlock extends MappableContent{
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return hasLiquids && tile.entity.liquids.get(liquid) + amount < liquidCapacity &&
(!singleLiquid || (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.01f)) &&
(!singleLiquid || (tile.entity.liquids.current() == liquid || tile.entity.liquids.get(tile.entity.liquids.current()) < 0.2f)) &&
(!consumes.has(ConsumeLiquid.class) || consumes.liquid() == liquid);
}

View File

@@ -17,7 +17,6 @@ import static io.anuke.mindustry.Vars.*;
public class Build{
private static final Rectangle rect = new Rectangle();
private static final Rectangle hitrect = new Rectangle();
/**Returns block type that was broken, or null if unsuccesful.*/
public static void beginBreak(Team team, int x, int y){

View File

@@ -94,7 +94,7 @@ public class PowerGraph{
public void clear(){
for(Tile other : all){
other.entity.power.graph = null;
if(other.entity != null && other.entity.power != null) other.entity.power.graph = null;
}
all.clear();
producers.clear();

View File

@@ -25,7 +25,6 @@ import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Threads;
import static io.anuke.mindustry.Vars.content;
public class Drill extends Block{
@@ -221,7 +220,7 @@ public class Drill extends Block{
@Override
public boolean canPlaceOn(Tile tile){
if(isMultiblock()){
for(Tile other : tile.getLinkedTilesAs(this, Threads.isLogic() ? tempTiles : drawTiles)){
for(Tile other : tile.getLinkedTilesAs(this, tempTiles)){
if(isValid(other)){
return true;
}

View File

@@ -11,6 +11,7 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.SelectionTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Log;
import java.io.DataInput;
import java.io.DataOutput;
@@ -18,6 +19,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
public class SortedUnloader extends Unloader implements SelectionTrait{
protected float speed = 1f;
public SortedUnloader(String name){
super(name);
@@ -35,13 +37,14 @@ public class SortedUnloader extends Unloader implements SelectionTrait{
public void update(Tile tile){
SortedUnloaderEntity entity = tile.entity();
if(entity.items.total() == 0 && entity.timer.get(timerUnload, speed)){
tile.allNearby(other -> {
if(tile.entity.timer.get(timerUnload, speed) && tile.entity.items.total() == 0){
Log.info(threads.getFrameID());
for(Tile other : tile.entity.proximity()){
if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && entity.items.total() == 0 &&
((entity.sortItem == null && other.entity.items.total() > 0) || ((StorageBlock) other.block()).hasItem(other, entity.sortItem))){
offloadNear(tile, ((StorageBlock) other.block()).removeItem(other, entity.sortItem));
}
});
}
}
if(entity.items.total() > 0){

View File

@@ -5,9 +5,8 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockGroup;
public class Unloader extends Block{
public abstract class Unloader extends Block{
protected final int timerUnload = timers++;
protected int speed = 5;
public Unloader(String name){
super(name);
@@ -18,22 +17,6 @@ public class Unloader extends Block{
hasItems = true;
}
@Override
public void update(Tile tile){
if(tile.entity.items.total() == 0 && tile.entity.timer.get(timerUnload, speed)){
tile.allNearby(other -> {
if(other.getTeam() == tile.getTeam() && other.block() instanceof StorageBlock && tile.entity.items.total() == 0 &&
((StorageBlock) other.block()).hasItem(other, null)){
offloadNear(tile, ((StorageBlock) other.block()).removeItem(other, null));
}
});
}
if(tile.entity.items.total() > 0){
tryDump(tile);
}
}
@Override
public boolean canDump(Tile tile, Tile to, Item item){
Block block = to.target().block();

View File

@@ -51,7 +51,7 @@ public class UnitFactory extends Block{
hasItems = true;
solid = false;
itemCapacity = 10;
flags = EnumSet.of(BlockFlag.producer);
flags = EnumSet.of(BlockFlag.producer, BlockFlag.target);
consumes.require(ConsumeItems.class);
}