Fixed deadlock / Crafter fixes / Autotile fixes / Low FPS ship fixes
This commit is contained in:
@@ -153,7 +153,7 @@ public class CraftingBlocks extends BlockList implements ContentList {
|
||||
melter = new PowerCrafter("melter") {{
|
||||
health = 200;
|
||||
outputLiquid = Liquids.lava;
|
||||
outputLiquidAmount = 0.05f;
|
||||
outputLiquidAmount = 0.75f;
|
||||
itemCapacity = 50;
|
||||
craftTime = 10f;
|
||||
hasLiquids = hasPower = true;
|
||||
@@ -212,7 +212,7 @@ public class CraftingBlocks extends BlockList implements ContentList {
|
||||
itemCapacity = 50;
|
||||
craftTime = 25f;
|
||||
outputLiquid = Liquids.oil;
|
||||
outputLiquidAmount = 0.1f;
|
||||
outputLiquidAmount = 0.14f;
|
||||
size = 2;
|
||||
health = 320;
|
||||
hasLiquids = true;
|
||||
@@ -238,6 +238,7 @@ public class CraftingBlocks extends BlockList implements ContentList {
|
||||
liquidCapacity = 21f;
|
||||
craftTime = 14;
|
||||
output = Items.stone;
|
||||
itemCapacity = 20;
|
||||
health = 80;
|
||||
craftEffect = BlockFx.purifystone;
|
||||
hasLiquids = hasItems = true;
|
||||
|
||||
@@ -115,11 +115,18 @@ public class ThreadHandler {
|
||||
while (true) {
|
||||
long time = TimeUtils.nanoTime();
|
||||
|
||||
synchronized (toRun) {
|
||||
for(Runnable r : toRun){
|
||||
r.run();
|
||||
while(true){
|
||||
Runnable r;
|
||||
synchronized (toRun){
|
||||
if(toRun.size > 0){
|
||||
r = toRun.pop();
|
||||
}else{
|
||||
r = null;
|
||||
}
|
||||
}
|
||||
toRun.clear();
|
||||
|
||||
if(r == null) break;
|
||||
r.run();
|
||||
}
|
||||
|
||||
logic.doUpdate = true;
|
||||
|
||||
@@ -225,7 +225,7 @@ public class UI extends SceneModule{
|
||||
|
||||
public void loadAnd(String text, Callable call){
|
||||
loadfrag.show(text);
|
||||
Timers.runTask(6f, () -> {
|
||||
Timers.runTask(7f, () -> {
|
||||
call.run();
|
||||
loadfrag.hide();
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -267,6 +268,28 @@ public class World extends Module{
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(Tile tile, Block block, Team team){
|
||||
tile.setBlock(block);
|
||||
if (block.isMultiblock()) {
|
||||
int offsetx = -(block.size - 1) / 2;
|
||||
int offsety = -(block.size - 1) / 2;
|
||||
|
||||
for (int dx = 0; dx < block.size; dx++) {
|
||||
for (int dy = 0; dy < block.size; dy++) {
|
||||
int worldx = dx + offsetx + tile.x;
|
||||
int worldy = dy + offsety + tile.y;
|
||||
if (!(worldx == tile.x && worldy == tile.y)) {
|
||||
Tile toplace = world.tile(worldx, worldy);
|
||||
if (toplace != null) {
|
||||
toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety));
|
||||
toplace.setTeam(team);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**Raycast, but with world coordinates.*/
|
||||
public GridPoint2 raycastWorld(float x, float y, float x2, float y2){
|
||||
return raycast(Mathf.scl2(x, tilesize), Mathf.scl2(y, tilesize),
|
||||
|
||||
@@ -599,18 +599,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
movement.set(targetX - x, targetY - y).limit(mech.speed);
|
||||
movement.setAngle(Mathf.slerpDelta(movement.angle(), velocity.angle(), 0.05f));
|
||||
movement.setAngle(Mathf.slerp(movement.angle(), velocity.angle(), 0.05f));
|
||||
|
||||
if(distanceTo(targetX, targetY) < attractDst){
|
||||
movement.setZero();
|
||||
}
|
||||
|
||||
velocity.add(movement);
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed);
|
||||
|
||||
//hovering effect
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.08f);
|
||||
|
||||
if(velocity.len() <= 0.2f){
|
||||
rotation += Mathf.sin(Timers.time() + id * 99, 10f, 1f);
|
||||
@@ -618,6 +613,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
rotation = Mathf.slerpDelta(rotation, velocity.angle(), velocity.len()/10f);
|
||||
}
|
||||
|
||||
updateVelocityStatus(mech.drag, mech.maxSpeed);
|
||||
|
||||
//hovering effect
|
||||
x += Mathf.sin(Timers.time() + id * 999, 25f, 0.08f);
|
||||
y += Mathf.cos(Timers.time() + id * 999, 25f, 0.08f);
|
||||
|
||||
//update shooting if not building, not mining and there's ammo left
|
||||
if(!isBuilding() && inventory.hasAmmo() && getMineTile() == null){
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ public class BuildBlock extends Block {
|
||||
|
||||
@Remote(called = Loc.server, in = In.blocks)
|
||||
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team){
|
||||
tile.setBlock(block);
|
||||
world.setBlock(tile, block, team);
|
||||
tile.setRotation(rotation);
|
||||
tile.setTeam(team);
|
||||
Effects.effect(Fx.placeBlock, tile.drawx(), tile.drawy(), block.size);
|
||||
|
||||
@@ -40,15 +40,15 @@ public class Conduit extends LiquidBlock {
|
||||
ConduitEntity entity = tile.entity();
|
||||
entity.blendbits = 0;
|
||||
|
||||
if(blends(tile, 0)){
|
||||
if(blends(tile, 1) && blends(tile, 2)) {
|
||||
entity.blendbits = 2;
|
||||
}else if(blends(tile, 3) && blends(tile, 2)) {
|
||||
entity.blendbits = 4;
|
||||
}else if(blends(tile, 0)){
|
||||
if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)) {
|
||||
entity.blendbits = 3;
|
||||
}else if(blends(tile, 1) && blends(tile, 3)) {
|
||||
entity.blendbits = 6;
|
||||
}else if(blends(tile, 1) && blends(tile, 2)) {
|
||||
entity.blendbits = 2;
|
||||
}else if(blends(tile, 3) && blends(tile, 2)) {
|
||||
entity.blendbits = 4;
|
||||
entity.blendbits = 6;
|
||||
}else if(blends(tile, 1)) {
|
||||
entity.blendbits = 5;
|
||||
}else if(blends(tile, 3)) {
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class ItemLiquidGenerator extends ItemGenerator {
|
||||
ItemGeneratorEntity entity = tile.entity();
|
||||
|
||||
//liquid takes priority over solids
|
||||
if(entity.liquids.currentAmount() >= 0.001f){
|
||||
if(entity.liquids.currentAmount() >= 0.001f && entity.cons.valid()){
|
||||
float powerPerLiquid = getLiquidEfficiency(entity.liquids.current())*this.powerPerLiquid;
|
||||
float used = Math.min(entity.liquids.currentAmount(), maxLiquidGenerate * Timers.delta());
|
||||
used = Math.min(used, (powerCapacity - entity.power.amount)/powerPerLiquid);
|
||||
@@ -47,7 +47,7 @@ public abstract class ItemLiquidGenerator extends ItemGenerator {
|
||||
float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency;
|
||||
float mfract = maxPower / (powerOutput);
|
||||
|
||||
if (entity.generateTime > 0f) {
|
||||
if (entity.generateTime > 0f && entity.cons.valid()) {
|
||||
entity.generateTime -= 1f / itemDuration * mfract;
|
||||
entity.power.amount += maxPower;
|
||||
entity.generateTime = Mathf.clamp(entity.generateTime);
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
|
||||
//TODO
|
||||
public class TurbineGenerator extends BurnerGenerator {
|
||||
|
||||
public TurbineGenerator(String name) {
|
||||
super(name);
|
||||
singleLiquid = false;
|
||||
|
||||
consumes.require(ConsumeLiquid.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(tile, source, liquid, amount) || liquid == consumes.liquid() && tile.entity.liquids.get(consumes.liquid()) < liquidCapacity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,11 @@ public class Fracker extends SolidPump {
|
||||
return new FrackerEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float typeLiquid(Tile tile) {
|
||||
return tile.entity.liquids.get(result);
|
||||
}
|
||||
|
||||
public static class FrackerEntity extends SolidPumpEntity{
|
||||
public float accumulator;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,6 @@ public class Pump extends LiquidBlock{
|
||||
stats.add(BlockStat.liquidOutput, 60f*pumpAmount, StatUnit.liquidSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
Draw.rect(name(), tile.drawx(), tile.drawy());
|
||||
|
||||
@@ -74,8 +74,8 @@ public class SolidPump extends Pump {
|
||||
if(isValid(tile)) fraction = 1f;
|
||||
}
|
||||
|
||||
if(tile.entity.cons.valid() && tile.entity.liquids.total() < liquidCapacity - 0.001f){
|
||||
float maxPump = Math.min(liquidCapacity - tile.entity.liquids.total(), pumpAmount * Timers.delta() * fraction);
|
||||
if(tile.entity.cons.valid() && typeLiquid(tile) < liquidCapacity - 0.001f){
|
||||
float maxPump = Math.min(liquidCapacity - typeLiquid(tile), pumpAmount * Timers.delta() * fraction);
|
||||
tile.entity.liquids.add(result, maxPump);
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.02f);
|
||||
if(Mathf.chance(Timers.delta() * updateEffectChance))
|
||||
@@ -86,7 +86,7 @@ public class SolidPump extends Pump {
|
||||
|
||||
entity.pumpTime += entity.warmup * Timers.delta();
|
||||
|
||||
tryDumpLiquid(tile, entity.liquids.current());
|
||||
tryDumpLiquid(tile, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,6 +113,10 @@ public class SolidPump extends Pump {
|
||||
return new SolidPumpEntity();
|
||||
}
|
||||
|
||||
public float typeLiquid(Tile tile){
|
||||
return tile.entity.liquids.total();
|
||||
}
|
||||
|
||||
public static class SolidPumpEntity extends TileEntity{
|
||||
public float warmup;
|
||||
public float pumpTime;
|
||||
|
||||
@@ -11,7 +11,6 @@ import io.anuke.mindustry.world.meta.values.LiquidFilterValue;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.function.Predicate;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
|
||||
public class ConsumeLiquidFilter extends Consume{
|
||||
private final Predicate<Liquid> filter;
|
||||
@@ -43,8 +42,6 @@ public class ConsumeLiquidFilter extends Consume{
|
||||
table.add("/");
|
||||
}
|
||||
}
|
||||
|
||||
table.add("x" + Strings.toFixed(use * 60f, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.world.mapgen;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
@@ -144,6 +145,7 @@ public class WorldGenerator {
|
||||
}
|
||||
|
||||
public static void generateMap(Tile[][] tiles, int seed){
|
||||
MathUtils.random.setSeed((long)(Math.random() * 99999999));
|
||||
Simplex sim = new Simplex(Mathf.random(99999));
|
||||
Simplex sim2 = new Simplex(Mathf.random(99999));
|
||||
Simplex sim3 = new Simplex(Mathf.random(99999));
|
||||
|
||||
Reference in New Issue
Block a user