Lock rotation of blocks that don't rotate
This commit is contained in:
@@ -35,7 +35,7 @@ public class BuildPlan implements Position, QuadTreeObject{
|
|||||||
public BuildPlan(int x, int y, int rotation, Block block){
|
public BuildPlan(int x, int y, int rotation, Block block){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.rotation = rotation;
|
setRotation(block, rotation);
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.breaking = false;
|
this.breaking = false;
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ public class BuildPlan implements Position, QuadTreeObject{
|
|||||||
public BuildPlan(int x, int y, int rotation, Block block, Object config){
|
public BuildPlan(int x, int y, int rotation, Block block, Object config){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.rotation = rotation;
|
setRotation(block, rotation);
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.breaking = false;
|
this.breaking = false;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -136,7 +136,7 @@ public class BuildPlan implements Position, QuadTreeObject{
|
|||||||
public BuildPlan set(int x, int y, int rotation, Block block){
|
public BuildPlan set(int x, int y, int rotation, Block block){
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.rotation = rotation;
|
setRotation(block, rotation);
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.breaking = false;
|
this.breaking = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -177,6 +177,14 @@ public class BuildPlan implements Position, QuadTreeObject{
|
|||||||
return drawy();
|
return drawy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRotation(Block block, int rotation){
|
||||||
|
this.rotation = !block.rotate && block.lockRotation ? 0 : rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRotation(int rotation){
|
||||||
|
if(block != null) setRotation(block, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "BuildPlan{" +
|
return "BuildPlan{" +
|
||||||
|
|||||||
@@ -1038,7 +1038,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
plan.x = World.toTile(wx - plan.block.offset) + ox;
|
plan.x = World.toTile(wx - plan.block.offset) + ox;
|
||||||
plan.y = World.toTile(wy - plan.block.offset) + oy;
|
plan.y = World.toTile(wy - plan.block.offset) + oy;
|
||||||
plan.rotation = Mathf.mod(plan.rotation + direction, 4);
|
plan.setRotation(Mathf.mod(plan.rotation + direction, 4));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,8 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
public boolean underBullets;
|
public boolean underBullets;
|
||||||
/** whether this is rotatable */
|
/** whether this is rotatable */
|
||||||
public boolean rotate;
|
public boolean rotate;
|
||||||
|
/** if rotate is false and this is true, building rotation is set to 0 regardless of player input */
|
||||||
|
public boolean lockRotation = true;
|
||||||
/** if rotate is true and this is false, the region won't rotate when drawing */
|
/** if rotate is true and this is false, the region won't rotate when drawing */
|
||||||
public boolean rotateDraw = true;
|
public boolean rotateDraw = true;
|
||||||
/** if true, schematic flips with this block are inverted. */
|
/** if true, schematic flips with this block are inverted. */
|
||||||
@@ -1343,7 +1345,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
|
|
||||||
public void flipRotation(BuildPlan req, boolean x){
|
public void flipRotation(BuildPlan req, boolean x){
|
||||||
if((x == (req.rotation % 2 == 0)) != invertFlip){
|
if((x == (req.rotation % 2 == 0)) != invertFlip){
|
||||||
req.rotation = Mathf.mod(req.rotation + 2, 4);
|
req.setRotation(Mathf.mod(req.rotation + 2, 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user