diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-12 18:33:55 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-12 18:33:55 +0900 |
commit | bbbf49cef6d8ed46b3fc5d69ff880137e62084de (patch) | |
tree | e141602a5cee61ace54dda0f68288dc531cb9ef8 /src/main/java/kr | |
parent | 75aa91678c2dfdf844ecfcbb68bcf9389028ca4e (diff) | |
download | Skyblock-Dungeons-Guide-bbbf49cef6d8ed46b3fc5d69ff880137e62084de.tar.gz Skyblock-Dungeons-Guide-bbbf49cef6d8ed46b3fc5d69ff880137e62084de.tar.bz2 Skyblock-Dungeons-Guide-bbbf49cef6d8ed46b3fc5d69ff880137e62084de.zip |
secrets!
Diffstat (limited to 'src/main/java/kr')
22 files changed, 724 insertions, 13 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java index 592049e7..a3c2be2c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java @@ -7,6 +7,7 @@ import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonAddSet; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonParameterEdit; import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonRoomEdit; +import kr.syeyoung.dungeonsguide.roomedit.gui.GuiDungeonValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomprocessor.RoomProcessor; import kr.syeyoung.dungeonsguide.utils.MapUtils; @@ -187,8 +188,8 @@ public class EventListener { if (valueEdit != null) { valueEdit.renderWorld(renderWorldLastEvent.partialTicks); } - } else if (guiScreen instanceof GuiDungeonOffsetPointEdit) { - ValueEdit valueEdit = ((GuiDungeonOffsetPointEdit) guiScreen).getValueEdit(); + } else if (guiScreen instanceof GuiDungeonValueEdit) { + ValueEdit valueEdit = ((GuiDungeonValueEdit) guiScreen).getValueEdit(); if (valueEdit != null) { valueEdit.renderWorld(renderWorldLastEvent.partialTicks); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java new file mode 100644 index 00000000..75364b36 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -0,0 +1,80 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionMoveNearestAir; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.*; +import java.util.List; + +@Data +public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { + private OffsetPointSet secretPoint = new OffsetPointSet(); + private List<String> preRequisite = new ArrayList<String>(); + + + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!"broken".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for breakable wall"); + if (!isBlocking(dungeonRoom)) { + return Collections.emptySet(); + } + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + { + ActionClickSet actionClick; + preRequisites.add(actionClick = new ActionClickSet(secretPoint)); + actionClick.setPredicate(PredicateSuperBoom.INSTANCE); + preRequisites = actionClick.getPreRequisite(); + } + { + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(secretPoint.getOffsetPointList().get(0)); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + } + return base; + } + + @Override + public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { + if (secretPoint.getOffsetPointList().isEmpty()) return; + OffsetPoint firstpt = secretPoint.getOffsetPointList().get(0); + BlockPos pos = firstpt.getBlockPos(dungeonRoom); + RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFF000000, 2f, true, false, partialTicks); + + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), color,partialTicks); + } + } + + @Override + public boolean isBlocking(DungeonRoom dungeonRoom) { + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + if (offsetPoint.getBlock(dungeonRoom) != Blocks.air) return true; + } + return false; + } + + public DungeonBreakableWall clone() throws CloneNotSupportedException { + DungeonBreakableWall dungeonSecret = new DungeonBreakableWall(); + dungeonSecret.secretPoint = (OffsetPointSet) secretPoint.clone(); + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); + return dungeonSecret; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java index 2af93795..851803ef 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonMechanic.java @@ -1,6 +1,13 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +import java.awt.*; +import java.util.Set; public interface DungeonMechanic { + Set<Action> getAction(String state, DungeonRoom dungeonRoom); + + void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java index 06992387..c1c717e0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -1,20 +1,32 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import kr.syeyoung.dungeonsguide.DungeonsGuide; +import com.google.common.base.Predicate; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateBat; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; -import lombok.Getter; -import lombok.Setter; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; @Data public class DungeonSecret implements DungeonMechanic { private OffsetPoint secretPoint = new OffsetPoint(0,0,0); private SecretType secretType = SecretType.CHEST; + private List<String> preRequisite = new ArrayList<String>(); public SecretStatus getSecretStatus(DungeonRoom dungeonRoom) { if (secretType == SecretType.CHEST) { @@ -37,6 +49,43 @@ public class DungeonSecret implements DungeonMechanic { } } + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!"claimed".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + if (secretType == SecretType.CHEST) { + ActionClick actionClick; + preRequisites.add(actionClick = new ActionClick(secretPoint)); + preRequisites = actionClick.getPreRequisite(); + } else if (secretType == SecretType.BAT) { + ActionKill actionKill; + preRequisites.add(actionKill = new ActionKill(secretPoint)); + actionKill.setPredicate(PredicateBat.INSTANCE); + preRequisites = actionKill.getPreRequisite(); + } + { + ActionMove actionMove = new ActionMove(secretPoint); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + } + return base; + } + + @Override + public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { + BlockPos pos = getSecretPoint().getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, color,partialTicks); + RenderUtils.drawTextAtWorld(getSecretType().name(), pos.getX() +0.5f, pos.getY()+1f, pos.getZ()+0.5f, 0xFF000000, 2f, true, false, partialTicks); + RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFF000000, 2f, true, false, partialTicks); + } + public static enum SecretType { BAT, CHEST, ITEM_DROP } @@ -49,6 +98,7 @@ public class DungeonSecret implements DungeonMechanic { DungeonSecret dungeonSecret = new DungeonSecret(); dungeonSecret.secretPoint = (OffsetPoint) secretPoint.clone(); dungeonSecret.secretType = secretType; + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); return dungeonSecret; } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java new file mode 100644 index 00000000..55b79e59 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -0,0 +1,84 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.BlockPos; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.*; +import java.util.List; + +@Data +public class DungeonTomb implements DungeonMechanic, RouteBlocker { + private OffsetPointSet secretPoint = new OffsetPointSet(); + private List<String> preRequisite = new ArrayList<String>(); + + + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!"broken".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for tomb"); + if (!isBlocking(dungeonRoom)) { + return Collections.emptySet(); + } + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + { + ActionClickSet actionClick; + preRequisites.add(actionClick = new ActionClickSet(secretPoint)); + actionClick.setPredicate(PredicateSuperBoom.INSTANCE); + preRequisites = actionClick.getPreRequisite(); + } + { + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(secretPoint.getOffsetPointList().get(0)); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + } + return base; + } + + @Override + public void highlight(Color color, String name, DungeonRoom dungeonRoom, float partialTicks) { + if (secretPoint.getOffsetPointList().isEmpty()) return; + OffsetPoint firstpt = secretPoint.getOffsetPointList().get(0); + BlockPos pos = firstpt.getBlockPos(dungeonRoom); + RenderUtils.drawTextAtWorld(name, pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFF000000, 2f, true, false, partialTicks); + + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + RenderUtils.highlightBlock(offsetPoint.getBlockPos(dungeonRoom), color,partialTicks); + } + } + + @Override + public boolean isBlocking(DungeonRoom dungeonRoom) { + for (OffsetPoint offsetPoint : secretPoint.getOffsetPointList()) { + if (offsetPoint.getBlock(dungeonRoom) != Blocks.air) return true; + } + return false; + } + + public DungeonTomb clone() throws CloneNotSupportedException { + DungeonTomb dungeonSecret = new DungeonTomb(); + dungeonSecret.secretPoint = (OffsetPointSet) secretPoint.clone(); + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); + return dungeonSecret; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java new file mode 100644 index 00000000..24388d8a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/RouteBlocker.java @@ -0,0 +1,7 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +public interface RouteBlocker { + boolean isBlocking(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java new file mode 100644 index 00000000..2d461d07 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java @@ -0,0 +1,9 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; + +import java.util.Set; + +public interface Action { + Set<Action> getPreRequisites(DungeonRoom dungeonRoom); +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java new file mode 100644 index 00000000..7c14406d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java @@ -0,0 +1,28 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionChangeState implements Action{ + private Set<Action> preRequisite2 = new HashSet<Action>(); + + private String mechanicName; + private String state; + + public ActionChangeState(String mechanicName, String state) { + this.mechanicName = mechanicName; + this.state = state; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + Set<Action> set = new HashSet<Action>(); + set.addAll(preRequisite2); + set.addAll(dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName).getAction(state, dungeonRoom)); + return set; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java new file mode 100644 index 00000000..683cbc33 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java @@ -0,0 +1,27 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionClick implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); + + public ActionClick(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java new file mode 100644 index 00000000..dff52b5d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java @@ -0,0 +1,28 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionClickSet implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPointSet target; + private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); + + public ActionClickSet(OffsetPointSet target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java new file mode 100644 index 00000000..841ed121 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java @@ -0,0 +1,23 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionDropItem implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + + public ActionDropItem(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java new file mode 100644 index 00000000..1603b52f --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java @@ -0,0 +1,28 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionKill implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + private Predicate<Entity> predicate; + private int radius; + + public ActionKill(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java new file mode 100644 index 00000000..b0048c11 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java @@ -0,0 +1,24 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; +import net.minecraft.util.BlockPos; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionMove implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + + public ActionMove(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java new file mode 100644 index 00000000..4ed826e1 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java @@ -0,0 +1,23 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionMoveNearestAir implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + + public ActionMoveNearestAir(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java new file mode 100644 index 00000000..136efd0e --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateBat.java @@ -0,0 +1,17 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates; + +import com.google.common.base.Predicate; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import org.jetbrains.annotations.Nullable; + + +public class PredicateBat implements Predicate<Entity> { + + public static final PredicateBat INSTANCE = new PredicateBat(); + + @Override + public boolean apply(@Nullable Entity input) { + return input instanceof EntityBat; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java new file mode 100644 index 00000000..ccc1b017 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateSuperBoom.java @@ -0,0 +1,15 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates; + +import com.google.common.base.Predicate; +import net.minecraft.item.ItemStack; +import org.jetbrains.annotations.Nullable; + +public class PredicateSuperBoom implements Predicate<ItemStack> { + + public static final PredicateSuperBoom INSTANCE = new PredicateSuperBoom(); + + @Override + public boolean apply(@Nullable ItemStack input) { + return false; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java index b7605542..30d80f3d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonValueEdit.java @@ -29,6 +29,7 @@ public class GuiDungeonValueEdit extends GuiScreen { for (int i = 0; i < addons.size(); i++) { addons.get(i).setBounds(new Rectangle(0, bounds.height - (i+1) * 20 - 20, bounds.width, 20)); } + save.setBounds(new Rectangle(0 ,bounds.height - 20, bounds.width, 20)); } }; @@ -68,7 +69,7 @@ public class GuiDungeonValueEdit extends GuiScreen { save = new MButton(){ @Override public void resize(int parentWidth, int parentHeight) { - setBounds(new Rectangle(parentWidth ,parentHeight - 20, parentWidth, 20)); + setBounds(new Rectangle(0 ,parentHeight - 20, parentWidth, 20)); } }; save.setText("Go back"); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java new file mode 100644 index 00000000..fd7438af --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditBreakableWall.java @@ -0,0 +1,127 @@ +package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonBreakableWall; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.init.Blocks; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Collections; + +public class ValueEditBreakableWall extends MPanel implements ValueEdit<DungeonSecret> { + private Parameter parameter; + + // scroll pane + // just create + // add set + private DungeonBreakableWall dungeonBreakableWall; + + private MLabel label; + private MValue<OffsetPointSet> value; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; + private MButton updateOnlyAir; + + public ValueEditBreakableWall(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonBreakableWall = (DungeonBreakableWall) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Wall Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonBreakableWall.getSecretPoint(), Collections.emptyList()); + add(value); + + updateOnlyAir = new MButton(); + updateOnlyAir.setText("Update Air"); + updateOnlyAir.setBackgroundColor(Color.green); + updateOnlyAir.setForeground(Color.black); + updateOnlyAir.setBounds(new Rectangle(0,40,bounds.width, 20)); + add(updateOnlyAir); + updateOnlyAir.setOnActionPerformed(new Runnable() { + @Override + public void run() { + OffsetPointSet ofs = dungeonBreakableWall.getSecretPoint(); + List<OffsetPoint> filtered = new ArrayList<OffsetPoint>(); + for (OffsetPoint offsetPoint : ofs.getOffsetPointList()) { + if (offsetPoint.getBlock(EditingContext.getEditingContext().getRoom()) != Blocks.air) continue; + filtered.add(offsetPoint); + } + dungeonBreakableWall.getSecretPoint().setOffsetPointList(filtered); + } + }); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonBreakableWall.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonBreakableWall.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,bounds.width, 20)); + value.setBounds(new Rectangle(0,20,bounds.width, 20)); + updateOnlyAir.setBounds(new Rectangle(0,40,bounds.width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonBreakableWall.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator<ValueEditBreakableWall> { + + @Override + public ValueEditBreakableWall createValueEdit(Parameter parameter) { + return new ValueEditBreakableWall(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonSecret(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonSecret)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java index 368bf376..044a4b5c 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditSecret.java @@ -5,12 +5,11 @@ import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.roomedit.EditingContext; import kr.syeyoung.dungeonsguide.roomedit.MPanel; import kr.syeyoung.dungeonsguide.roomedit.Parameter; -import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; -import kr.syeyoung.dungeonsguide.roomedit.elements.MStringSelectionButton; -import kr.syeyoung.dungeonsguide.roomedit.elements.MValue; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.util.BlockPos; import scala.actors.threadpool.Arrays; @@ -28,6 +27,8 @@ public class ValueEditSecret extends MPanel implements ValueEdit<DungeonSecret> private MLabel label; private MValue<OffsetPoint> value; private MStringSelectionButton selectionButton; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; public ValueEditSecret(final Parameter parameter2) { this.parameter = parameter2; @@ -50,6 +51,17 @@ public class ValueEditSecret extends MPanel implements ValueEdit<DungeonSecret> } }); add(selectionButton); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonSecret.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonSecret.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); + add(preRequisite2); } @Override @@ -57,6 +69,7 @@ public class ValueEditSecret extends MPanel implements ValueEdit<DungeonSecret> label.setBounds(new Rectangle(0,0,bounds.width, 20)); value.setBounds(new Rectangle(0,20,bounds.width, 20)); selectionButton.setBounds(new Rectangle(0,40,bounds.width, 20)); + preRequisite2.setBounds(new Rectangle(0,60,bounds.width,20)); } @Override @@ -66,9 +79,7 @@ public class ValueEditSecret extends MPanel implements ValueEdit<DungeonSecret> @Override public void renderWorld(float partialTicks) { - BlockPos pos = dungeonSecret.getSecretPoint().getBlockPos(EditingContext.getEditingContext().getRoom()); - RenderUtils.highlightBlock(pos, new Color(0,255,0,50),partialTicks); - RenderUtils.drawTextAtWorld(dungeonSecret.getSecretType().name(), pos.getX() +0.5f, pos.getY()+0.5f, pos.getZ()+0.5f, 0xFF000000, 0.5f, false, false, partialTicks); + dungeonSecret.highlight(new Color(0,255,0,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java new file mode 100644 index 00000000..04150b19 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditTomb.java @@ -0,0 +1,104 @@ +package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonTomb; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.elements.*; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.util.BlockPos; +import scala.actors.threadpool.Arrays; + +import java.awt.*; +import java.util.Collections; + +public class ValueEditTomb extends MPanel implements ValueEdit<DungeonSecret> { + private Parameter parameter; + + // scroll pane + // just create + // add set + private DungeonTomb dungeonTomb; + + private MLabel label; + private MValue<OffsetPointSet> value; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; + + public ValueEditTomb(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonTomb = (DungeonTomb) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("Tomb Points"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonTomb.getSecretPoint(), Collections.emptyList()); + add(value); + + preRequisite = new MTextField() { + @Override + public void edit(String str) { + dungeonTomb.setPreRequisite(Arrays.asList(str.split(","))); + } + }; + preRequisite.setText(TextUtils.join(dungeonTomb.getPreRequisite(), ",")); + preRequisite2 = new MLabelAndElement("Req.",preRequisite); + preRequisite2.setBounds(new Rectangle(0,40,bounds.width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,bounds.width, 20)); + value.setBounds(new Rectangle(0,20,bounds.width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,bounds.width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonTomb.highlight(new Color(0,255,255,50), parameter.getName(), EditingContext.getEditingContext().getRoom(), partialTicks); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,0,parentWidth, parentHeight)); + } + + public static class Generator implements ValueEditCreator<ValueEditTomb> { + + @Override + public ValueEditTomb createValueEdit(Parameter parameter) { + return new ValueEditTomb(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonSecret(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonSecret)object).clone(); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assert false; + return null; + } + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java index ef2a7b0d..c53ec5e7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java @@ -2,8 +2,12 @@ package kr.syeyoung.dungeonsguide.roomedit.valueedit; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPointSet; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonBreakableWall; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonTomb; +import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditBreakableWall; import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditSecret; +import kr.syeyoung.dungeonsguide.roomedit.mechanicedit.ValueEditTomb; import java.util.ArrayList; import java.util.HashMap; @@ -31,5 +35,7 @@ public class ValueEditRegistry { valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); + valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); + valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java index ee4d056c..d56584c3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/TextUtils.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.utils; import java.text.DecimalFormat; +import java.util.List; import java.util.regex.Pattern; public class TextUtils { @@ -22,4 +23,14 @@ public class TextUtils { return INTEGER_CHARACTERS.matcher(text).replaceAll(""); } + public static String join(List list, String delimeter) { + if (list.isEmpty()) return ""; + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < list.size() - 1; i++) { + stringBuilder.append(list.get(i).toString()).append(delimeter); + } + stringBuilder.append(list.get(list.size() - 1).toString()); + return stringBuilder.toString(); + } + }
\ No newline at end of file |