Fixed #3222 / Fixed #3218 / Fixed #3228 / Fixed #3217

This commit is contained in:
Anuken
2020-11-01 09:28:03 -05:00
parent 54ba4b31a1
commit 187cb79265
7 changed files with 33 additions and 9 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ import arc.struct.*;
import arc.util.*; import arc.util.*;
import arc.util.async.*; import arc.util.async.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.core.*; import mindustry.core.*;
import mindustry.game.EventType.*; import mindustry.game.EventType.*;
import mindustry.game.*; import mindustry.game.*;
@@ -116,7 +117,7 @@ public class Pathfinder implements Runnable{
tile.getTeamID(), tile.getTeamID(),
tile.solid(), tile.solid(),
tile.floor().isLiquid, tile.floor().isLiquid,
tile.staticDarkness() >= 2, tile.staticDarkness() >= 2 || (tile.floor().solid && tile.block() == Blocks.air),
nearLiquid, nearLiquid,
nearGround, nearGround,
nearSolid, nearSolid,
+14
View File
@@ -418,13 +418,27 @@ public class Schematics implements Loadable{
} }
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource){ public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource){
placeLoadout(schem, x, y, team, resource, true);
}
public static void placeLoadout(Schematic schem, int x, int y, Team team, Block resource, boolean check){
Stile coreTile = schem.tiles.find(s -> s.block instanceof CoreBlock); Stile coreTile = schem.tiles.find(s -> s.block instanceof CoreBlock);
Seq<Tile> seq = new Seq<>();
if(coreTile == null) throw new IllegalArgumentException("Loadout schematic has no core tile!"); if(coreTile == null) throw new IllegalArgumentException("Loadout schematic has no core tile!");
int ox = x - coreTile.x, oy = y - coreTile.y; int ox = x - coreTile.x, oy = y - coreTile.y;
schem.tiles.each(st -> { schem.tiles.each(st -> {
Tile tile = world.tile(st.x + ox, st.y + oy); Tile tile = world.tile(st.x + ox, st.y + oy);
if(tile == null) return; if(tile == null) return;
//check for blocks that are in the way.
if(check && !(st.block instanceof CoreBlock)){
seq.clear();
tile.getLinkedTilesAs(st.block, seq);
if(seq.contains(t -> !t.block().alwaysReplace)){
return;
}
}
tile.setBlock(st.block, team, st.rotation); tile.setBlock(st.block, team, st.rotation);
Object config = st.config; Object config = st.config;
+10 -1
View File
@@ -21,7 +21,7 @@ public class Universe{
private int turn; private int turn;
private float turnCounter; private float turnCounter;
private Schematic lastLoadout; private @Nullable Schematic lastLoadout;
private ItemSeq lastLaunchResources = new ItemSeq(); private ItemSeq lastLaunchResources = new ItemSeq();
public Universe(){ public Universe(){
@@ -92,6 +92,15 @@ public class Universe{
} }
} }
public void clearLoadoutInfo(){
lastLoadout = null;
lastLaunchResources = new ItemSeq();
Core.settings.remove("launch-resources-seq");
Core.settings.remove("lastloadout-core-shard");
Core.settings.remove("lastloadout-core-nucleus");
Core.settings.remove("lastloadout-core-foundation");
}
public ItemSeq getLaunchResources(){ public ItemSeq getLaunchResources(){
lastLaunchResources = Core.settings.getJson("launch-resources-seq", ItemSeq.class, ItemSeq::new); lastLaunchResources = Core.settings.getJson("launch-resources-seq", ItemSeq.class, ItemSeq::new);
return lastLaunchResources; return lastLaunchResources;
+1 -2
View File
@@ -159,9 +159,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
player.unit().eachGroup(unit -> { player.unit().eachGroup(unit -> {
Item item = unit.item(); Item item = unit.item();
int accepted = tile.acceptStack(item, unit.stack.amount, unit); int accepted = tile.acceptStack(item, unit.stack.amount, unit);
unit.stack.amount -= accepted;
Call.transferItemTo(item, accepted, unit.x, unit.y, tile); Call.transferItemTo(unit, item, accepted, unit.x, unit.y, tile);
if(unit == player.unit()){ if(unit == player.unit()){
Events.fire(new DepositEvent(tile, player, item, accepted)); Events.fire(new DepositEvent(tile, player, item, accepted));
@@ -60,7 +60,7 @@ public class BaseGenerator{
for(Tile tile : cores){ for(Tile tile : cores){
tile.clearOverlay(); tile.clearOverlay();
Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? bases.ores.get((Item)coreschem.required) : Blocks.oreCopper); Schematics.placeLoadout(coreschem.schematic, tile.x, tile.y, team, coreschem.required instanceof Item ? bases.ores.get((Item)coreschem.required) : Blocks.oreCopper, false);
//fill core with every type of item (even non-material) //fill core with every type of item (even non-material)
Building entity = tile.build; Building entity = tile.build;
@@ -121,6 +121,7 @@ public class SettingsMenuDialog extends SettingsDialog{
t.button("@settings.clearresearch", Icon.trash, style, () -> { t.button("@settings.clearresearch", Icon.trash, style, () -> {
ui.showConfirm("@confirm", "@settings.clearresearch.confirm", () -> { ui.showConfirm("@confirm", "@settings.clearresearch.confirm", () -> {
universe.clearLoadoutInfo();
for(TechNode node : TechTree.all){ for(TechNode node : TechTree.all){
node.reset(); node.reset();
} }
@@ -58,16 +58,16 @@ public class StackConveyor extends Block implements Autotiler{
@Override @Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
if(tile.build instanceof StackConveyorBuild){ if(tile.build instanceof StackConveyorBuild b){
int state = ((StackConveyorBuild)tile.build).state; int state = b.state;
if(state == stateLoad){ //standard conveyor mode if(state == stateLoad){ //standard conveyor mode
return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock); return otherblock.outputsItems() && lookingAtEither(tile, rotation, otherx, othery, otherrot, otherblock);
}else if(state == stateUnload){ //router mode }else if(state == stateUnload){ //router mode
return otherblock.acceptsItems && return otherblock.acceptsItems &&
(notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) || (notLookingAt(tile, rotation, otherx, othery, otherrot, otherblock) ||
(otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) && (otherblock instanceof StackConveyor && facing(otherx, othery, otherrot, tile.x, tile.y))) &&
!(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateUnload) && !(world.build(otherx, othery) instanceof StackConveyorBuild s && s.state == stateUnload) &&
!(world.build(otherx, othery) instanceof StackConveyorBuild && ((StackConveyorBuild)world.build(otherx, othery)).state == stateMove && !(world.build(otherx, othery) instanceof StackConveyorBuild s2 && s2.state == stateMove &&
!facing(otherx, othery, otherrot, tile.x, tile.y)); !facing(otherx, othery, otherrot, tile.x, tile.y));
} }
} }