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

@@ -31,7 +31,7 @@ public class ContinuousFlameBulletType extends ContinuousBulletType{
0.25f, 0.7f, 0.1f, 0.03f
};
public Color[] colors = {Color.valueOf("eb7abe").a(0.55f), Color.valueOf("e189f5").a(0.7f), Color.valueOf("907ef7").a(0.8f), Color.valueOf("91a4ff"), Color.white};
public Color[] colors = {Color.valueOf("eb7abe").a(0.55f), Color.valueOf("e189f5").a(0.7f), Color.valueOf("907ef7").a(0.8f), Color.valueOf("91a4ff"), Color.white.cpy()};
public ContinuousFlameBulletType(float damage){
this.damage = damage;

View File

@@ -216,15 +216,11 @@ public class ClassMap{
classes.put("MessageBuild", mindustry.world.blocks.logic.MessageBlock.MessageBuild.class);
classes.put("SwitchBlock", mindustry.world.blocks.logic.SwitchBlock.class);
classes.put("SwitchBuild", mindustry.world.blocks.logic.SwitchBlock.SwitchBuild.class);
classes.put("BallisticSilo", mindustry.world.blocks.payloads.BallisticSilo.class);
classes.put("BallisticSiloBuild", mindustry.world.blocks.payloads.BallisticSilo.BallisticSiloBuild.class);
classes.put("BlockProducer", mindustry.world.blocks.payloads.BlockProducer.class);
classes.put("BlockProducerBuild", mindustry.world.blocks.payloads.BlockProducer.BlockProducerBuild.class);
classes.put("BuildPayload", mindustry.world.blocks.payloads.BuildPayload.class);
classes.put("Constructor", mindustry.world.blocks.payloads.Constructor.class);
classes.put("ConstructorBuild", mindustry.world.blocks.payloads.Constructor.ConstructorBuild.class);
classes.put("NuclearWarhead", mindustry.world.blocks.payloads.NuclearWarhead.class);
classes.put("NuclearWarheadBuild", mindustry.world.blocks.payloads.NuclearWarhead.NuclearWarheadBuild.class);
classes.put("Payload", mindustry.world.blocks.payloads.Payload.class);
classes.put("PayloadBlock", mindustry.world.blocks.payloads.PayloadBlock.class);
classes.put("PayloadBlockBuild", mindustry.world.blocks.payloads.PayloadBlock.PayloadBlockBuild.class);

View File

@@ -369,7 +369,7 @@ public class Mods implements Loadable{
mods.add(mod);
}catch(Throwable e){
if(e instanceof ClassNotFoundException && e.getMessage().contains("mindustry.plugin.Plugin")){
Log.info("Plugin @ is outdated and needs to be ported to 6.0! Update its main class to inherit from 'mindustry.mod.Plugin'. See https://mindustrygame.github.io/wiki/modding/6-migrationv6/");
Log.info("Plugin '@' is outdated and needs to be ported to 6.0! Update its main class to inherit from 'mindustry.mod.Plugin'. See https://mindustrygame.github.io/wiki/modding/6-migrationv6/", file.name());
}else{
Log.err("Failed to load mod file @. Skipping.", file);
Log.err(e);

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;