aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java9
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java32
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java29
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java28
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionRoot.java25
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/tree/ActionTree.java49
10 files changed, 300 insertions, 0 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java
new file mode 100644
index 00000000..7e3318c7
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java
@@ -0,0 +1,9 @@
+package kr.syeyoung.dungeonsguide.dungeon.actions;
+
+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/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java
new file mode 100644
index 00000000..b17625d7
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java
@@ -0,0 +1,32 @@
+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 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;
+ }
+ @Override
+ public String toString() {
+ return "ChangeState\n\ttarget: "+mechanicName+"\n\tstate: "+state;
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java
new file mode 100644
index 00000000..13e4ee76
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClick.java
@@ -0,0 +1,32 @@
+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;
+
+@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;
+ }
+
+ @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/actions/ActionClickSet.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
new file mode 100644
index 00000000..454bfad3
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionClickSet.java
@@ -0,0 +1,32 @@
+package kr.syeyoung.dungeonsguide.dungeon.actions;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+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;
+ }
+
+ @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/actions/ActionDropItem.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java
new file mode 100644
index 00000000..ad2eb5e2
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionDropItem.java
@@ -0,0 +1,32 @@
+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;
+
+@Data
+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;
+ }
+
+ @Override
+ 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/actions/ActionKill.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java
new file mode 100644
index 00000000..162d0345
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionKill.java
@@ -0,0 +1,32 @@
+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 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;
+ }
+
+ @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/actions/ActionMove.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
new file mode 100644
index 00000000..15bc9814
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMove.java
@@ -0,0 +1,29 @@
+package kr.syeyoung.dungeonsguide.dungeon.actions;
+
+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 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;
+ }
+
+
+ @Override
+ public String toString() {
+ return "Move\n\ttarget: "+target.toString();
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
new file mode 100644
index 00000000..3e3f3016
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionMoveNearestAir.java
@@ -0,0 +1,28 @@
+package kr.syeyoung.dungeonsguide.dungeon.actions;
+
+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;
+ }
+
+ @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;
+ }
+}