mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-24 21:41:25 -08:00
Auto-junctions
This commit is contained in:
parent
b6d72044a0
commit
2c59288969
5 changed files with 34 additions and 5 deletions
|
|
@ -526,6 +526,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
req.animScale = 1f;
|
||||
lineRequests.add(req);
|
||||
});
|
||||
|
||||
lineRequests.each(req -> req.block = req.block.getReplacement(req, lineRequests));
|
||||
}
|
||||
|
||||
protected void updateLine(int x1, int y1){
|
||||
|
|
|
|||
|
|
@ -551,6 +551,11 @@ public class Block extends BlockStorage{
|
|||
return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group;
|
||||
}
|
||||
|
||||
/** @return a possible replacement for this block when placed in a line by the player. */
|
||||
public Block getReplacement(BuildRequest req, Array<BuildRequest> requests){
|
||||
return this;
|
||||
}
|
||||
|
||||
public float handleDamage(Tile tile, float amount){
|
||||
return amount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
package io.anuke.mindustry.world.blocks.distribution;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
|
@ -61,6 +65,16 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
|||
Draw.rect(topRegions[bits[0]], req.drawx(), req.drawy(), topRegions[bits[0]].getWidth() * Draw.scl * req.animScale, topRegions[bits[0]].getHeight() * Draw.scl * req.animScale, req.rotation * 90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getReplacement(BuildRequest req, Array<BuildRequest> requests){
|
||||
Boolf<Point2> cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && o.rotation == req.rotation && (req.block instanceof Conduit || req.block instanceof LiquidJunction));
|
||||
return cont.get(Geometry.d4(req.rotation)) &&
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conduit &&
|
||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.liquidJunction : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformCase(int num, int[] bits){
|
||||
bits[0] = num == 0 ? 3 : num == 1 ? 6 : num == 2 ? 2 : num == 3 ? 4 : num == 4 ? 5 : num == 5 ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -2,16 +2,18 @@ package io.anuke.mindustry.world.blocks.distribution;
|
|||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
|
|
@ -247,6 +249,16 @@ public class Conveyor extends Block implements Autotiler{
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getReplacement(BuildRequest req, Array<BuildRequest> requests){
|
||||
Boolf<Point2> cont = p -> requests.contains(o -> o.x == req.x + p.x && o.y == req.y + p.y && o.rotation == req.rotation && (req.block instanceof Conveyor || req.block instanceof Junction));
|
||||
return cont.get(Geometry.d4(req.rotation)) &&
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conveyor &&
|
||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeStack(Tile tile, Item item, int amount){
|
||||
ConveyorEntity entity = tile.entity();
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||
Scl.setAddition(-0.5f);
|
||||
}
|
||||
|
||||
//IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
return new IOSApplication(new ClientLauncher(){
|
||||
|
||||
@Override
|
||||
|
|
@ -103,7 +102,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||
|
||||
NSURL url = new NSURL(to.file());
|
||||
UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null);
|
||||
//p.getPopoverPresentationController().setSourceView(UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView());
|
||||
|
||||
//DispatchQueue.getMainQueue().sync(() -> {
|
||||
UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
|
||||
|
|
@ -135,7 +133,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||
|
||||
@Override
|
||||
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
|
||||
System.out.println("Opened URL: " + url.getPath());
|
||||
openURL(url);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -145,7 +142,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||
boolean b = super.didFinishLaunching(application, options);
|
||||
|
||||
if(options != null && options.has(UIApplicationLaunchOptions.Keys.URL())){
|
||||
System.out.println("Opened URL at launch: " + ((NSURL)options.get(UIApplicationLaunchOptions.Keys.URL())).getPath());
|
||||
openURL(((NSURL)options.get(UIApplicationLaunchOptions.Keys.URL())));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue