diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide')
22 files changed, 356 insertions, 50 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java index 2d461d07..7e3318c7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/Action.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java index 7c14406d..b17625d7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionChangeState.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import lombok.Data; @@ -25,4 +25,8 @@ public class ActionChangeState implements Action{ set.addAll(dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName).getAction(state, dungeonRoom)); return set; } + @Override + public String toString() { + return "ChangeState\n\ttarget: "+mechanicName+"\n\tstate: "+state; + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java index 683cbc33..13e4ee76 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClick.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; import com.google.common.base.Predicate; import com.google.common.base.Predicates; @@ -24,4 +24,9 @@ public class ActionClick implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + @Override + public String toString() { + return "Click\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java index dff52b5d..454bfad3 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionClickSet.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java @@ -1,8 +1,7 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; 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; @@ -25,4 +24,9 @@ public class ActionClickSet implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + @Override + public String toString() { + return "ClickSet\n\ttargets size: "+target.getOffsetPointList().size()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java index 841ed121..ad2eb5e2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionDropItem.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java @@ -1,8 +1,11 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; +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; @@ -11,6 +14,7 @@ import java.util.Set; public class ActionDropItem implements Action { private Set<Action> preRequisite = new HashSet<Action>(); private OffsetPoint target; + private Predicate<ItemStack> predicate = Predicates.alwaysTrue(); public ActionDropItem(OffsetPoint target) { this.target = target; @@ -20,4 +24,9 @@ public class ActionDropItem implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + @Override + public String toString() { + return "DropItem\n\ttarget: "+target.toString()+"\n\tpredicate: "+predicate.getClass().getSimpleName(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java index 1603b52f..162d0345 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionKill.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java @@ -1,11 +1,10 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; 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; @@ -25,4 +24,9 @@ public class ActionKill implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + @Override + public String toString() { + return "KillEntity\n\ttarget: "+target.toString()+"\n\tradius: "+radius+"\n\tpredicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java index b0048c11..15bc9814 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMove.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java @@ -1,9 +1,8 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; 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; @@ -21,4 +20,10 @@ public class ActionMove implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + + @Override + public String toString() { + return "Move\n\ttarget: "+target.toString(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java index 4ed826e1..3e3f3016 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/action/ActionMoveNearestAir.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java @@ -1,4 +1,4 @@ -package kr.syeyoung.dungeonsguide.dungeon.mechanics.action; +package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; @@ -20,4 +20,9 @@ public class ActionMoveNearestAir implements Action { public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { return preRequisite; } + + @Override + public String toString() { + return "MoveNearestAir\n\ttarget: "+target.toString(); + } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java new file mode 100644 index 00000000..3d625371 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java @@ -0,0 +1,25 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionRoot implements Action { + private Set<Action> preRequisite = new HashSet<Action>(); + + public ActionRoot() { + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public String toString() { + return "Action Root"; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java new file mode 100644 index 00000000..1db6767c --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java @@ -0,0 +1,49 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions.tree; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionRoot; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import lombok.Data; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +@Data +public class ActionTree { + private ActionTree parent; + private Action current; + private Set<ActionTree> children; + + + public static ActionTree buildActionTree(Set<Action> actions, DungeonRoom dungeonRoom) { + ActionRoot root = new ActionRoot(); + root.setPreRequisite(actions); + ActionTree tree = new ActionTree(); + tree.setParent(null); + tree.setCurrent(root); + HashSet<ActionTree> set = new HashSet(); + for (Action action : actions) { + set.add(buildActionTree(tree, action, dungeonRoom, new HashMap<Action, ActionTree>())); + } + tree.setChildren(set); + return tree; + } + + private static ActionTree buildActionTree(ActionTree parent, Action action, DungeonRoom dungeonRoom, Map<Action, ActionTree> alreadyBuilt) { + if (action == null) return null; + if (alreadyBuilt.containsKey(action)) return alreadyBuilt.get(action); + + ActionTree tree = new ActionTree(); + alreadyBuilt.put(action, tree); + tree.setParent(parent); + tree.setCurrent(action); + HashSet<ActionTree> set = new HashSet(); + for (Action action2 : action.getPreRequisites(dungeonRoom)) { + set.add(buildActionTree(tree, action2, dungeonRoom, alreadyBuilt)); + } + tree.setChildren(set); + return tree; + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java index 6f56c800..fe89b7cb 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -2,10 +2,10 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java index 48c13367..cbf7520f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonDoor.java @@ -2,15 +2,14 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.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.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java index 9965e11d..9fe0165f 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java @@ -1,10 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionChangeState; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionClick; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.ActionMove; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClick; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; 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 31f03eac..a1180f02 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,6 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import java.awt.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java index 4c99fb94..3ee41f1b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java @@ -2,10 +2,10 @@ 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.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateSuperBoom; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java index 87e2b44d..d9b396f0 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java @@ -1,7 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClick; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java index d36c8cd2..da126215 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -1,7 +1,10 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionDropItem; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMove; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.action.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; import lombok.Data; 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 fe5ad8c7..e5b8d54a 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -1,21 +1,15 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.actions.*; 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 net.minecraft.block.Block; 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.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java index 5d9aa06d..ce74e955 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -1,22 +1,18 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; -import com.google.common.base.Predicate; +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionChangeState; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionClickSet; +import kr.syeyoung.dungeonsguide.dungeon.actions.ActionMoveNearestAir; 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.Block; -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.*; diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java index c332dd20..2c5a7b69 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/gui/GuiDungeonRoomEdit.java @@ -6,10 +6,7 @@ import kr.syeyoung.dungeonsguide.roomedit.elements.MButton; import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel; import kr.syeyoung.dungeonsguide.roomedit.elements.MTabbedPane; import kr.syeyoung.dungeonsguide.roomedit.elements.MTextField; -import kr.syeyoung.dungeonsguide.roomedit.panes.GeneralEditPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.ProcessorParameterEditPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.RoomDataDisplayPane; -import kr.syeyoung.dungeonsguide.roomedit.panes.SecretEditPane; +import kr.syeyoung.dungeonsguide.roomedit.panes.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; @@ -39,6 +36,7 @@ public class GuiDungeonRoomEdit extends GuiScreen { tabbedPane.addTab("General", new GeneralEditPane(room)); tabbedPane.addTab("Match", new RoomDataDisplayPane(room)); tabbedPane.addTab("Secrets", new SecretEditPane(room)); + tabbedPane.addTab("Actions", new ActionDisplayPane(room)); tabbedPane.addTab("Proc.Params", new ProcessorParameterEditPane(room)); this.tabbedPane = tabbedPane; } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java new file mode 100644 index 00000000..974e46b5 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionDisplayPane.java @@ -0,0 +1,72 @@ +package kr.syeyoung.dungeonsguide.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +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; +import java.util.Set; + +public class ActionDisplayPane extends MPanel { + private DungeonRoom dungeonRoom; + + private ActionTreeDisplayPane displayPane; + + private MTextField textField; + private MButton calculate; + public ActionDisplayPane(final DungeonRoom dungeonRoom) { + this.dungeonRoom = dungeonRoom; + + { + textField = new MTextField(); + textField.setBounds(new Rectangle(0,0,bounds.width - 100, 20)); + add(textField); + } + { + calculate = new MButton(); + calculate.setBounds(new Rectangle(bounds.width - 100,0,100, 20)); + calculate.setText("calculate"); + calculate.setOnActionPerformed(new Runnable() { + @Override + public void run() { + try { + remove(displayPane); + + String text = textField.getText(); + String target = text.split(":")[0]; + String state = text.split(":")[1]; + + DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(target); + Set<Action> actionSet = mechanic.getAction(state, dungeonRoom); + ActionTree tree= ActionTree.buildActionTree(actionSet, dungeonRoom); + + displayPane = new ActionTreeDisplayPane(dungeonRoom, tree); + displayPane.setBounds(new Rectangle(0,25,bounds.width,bounds.height-25)); + add(displayPane); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }); + add(calculate); + } + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10)); + } + + @Override + public void onBoundsUpdate() { + textField.setBounds(new Rectangle(0,0,bounds.width - 100, 20)); + calculate.setBounds(new Rectangle(bounds.width - 100,0,100, 20)); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java new file mode 100644 index 00000000..20c5242d --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/panes/ActionTreeDisplayPane.java @@ -0,0 +1,131 @@ +package kr.syeyoung.dungeonsguide.roomedit.panes; + +import kr.syeyoung.dungeonsguide.dungeon.actions.Action; +import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionTree; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.roomedit.MPanel; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.*; + +public class ActionTreeDisplayPane extends MPanel { + + private int offsetX = 0; + private int offsetY = 0; + + private DungeonRoom dungeonRoom; + private ActionTree tree; + public ActionTreeDisplayPane(DungeonRoom dungeonRoom, ActionTree tree) { + this.dungeonRoom = dungeonRoom; + this.tree = tree; + } + + @Override + public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) { + ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); + + FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + + GL11.glPushMatrix(); + GL11.glTranslated(-offsetX, -offsetY, 0); + renderTree(tree, 5, 5, Minecraft.getMinecraft().fontRendererObj, null, new HashMap<ActionTree, Point>()); + GL11.glPopMatrix(); + } + + public int renderTree(ActionTree actionTree, int x, int y, FontRenderer fr, Point drawLineFrom, HashMap<ActionTree, Point> drawmPoints) { + if (drawmPoints.containsKey(actionTree)) { + // recursive, fu + Point pt = drawmPoints.get(actionTree); + + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer(); + GlStateManager.color(255,0,0, 255); + renderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + renderer.pos(pt.x, pt.y, 0).endVertex(); + renderer.pos(drawLineFrom.x, drawLineFrom.y, 0).endVertex(); + Tessellator.getInstance().draw(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + return 0; + } + + Dimension dim = renderAction(actionTree.getCurrent(), x, y, fr); + if (drawLineFrom != null) { + GlStateManager.pushMatrix(); + GlStateManager.pushAttrib(); + WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer(); + GlStateManager.color(255,255,255, 255); + renderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); + renderer.pos(x + dim.width, y, 0).endVertex(); + renderer.pos(drawLineFrom.x, drawLineFrom.y, 0).endVertex(); + Tessellator.getInstance().draw(); + GlStateManager.popMatrix(); + GlStateManager.popAttrib(); + } + Point pt = new Point(x + dim.width / 2, y + dim.height); + + drawmPoints.put(actionTree, new Point(x + dim.width / 2, y + dim.height / 2)); + int xOff = 0; + for (ActionTree tree:actionTree.getChildren()) { + xOff += renderTree(tree, x + xOff, y + dim.height + 10, fr, pt, drawmPoints) + 10; + } + return xOff; + } + + public Dimension renderAction(Action action, int x, int y, FontRenderer fr) { + String[] lines = action.toString().split("\n"); + int maxWidth = 0; + for (String line : lines) { + if (fr.getStringWidth(line) > maxWidth) maxWidth= fr.getStringWidth(line); + } + int offset = 2; + int height = (fr.FONT_HEIGHT + offset) * lines.length; + + Gui.drawRect(x,y,x + maxWidth +10, y + height + 10, 0xff000000); + Gui.drawRect(x+1,y+1,x + maxWidth +8, y + height + 8, 0xff4d4d4d); + for (int i = 0; i < lines.length; i++) { + fr.drawString(lines[i], 5, 5 + i*(fr.FONT_HEIGHT + offset), 0xffffffff); + } + + return new Dimension(maxWidth + 10, height + 10); + } + + @Override + public void resize(int parentWidth, int parentHeight) { + this.setBounds(new Rectangle(0,25,parentWidth,parentHeight-25)); + } + + + private int lastX; + private int lastY; + @Override + public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) { + lastX = absMouseX; + lastY = absMouseY; + } + + @Override + public void mouseClickMove(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int clickedMouseButton, long timeSinceLastClick) { + int dX = absMouseX - lastX; + int dY = absMouseY - lastY; + offsetX += dX; + offsetY += dY; + lastX = absMouseX; + lastY = absMouseY; + } +} |