diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-25 15:37:57 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-11-25 15:37:57 +0900 |
commit | 81a315f025f361d1155305e55dfee29308a74ed3 (patch) | |
tree | 9be59a599ef9821ca9e66005207cee32022e5a4f /src/main/java | |
parent | a49e2c1970f6f77079a860dd5e92741251f41c9c (diff) | |
download | Skyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.tar.gz Skyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.tar.bz2 Skyblock-Dungeons-Guide-81a315f025f361d1155305e55dfee29308a74ed3.zip |
room processor stuff
Diffstat (limited to 'src/main/java')
10 files changed, 215 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java index f9069670..b998fb27 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/data/DungeonRoomInfo.java @@ -26,4 +26,6 @@ public class DungeonRoomInfo implements Serializable { private UUID uuid; private String name; + + private String processorId = "default"; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java index 30908ef8..f13ab33f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/doorfinder/DungeonDoor.java @@ -18,20 +18,55 @@ public class DungeonDoor { private static final Set<Block> legalBlocks = Sets.newHashSet(Blocks.coal_block, Blocks.barrier, Blocks.monster_egg, Blocks.air, Blocks.stained_hardened_clay); + private boolean requiresKey = false; + private boolean opened = false; public DungeonDoor(World world, BlockPos pos) { this.w = world; this.position = pos; + Block itshouldbeall = world.getChunkFromBlockCoords(pos).getBlock(pos); + if (!legalBlocks.contains(itshouldbeall)) { + exist = false; + return; + } for (int x = -1; x<=1; x++) for (int y = -1; y<=1; y++) for (int z = -1; z<=1; z++) { BlockPos pos2 = pos.add(x,y,z); Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); - if (!legalBlocks.contains(block)) exist = false; + if (itshouldbeall != block) exist = false; } if (exist) { BlockPos ZCheck = pos.add(0,0,2); isZDir = world.getChunkFromBlockCoords(ZCheck).getBlock(ZCheck) == Blocks.air; + + if (isZDir) { + for (int x = -1; x<=1; x++) + for (int y = -1; y<=1; y++) + for (int z = -2; z<=2; z+=4) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } else { + for (int x = -2; x<=2; x+=4) + for (int y = -1; y<=1; y++) + for (int z = -1; z<=1; z++) { + BlockPos pos2 = pos.add(x,y,z); + Block block = world.getChunkFromBlockCoords(pos2).getBlock(pos2); + if (block != Blocks.air) exist = false; + } + } + } + if (!exist) { + isZDir = false; + return; + } + + if (itshouldbeall == Blocks.stained_hardened_clay || itshouldbeall == Blocks.coal_block) { + requiresKey = true; + } else if (itshouldbeall == Blocks.barrier) { + opened = true; } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java index cd174660..7e8c43e0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoom.java @@ -5,6 +5,9 @@ import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.MapProcessor; import kr.syeyoung.dungeonsguide.dungeon.data.DungeonRoomInfo; import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; +import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; +import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessorGenerator; import lombok.Getter; import net.minecraft.block.Block; import net.minecraft.util.BlockPos; @@ -33,6 +36,9 @@ public class DungeonRoom { private final int unitWidth; // X private final int unitHeight; // Z + + private RoomProcessor roomProcessor; + public DungeonRoom(List<Point> points, short shape, byte color, BlockPos min, BlockPos max, DungeonContext context) { this.unitPoints = points; this.shape = shape; @@ -40,8 +46,6 @@ public class DungeonRoom { this.min = min; this.max = max; this.context = context; - buildDoors(); - buildRoom(); minRoomPt = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); for (Point pt : unitPoints) { @@ -50,6 +54,11 @@ public class DungeonRoom { } unitWidth = (int) Math.ceil(max.getX() - min.getX() / 32.0); unitHeight = (int) Math.ceil(max.getZ() - min.getZ() / 32.0); + + + buildDoors(); + buildRoom(); + updateRoomProcessor(); } private static final Set<Vector2d> directions = Sets.newHashSet(new Vector2d(0,16), new Vector2d(0, -16), new Vector2d(16, 0), new Vector2d(-16 , 0)); @@ -81,6 +90,12 @@ public class DungeonRoom { this.dungeonRoomInfo = dungeonRoomInfo; } + public void updateRoomProcessor() { + RoomProcessorGenerator roomProcessorGenerator = ProcessorFactory.getRoomProcessorGenerator(dungeonRoomInfo.getProcessorId()); + if (roomProcessorGenerator == null) this.roomProcessor = null; + else this.roomProcessor = roomProcessorGenerator.createNew(this); + } + public Block getAbsoluteBlockAt(int x, int y, int z) { // validate x y z's BlockPos pos = new BlockPos(x,y,z); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java index 544dc03e..5b52bcf0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java @@ -33,8 +33,6 @@ public class GuiDungeonRoomEdit extends GuiScreen { tabbedPane.addTab("General", new GeneralEditPane(room)); tabbedPane.addTab("Room Match", new RoomDataDisplayPane(room)); - - } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java new file mode 100644 index 00000000..7e9e42cb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MStringSelectionButton.java @@ -0,0 +1,69 @@ +package kr.syeyoung.dungeonsguide.roomedit.elements; + +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import lombok.Getter; +import lombok.Setter; + +import java.awt.*; +import java.util.List; + +@Getter +@Setter +public class MStringSelectionButton extends MPanel { + + private List<String> possible; + private int selectedIndex; + + private MButton dec; + private MButton inc; + private MLabel selected; + + @Getter + @Setter + private Runnable onUpdate; + + public MStringSelectionButton(final List<String> possible) { + this.possible = possible; + selectedIndex = 0; + + dec = new MButton(); dec.setText("<"); add(dec); + inc = new MButton(); inc.setText(">"); add(inc); + selected = new MLabel(); updateSelected(); add(selected); + + dec.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex++; + if (selectedIndex >= possible.size()) selectedIndex = 0; + updateSelected(); + onUpdate.run(); + } + }); + inc.setOnActionPerformed(new Runnable() { + @Override + public void run() { + selectedIndex --; + if (selectedIndex < 0) selectedIndex = possible.size() - 1; + updateSelected(); + onUpdate.run(); + } + }); + } + + public String getSelected() { + if (possible.size() == 0) return null; + return possible.get(selectedIndex); + } + + private void updateSelected() { + if (possible.size() == 0) selected.setText("-Empty-"); + else selected.setText(possible.get(selectedIndex)); + } + + @Override + public void onBoundsUpdate() { + dec.setBounds(new Rectangle(0,0,bounds.height, bounds.height)); + inc.setBounds(new Rectangle(bounds.width - bounds.height, 0, bounds.height, bounds.height)); + selected.setBounds(new Rectangle(bounds.height, 0, bounds.width - bounds.height - bounds.height, bounds.height)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java index 59620ff0..eec9a63b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/GeneralEditPane.java @@ -4,8 +4,10 @@ import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.roomprocessor.ProcessorFactory; import java.awt.*; +import java.util.ArrayList; public class GeneralEditPane extends MPanel { private DungeonRoom dungeonRoom; @@ -19,6 +21,8 @@ public class GeneralEditPane extends MPanel { private MButton save; + private MLabelAndElement roomProcessor; + public GeneralEditPane(final DungeonRoom dungeonRoom) { this.dungeonRoom = dungeonRoom; System.out.println("building"); @@ -66,9 +70,21 @@ System.out.println("building"); add(shape2); } { - System.out.println("roomdata"); + final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(ProcessorFactory.getProcessors())); + roomProcessor = new MLabelAndElement("Room Processor: ", mStringSelectionButton); + roomProcessor.setBounds(new Rectangle(0,100,bounds.width, 20)); + add(roomProcessor); + + mStringSelectionButton.setOnUpdate(new Runnable() { + @Override + public void run() { + dungeonRoom.getDungeonRoomInfo().setProcessorId(mStringSelectionButton.getSelected()); + dungeonRoom.updateRoomProcessor(); + } + }); + } + { if (dungeonRoom.getDungeonRoomInfo().isRegistered()) return; - System.out.println("roomdata"); save = new MButton(); save.setText("Save RoomData"); save.setOnActionPerformed(new Runnable() { @@ -79,8 +95,7 @@ System.out.println("building"); } }); save.setBackgroundColor(Color.green); - save.setBounds(new Rectangle(1,100,bounds.width-2, 20)); - System.out.println("roomdata"); + save.setBounds(new Rectangle(1,120,bounds.width-2, 20)); add(save); System.out.println(save.getBounds()); } @@ -94,6 +109,6 @@ System.out.println("building"); @Override public void onBoundsUpdate() { if (save != null) - save.setBounds(new Rectangle(0,100,bounds.width, 20)); + save.setBounds(new Rectangle(0,120,bounds.width, 20)); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java new file mode 100644 index 00000000..9edbcae9 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/DefaultRoomProcessor.java @@ -0,0 +1,29 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +public class DefaultRoomProcessor implements RoomProcessor { + + public DefaultRoomProcessor(DungeonRoom dungeonRoom) { + + } + + @Override + public void tick() { + + } + + @Override + public void drawScreen() { + + } + + public static class Generator implements RoomProcessorGenerator<DefaultRoomProcessor> { + @Override + public DefaultRoomProcessor createNew(DungeonRoom dungeonRoom) { + + DefaultRoomProcessor defaultRoomProcessor = new DefaultRoomProcessor(dungeonRoom); + return defaultRoomProcessor; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java new file mode 100644 index 00000000..d404a1e4 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/ProcessorFactory.java @@ -0,0 +1,27 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class ProcessorFactory { + private static Map<String, RoomProcessorGenerator> map = new HashMap<String, RoomProcessorGenerator>(); + + public static RoomProcessorGenerator getRoomProcessorGenerator(String processorId) { + return map.get(processorId); + } + + public static void registerRoomProcessor(String processorId, RoomProcessorGenerator generator) { + map.put(processorId, generator); + } + + public static Set<String> getProcessors() { + return map.keySet(); + } + + static { + registerRoomProcessor("default", new DefaultRoomProcessor.Generator()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java new file mode 100644 index 00000000..24e29332 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessor.java @@ -0,0 +1,8 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +public interface RoomProcessor { + void tick(); + void drawScreen(); +}
\ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java new file mode 100644 index 00000000..66e97051 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomprocessor/RoomProcessorGenerator.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.roomprocessor; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +public interface RoomProcessorGenerator<T extends RoomProcessor> { + T createNew(DungeonRoom dungeonRoom); +} |