Auto-junctions
This commit is contained in:
@@ -526,6 +526,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
req.animScale = 1f;
|
req.animScale = 1f;
|
||||||
lineRequests.add(req);
|
lineRequests.add(req);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lineRequests.each(req -> req.block = req.block.getReplacement(req, lineRequests));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLine(int x1, int y1){
|
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 (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){
|
public float handleDamage(Tile tile, float amount){
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package io.anuke.mindustry.world.blocks.distribution;
|
package io.anuke.mindustry.world.blocks.distribution;
|
||||||
|
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
|
import io.anuke.arc.collection.*;
|
||||||
|
import io.anuke.arc.func.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.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);
|
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
|
@Override
|
||||||
public void transformCase(int num, int[] bits){
|
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;
|
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.*;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
|
import io.anuke.arc.func.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.math.geom.*;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.graphics.*;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.type.*;
|
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.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.meta.*;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
@@ -247,6 +249,16 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
return true;
|
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
|
@Override
|
||||||
public int removeStack(Tile tile, Item item, int amount){
|
public int removeStack(Tile tile, Item item, int amount){
|
||||||
ConveyorEntity entity = tile.entity();
|
ConveyorEntity entity = tile.entity();
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
Scl.setAddition(-0.5f);
|
Scl.setAddition(-0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
|
||||||
return new IOSApplication(new ClientLauncher(){
|
return new IOSApplication(new ClientLauncher(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,7 +102,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
|
|
||||||
NSURL url = new NSURL(to.file());
|
NSURL url = new NSURL(to.file());
|
||||||
UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null);
|
UIActivityViewController p = new UIActivityViewController(Collections.singletonList(url), null);
|
||||||
//p.getPopoverPresentationController().setSourceView(UIApplication.getSharedApplication().getKeyWindow().getRootViewController().getView());
|
|
||||||
|
|
||||||
//DispatchQueue.getMainQueue().sync(() -> {
|
//DispatchQueue.getMainQueue().sync(() -> {
|
||||||
UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
|
UIApplication.getSharedApplication().getKeyWindow().getRootViewController()
|
||||||
@@ -135,7 +133,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
|
public boolean openURL(UIApplication app, NSURL url, UIApplicationOpenURLOptions options){
|
||||||
System.out.println("Opened URL: " + url.getPath());
|
|
||||||
openURL(url);
|
openURL(url);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -145,7 +142,6 @@ public class IOSLauncher extends IOSApplication.Delegate{
|
|||||||
boolean b = super.didFinishLaunching(application, options);
|
boolean b = super.didFinishLaunching(application, options);
|
||||||
|
|
||||||
if(options != null && options.has(UIApplicationLaunchOptions.Keys.URL())){
|
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())));
|
openURL(((NSURL)options.get(UIApplicationLaunchOptions.Keys.URL())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user