1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 14:56:10 +03:00

Fixed conveyor entities not sleeping

This commit is contained in:
Anuken 2018-07-19 17:58:16 -04:00
parent 9f723c39ef
commit bcf72b894d
5 changed files with 26 additions and 19 deletions

View File

@ -11,6 +11,7 @@ import io.anuke.mindustry.game.EventType.TileChangeEvent;
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.TeamInfo.TeamData;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.core.Events;
@ -29,6 +30,7 @@ public class Pathfinder{
public Pathfinder(){
Events.on(WorldLoadEvent.class, this::clear);
Events.on(TileChangeEvent.class, tile -> {
if(Net.client()) return;
for(TeamData data : state.teams.getTeams()){
if(data.team != tile.getTeam() && paths[data.team.ordinal()].weights[tile.x][tile.y] >= Float.MAX_VALUE){
@ -41,6 +43,8 @@ public class Pathfinder{
}
public void update(){
if(Net.client()) return;
ObjectSetIterator<TeamData> iterator = new ObjectSetIterator<>(state.teams.getTeams());
for(TeamData team : iterator){

View File

@ -1,7 +1,6 @@
package io.anuke.mindustry.maps.generation;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.IntArray;
import com.badlogic.gdx.utils.ObjectMap;
@ -18,14 +17,13 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.ucore.noise.RidgedPerlin;
import io.anuke.ucore.noise.Simplex;
import io.anuke.ucore.noise.VoronoiNoise;
import io.anuke.ucore.util.Bits;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.SeedRandom;
import static io.anuke.mindustry.Vars.sectorSize;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.world;
import static io.anuke.mindustry.Vars.*;
public class WorldGenerator{
@ -35,6 +33,7 @@ public class WorldGenerator{
private Simplex sim = new Simplex(seed);
private Simplex sim2 = new Simplex(seed + 1);
private Simplex sim3 = new Simplex(seed + 2);
private VoronoiNoise vn = new VoronoiNoise(seed + 2, (short)0);
private SeedRandom random = new SeedRandom(seed + 3);
@ -195,8 +194,10 @@ public class WorldGenerator{
}
}
tiles[width / 2][height / 2].setBlock(StorageBlocks.core);
tiles[width / 2][height / 2].setTeam(Team.blue);
int coreX = width/2, coreY = height/3;
tiles[coreX][coreY].setBlock(StorageBlocks.core);
tiles[coreX][coreY].setTeam(Team.blue);
prepareTiles(tiles, seed, true);
}
@ -217,11 +218,11 @@ public class WorldGenerator{
Block wall = Blocks.air;
double elevation = sim.octaveNoise2D(detailed ? 7 : 2, 0.5, 1f / 500, x, y) * 4.1 - 1;
double temp = sim3.octaveNoise2D(detailed ? 12 : 6, 0.54, 1f / 820f, x, y);
double temp = vn.noise(x, y, 1f/200f)/2f + sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 620f, x, y);
double r = sim2.octaveNoise2D(1, 0.6, 1f / 70, x, y);
double edgeDist = Math.max(sectorSize / 2, sectorSize / 2) - Math.max(Math.abs(x - sectorSize / 2), Math.abs(y - sectorSize / 2));
double dst = Vector2.dst((sectorX * sectorSize) + sectorSize/2f, (sectorY * sectorSize) + sectorSize/2f, x, y);
//double dst = Vector2.dst((sectorX * sectorSize) + sectorSize/2f, (sectorY * sectorSize) + sectorSize/2f, x, y);
double elevDip = 30;
double border = 14;
@ -245,9 +246,9 @@ public class WorldGenerator{
floor = Blocks.lava;
}
if(dst < elevDip){
elevation -= (elevDip - dst) / elevDip * 3.0;
}else if(detailed && r > 0.9){
//if(dst < elevDip){
// elevation -= (elevDip - dst) / elevDip * 3.0;
/*}else*/if(detailed && r > 0.9){
floor = Blocks.water;
elevation = 0;

View File

@ -60,22 +60,19 @@ public abstract class BaseBlock{
return amount;
}
/**
* Handle a stack input.
*/
/**Handle a stack input.*/
public void handleStack(Item item, int amount, Tile tile, Unit source){
tile.entity.wakeUp();
tile.entity.items.add(item, amount);
}
/**
* Returns offset for stack placement.
*/
/**Returns offset for stack placement.*/
public void getStackOffset(Item item, Tile tile, Translator trns){
}
public void onProximityUpdate(Tile tile){
if(tile.entity != null) tile.entity.wakeUp();
}
public void handleItem(Item item, Tile tile, Tile source){

View File

@ -49,6 +49,8 @@ public class Conduit extends LiquidBlock{
@Override
public void onProximityUpdate(Tile tile){
super.onProximityUpdate(tile);
ConduitEntity entity = tile.entity();
entity.blendbits = 0;
entity.blendshadowrot = -1;

View File

@ -98,6 +98,8 @@ public class Conveyor extends Block{
@Override
public void onProximityUpdate(Tile tile){
super.onProximityUpdate(tile);
ConveyorEntity entity = tile.entity();
entity.blendbits = 0;
entity.blendsclx = entity.blendscly = 1;
@ -224,6 +226,7 @@ public class Conveyor extends Block{
break;
}
float prev = pos.y;
float nextpos = (i == entity.convey.size - 1 ? 100f : pos2.set(entity.convey.get(i + 1), ItemPos.updateShorts).y) - itemSpace;
if(entity.minCarry >= pos.y && entity.minCarry <= nextpos){
nextpos = entity.minCarry;
@ -233,12 +236,12 @@ public class Conveyor extends Block{
if(maxmove > minmove){
pos.y += maxmove;
pos.x = Mathf.lerpDelta(pos.x, 0, 0.06f);
totalMoved += maxmove;
}else{
pos.x = Mathf.lerpDelta(pos.x, pos.seed / offsetScl, 0.1f);
}
pos.y = Mathf.clamp(pos.y);
totalMoved += (pos.y - prev);
if(pos.y >= 0.9999f && offloadDir(tile, pos.item)){
minremove = Math.min(i, minremove);
@ -262,7 +265,7 @@ public class Conveyor extends Block{
entity.carrying = 0f;
entity.minCarry = 2f;
if(totalMoved <= 0.0001f){
if(totalMoved/Timers.delta() <= 0.0001f){
entity.sleep();
}