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