Block regionRotated

This commit is contained in:
Anuken
2022-01-12 09:58:54 -05:00
parent a053d93636
commit 0f6f85887e
12 changed files with 14 additions and 54 deletions

View File

@@ -289,6 +289,8 @@ public class Block extends UnlockableContent{
protected TextureRegion[] generatedIcons;
protected TextureRegion[] editorVariantRegions;
/** Regions indexes from icons() that are rotated. If either of these is not -1, other regions won't be rotated in ConstructBlocks. */
public int regionRotated1 = -1, regionRotated2 = -1;
public TextureRegion region, editorIcon;
public @Load("@-shadow") TextureRegion customShadowRegion;
public @Load("@-team") TextureRegion teamRegion;

View File

@@ -224,14 +224,17 @@ public class ConstructBlock extends Block{
Draw.draw(Layer.blockBuilding, () -> {
Draw.color(Pal.accent, Pal.remove, constructColor);
boolean noOverrides = current.regionRotated1 == -1 && current.regionRotated2 == -1;
int i = 0;
for(TextureRegion region : current.getGeneratedIcons()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.time = Time.time;
Shaders.blockbuild.progress = progress;
Draw.rect(region, x, y, current.rotate ? rotdeg() : 0);
Draw.rect(region, x, y, current.rotate && (noOverrides || current.regionRotated2 == i || current.regionRotated1 == i) ? rotdeg() : 0);
Draw.flush();
i ++;
}
Draw.color();

View File

@@ -1,29 +0,0 @@
package mindustry.world.blocks.payloads;
import mindustry.gen.*;
import mindustry.world.blocks.payloads.NuclearWarhead.*;
public class BallisticSilo extends PayloadBlock{
public BallisticSilo(String name){
super(name);
}
public class BallisticSiloBuild extends PayloadBlockBuild<BuildPayload>{
@Override
public boolean acceptPayload(Building source, Payload payload){
return this.payload == null && payload instanceof BuildPayload b && b.build instanceof NuclearWarheadBuild;
}
@Override
public void updateTile(){
moveInPayload();
}
@Override
public void draw(){
super.draw();
drawPayload();
}
}
}

View File

@@ -30,6 +30,7 @@ public abstract class BlockProducer extends PayloadBlock{
hasItems = true;
hasPower = true;
rotate = true;
regionRotated1 = 1;
consumes.add(new ConsumeItemDynamic((BlockProducerBuild e) -> e.recipe() != null ? e.recipe().requirements : ItemStack.empty));
}

View File

@@ -1,18 +0,0 @@
package mindustry.world.blocks.payloads;
import mindustry.gen.*;
import mindustry.world.*;
public class NuclearWarhead extends Block{
public float radius = 100f;
public NuclearWarhead(String name){
super(name);
solid = true;
update = true;
}
public class NuclearWarheadBuild extends Building{
}
}

View File

@@ -61,6 +61,7 @@ public class PayloadMassDriver extends PayloadBlock{
rotate = true;
outputsPayload = true;
group = BlockGroup.units;
regionRotated1 = 1;
//point2 is relative
config(Point2.class, (PayloadDriverBuild tile, Point2 point) -> tile.link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY()));

View File

@@ -32,6 +32,7 @@ public class PayloadSource extends PayloadBlock{
clipSize = 120;
noUpdateDisabled = true;
clearOnDoubleTap = true;
regionRotated1 = 1;
config(Block.class, (PayloadSourceBuild build, Block block) -> {
if(canProduce(block) && build.block != block){

View File

@@ -29,6 +29,8 @@ public class Reconstructor extends UnitBlock{
public Reconstructor(String name){
super(name);
regionRotated1 = 1;
regionRotated2 = 2;
}
@Override

View File

@@ -38,6 +38,7 @@ public class UnitFactory extends UnitBlock{
clearOnDoubleTap = true;
outputsPayload = true;
rotate = true;
regionRotated1 = 1;
config(Integer.class, (UnitFactoryBuild tile, Integer i) -> {
if(tile.currentPlan == i) return;