mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-21 20:12:20 -08:00
Unloader fixed stupid bug (#11452)
* aaaaaaa * unloader fixed stupid bug (check #development) * a
This commit is contained in:
parent
8fb7aa34e3
commit
54ea4acf22
1 changed files with 7 additions and 2 deletions
|
|
@ -14,6 +14,8 @@ import mindustry.gen.*;
|
|||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
import mindustry.world.blocks.storage.StorageBlock.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -24,6 +26,7 @@ public class Unloader extends Block{
|
|||
public @Load(value = "@-center", fallback = "unloader-center") TextureRegion centerRegion;
|
||||
|
||||
public float speed = 1f;
|
||||
public boolean allowCoreUnload = true;
|
||||
|
||||
/** Cached result of content.items() */
|
||||
static Item[] allItems;
|
||||
|
|
@ -94,6 +97,8 @@ public class Unloader extends Block{
|
|||
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
|
||||
//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
|
||||
if(unloadPriority != 0) return unloadPriority;
|
||||
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
|
||||
|
||||
//partial check
|
||||
boolean canLoad = !(other.block instanceof StorageBlock);
|
||||
boolean canUnload = other.canUnload() && other.items != null;
|
||||
boolean canLoad = !(other instanceof CoreBuild || (other instanceof StorageBuild sb && sb.linkedCore != null));
|
||||
boolean canUnload = other.canUnload() && (allowCoreUnload || canLoad) && other.items != null;
|
||||
|
||||
if(canLoad || canUnload){ //avoid blocks that can neither give nor receive items
|
||||
var pb = Pools.obtain(ContainerStat.class, ContainerStat::new);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue