Unloader fixed stupid bug (#11452)
* aaaaaaa * unloader fixed stupid bug (check #development) * a
This commit is contained in:
@@ -14,6 +14,8 @@ import mindustry.gen.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
|
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||||
|
import mindustry.world.blocks.storage.StorageBlock.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -24,6 +26,7 @@ public class Unloader extends Block{
|
|||||||
public @Load(value = "@-center", fallback = "unloader-center") TextureRegion centerRegion;
|
public @Load(value = "@-center", fallback = "unloader-center") TextureRegion centerRegion;
|
||||||
|
|
||||||
public float speed = 1f;
|
public float speed = 1f;
|
||||||
|
public boolean allowCoreUnload = true;
|
||||||
|
|
||||||
/** Cached result of content.items() */
|
/** Cached result of content.items() */
|
||||||
static Item[] allItems;
|
static Item[] allItems;
|
||||||
@@ -94,6 +97,8 @@ public class Unloader extends Block{
|
|||||||
protected final Comparator<ContainerStat> comparator = (x, y) -> {
|
protected final Comparator<ContainerStat> comparator = (x, y) -> {
|
||||||
//sort so it gives priority for blocks that can only either receive or give (not both), and then by load, and then by last use
|
//sort so it gives priority for blocks that can only either receive or give (not both), and then by load, and then by last use
|
||||||
//highest = unload from, lowest = unload to
|
//highest = unload from, lowest = unload to
|
||||||
|
int unloadCore = Boolean.compare(!x.notStorage, !y.notStorage); //priority to core and core containers always
|
||||||
|
if(unloadCore != 0) return unloadCore;
|
||||||
int unloadPriority = Boolean.compare(x.canUnload && !x.canLoad, y.canUnload && !y.canLoad); //priority to receive if it cannot give
|
int unloadPriority = Boolean.compare(x.canUnload && !x.canLoad, y.canUnload && !y.canLoad); //priority to receive if it cannot give
|
||||||
if(unloadPriority != 0) return unloadPriority;
|
if(unloadPriority != 0) return unloadPriority;
|
||||||
int loadPriority = Boolean.compare(x.canUnload || !x.canLoad, y.canUnload || !y.canLoad); //priority to give if it cannot receive
|
int loadPriority = Boolean.compare(x.canUnload || !x.canLoad, y.canUnload || !y.canLoad); //priority to give if it cannot receive
|
||||||
@@ -138,8 +143,8 @@ public class Unloader extends Block{
|
|||||||
if(!other.interactable(team)) continue; //avoid blocks of the wrong team
|
if(!other.interactable(team)) continue; //avoid blocks of the wrong team
|
||||||
|
|
||||||
//partial check
|
//partial check
|
||||||
boolean canLoad = !(other.block instanceof StorageBlock);
|
boolean canLoad = !(other instanceof CoreBuild || (other instanceof StorageBuild sb && sb.linkedCore != null));
|
||||||
boolean canUnload = other.canUnload() && other.items != null;
|
boolean canUnload = other.canUnload() && (allowCoreUnload || canLoad) && other.items != null;
|
||||||
|
|
||||||
if(canLoad || canUnload){ //avoid blocks that can neither give nor receive items
|
if(canLoad || canUnload){ //avoid blocks that can neither give nor receive items
|
||||||
var pb = Pools.obtain(ContainerStat.class, ContainerStat::new);
|
var pb = Pools.obtain(ContainerStat.class, ContainerStat::new);
|
||||||
|
|||||||
Reference in New Issue
Block a user