From 4039556aaeb84d643596fbfed599a7ff20a6d71b Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 6 May 2023 21:17:41 -0400 Subject: [PATCH] WIP schematic part idea --- core/src/mindustry/content/Blocks.java | 10 +++ .../world/blocks/logic/PartMarker.java | 65 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 core/src/mindustry/world/blocks/logic/PartMarker.java diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 6a7cebb2ef..4541e4cd85 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -79,6 +79,8 @@ public class Blocks{ //sandbox powerSource, powerVoid, itemSource, itemVoid, liquidSource, liquidVoid, payloadSource, payloadVoid, illuminator, heatSource, + partInput, partOutput, + //defense copperWall, copperWallLarge, titaniumWall, titaniumWallLarge, plastaniumWall, plastaniumWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge, phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, @@ -5742,6 +5744,14 @@ public class Blocks{ ambientSound = Sounds.none; }}; + partInput = new PartMarker("part-input"){{ + requirements(Category.crafting, BuildVisibility.debugOnly, with()); + }}; + + partOutput = new PartMarker("part-output"){{ + requirements(Category.crafting, BuildVisibility.debugOnly, with()); + }}; + //TODO move illuminator = new LightBlock("illuminator"){{ requirements(Category.effect, BuildVisibility.lightingOnly, with(Items.graphite, 12, Items.silicon, 8, Items.lead, 8)); diff --git a/core/src/mindustry/world/blocks/logic/PartMarker.java b/core/src/mindustry/world/blocks/logic/PartMarker.java new file mode 100644 index 0000000000..7fc6a2573c --- /dev/null +++ b/core/src/mindustry/world/blocks/logic/PartMarker.java @@ -0,0 +1,65 @@ +package mindustry.world.blocks.logic; + +import arc.graphics.g2d.*; +import arc.util.*; +import arc.util.io.*; +import mindustry.annotations.Annotations.*; +import mindustry.ctype.*; +import mindustry.gen.*; +import mindustry.io.*; +import mindustry.type.*; +import mindustry.world.*; +import mindustry.world.meta.*; + +/** For internal use only; marks base part edges. */ +public class PartMarker extends Block{ + public @Load("@-arrow") TextureRegion arrowRegion; + + public PartMarker(String name){ + super(name); + + update = true; + rotate = true; + configurable = true; + saveConfig = true; + group = BlockGroup.transportation; + + config(Item.class, (PartMarkerBuild tile, Item item) -> tile.content = item); + config(Liquid.class, (PartMarkerBuild tile, Liquid item) -> tile.content = item); + configClear((PartMarkerBuild tile) -> tile.content = null); + } + + public class PartMarkerBuild extends Building{ + public @Nullable UnlockableContent content; + + @Override + public void draw(){ + super.draw(); + Draw.rect(arrowRegion, x, y); + + if(content != null){ + float size = 4f; + Draw.rect(content.fullIcon, x, y, size, size); + } + } + + @Override + public UnlockableContent config(){ + return content; + } + + @Override + public void write(Writes write){ + super.write(write); + + TypeIO.writeContent(write, content); + } + + @Override + public void read(Reads read, byte revision){ + super.read(read, revision); + + content = TypeIO.readContent(read) instanceof UnlockableContent con ? con : null; + } + } +}