Add destination tile to block rotatedOutput (#9949)

* Add destination to rotatedOutput

* Apply to GenericCrafter for output directions.

* Forgot to remove some logs
This commit is contained in:
MEEPofFaith 2024-06-15 21:42:40 -07:00 committed by GitHub
parent 92df8f9507
commit 5c23abf2d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 3 deletions

View File

@ -519,6 +519,10 @@ public class Block extends UnlockableContent implements Senseable{
return rotate;
}
public boolean rotatedOutput(int fromX, int fromY, Tile destination){
return rotatedOutput(fromX, fromY);
}
public boolean synthetic(){
return update || destructible;
}

View File

@ -206,7 +206,7 @@ public interface Autotiler{
//block is facing the other
Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) ||
//does not output to rotated direction
!otherblock.rotatedOutput(otherx, othery) ||
!otherblock.rotatedOutput(otherx, othery, tile) ||
//other block is facing this one
Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y);
}

View File

@ -13,6 +13,7 @@ import mindustry.gen.*;
import mindustry.logic.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.liquid.Conduit.*;
import mindustry.world.draw.*;
import mindustry.world.meta.*;
@ -91,8 +92,17 @@ public class GenericCrafter extends Block{
}
@Override
public boolean rotatedOutput(int x, int y){
return false;
public boolean rotatedOutput(int fromX, int fromY, Tile destination){
if(!(destination.build instanceof ConduitBuild)) return false;
Building crafter = world.build(fromX, fromY);
if(crafter == null) return false;
int relative = Mathf.mod(crafter.relativeTo(destination) - crafter.rotation, 4);
for(int dir : liquidOutputDirections){
if(dir == -1 || dir == relative) return false;
}
return true;
}
@Override