mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-20 21:08:42 +03:00
Fixed #3899
This commit is contained in:
parent
42d66d1136
commit
57ad1d5366
@ -32,6 +32,7 @@ public class Items implements ContentList{
|
||||
|
||||
sand = new Item("sand", Color.valueOf("f7cba4")){{
|
||||
alwaysUnlocked = true;
|
||||
lowPriority = true;
|
||||
}};
|
||||
|
||||
coal = new Item("coal", Color.valueOf("272727")){{
|
||||
|
@ -341,7 +341,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
state.rules.waves = true;
|
||||
|
||||
//reset win wave??
|
||||
state.rules.winWave = state.rules.attackMode ? -1 : sector.preset != null && sector.preset.captureWave > 0 ? sector.preset.captureWave : state.rules.winWave > state.wave ? state.rules.winWave : 40;
|
||||
state.rules.winWave = state.rules.attackMode ? -1 : sector.preset != null && sector.preset.captureWave > 0 ? sector.preset.captureWave : state.rules.winWave > state.wave ? state.rules.winWave : 30;
|
||||
|
||||
//if there's still an enemy base left, fix it
|
||||
if(state.rules.attackMode){
|
||||
|
@ -340,11 +340,12 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
}else if(floor != Blocks.basalt && floor != Blocks.ice && floor.asFloor().hasSurface()){
|
||||
float noise = noise(x + 782, y, 5, 0.75f, 260f, 1f);
|
||||
if(noise > 0.72f){
|
||||
floor = noise > 0.78f ? Blocks.taintedWater : (floor == Blocks.sand ? Blocks.sandWater : Blocks.darksandTaintedWater);
|
||||
ore = Blocks.air;
|
||||
}else if(noise > 0.67f){
|
||||
floor = (floor == Blocks.sand ? floor : Blocks.darksand);
|
||||
if(noise > 0.67f && !enemies.contains(e -> Mathf.within(x, y, e.x, e.y, 8))){
|
||||
if(noise > 0.72f){
|
||||
floor = noise > 0.78f ? Blocks.taintedWater : (floor == Blocks.sand ? Blocks.sandWater : Blocks.darksandTaintedWater);
|
||||
}else{
|
||||
floor = (floor == Blocks.sand ? floor : Blocks.darksand);
|
||||
}
|
||||
ore = Blocks.air;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ public class Item extends UnlockableContent{
|
||||
* 1 cost = 1 tick added to build time
|
||||
*/
|
||||
public float cost = 1f;
|
||||
/** if true, this item is of lowest priority to drills. */
|
||||
public boolean lowPriority;
|
||||
|
||||
public Item(String name, Color color){
|
||||
super(name);
|
||||
|
@ -168,7 +168,7 @@ public class Drill extends Block{
|
||||
}
|
||||
|
||||
itemArray.sort((item1, item2) -> {
|
||||
int type = Boolean.compare(item1 != Items.sand, item2 != Items.sand);
|
||||
int type = Boolean.compare(!item1.lowPriority, !item2.lowPriority);
|
||||
if(type != 0) return type;
|
||||
int amounts = Integer.compare(oreCount.get(item1, 0), oreCount.get(item2, 0));
|
||||
if(amounts != 0) return amounts;
|
||||
|
@ -27,6 +27,7 @@ public class Unloader extends Block{
|
||||
saveConfig = true;
|
||||
itemCapacity = 0;
|
||||
noUpdateDisabled = true;
|
||||
unloadable = false;
|
||||
|
||||
config(Item.class, (UnloaderBuild tile, Item item) -> tile.sortItem = item);
|
||||
configClear((UnloaderBuild tile) -> tile.sortItem = null);
|
||||
@ -47,10 +48,17 @@ public class Unloader extends Block{
|
||||
public Item sortItem = null;
|
||||
public Building dumpingTo;
|
||||
public int offset = 0;
|
||||
public int[] rotations;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(timer(timerUnload, speed / timeScale())){
|
||||
if(rotations == null || rotations.length != proximity.size){
|
||||
rotations = new int[proximity.size];
|
||||
}
|
||||
|
||||
Log.info("unloader @", id);
|
||||
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
int pos = (offset + i) % proximity.size;
|
||||
var other = proximity.get(pos);
|
||||
@ -61,18 +69,19 @@ public class Unloader extends Block{
|
||||
dumpingTo = other;
|
||||
|
||||
//get item to be taken
|
||||
Item item = sortItem == null ? other.items.beginTake() : sortItem;
|
||||
Item item = sortItem == null ? other.items.takeIndex(rotations[pos]) : sortItem;
|
||||
|
||||
//remove item if it's dumped correctly
|
||||
if(put(item)){
|
||||
other.items.remove(item, 1);
|
||||
|
||||
if(sortItem == null){
|
||||
other.items.endTake(item);
|
||||
}else{
|
||||
other.items.remove(item, 1);
|
||||
rotations[pos] = item.id + 1;
|
||||
}
|
||||
|
||||
other.itemTaken(item);
|
||||
}else if(sortItem == null){
|
||||
other.items.failTake();
|
||||
rotations[pos] = other.items.nextIndex(rotations[pos]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ public class ItemModule extends BlockModule{
|
||||
|
||||
/** Begins a speculative take operation. This returns the item that would be returned by #take(), but does not change state. */
|
||||
@Nullable
|
||||
public Item beginTake(){
|
||||
public Item takeIndex(int takeRotation){
|
||||
for(int i = 0; i < items.length; i++){
|
||||
int index = (i + takeRotation);
|
||||
if(index >= items.length) index -= items.length;
|
||||
@ -217,23 +217,15 @@ public class ItemModule extends BlockModule{
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Finishes a take operation. Updates take state, removes the item. */
|
||||
public void endTake(Item item){
|
||||
items[item.id] --;
|
||||
total --;
|
||||
takeRotation = item.id + 1;
|
||||
}
|
||||
|
||||
public void failTake(){
|
||||
public int nextIndex(int takeRotation){
|
||||
for(int i = 1; i < items.length; i++){
|
||||
int index = (i + takeRotation);
|
||||
if(index >= items.length) index -= items.length;
|
||||
if(items[index] > 0){
|
||||
takeRotation += i;
|
||||
takeRotation %= items.length;
|
||||
return;
|
||||
return (takeRotation + i) % items.length;
|
||||
}
|
||||
}
|
||||
return takeRotation;
|
||||
}
|
||||
|
||||
public int get(int id){
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=08d81cd26f74ea2e490c5ddc6e5a509f30f48368
|
||||
archash=f0400adb14a72ca567ea3b48ea8c3a22c55e1b9e
|
||||
|
Loading…
Reference in New Issue
Block a user