diff options
Diffstat (limited to 'src/main/java/kr')
16 files changed, 461 insertions, 29 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java index 16cd7ab0..85897a9b 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/AbstractAction.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -26,6 +27,11 @@ public abstract class AbstractAction implements Action { } @Override + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event) { + + } + + @Override public void onTick(DungeonRoom dungeonRoom) { } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java index 496439b8..fc77c192 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/Action.java @@ -1,6 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -10,6 +11,7 @@ public interface Action { Set<Action> getPreRequisites(DungeonRoom dungeonRoom); void onPlayerInteract(DungeonRoom dungeonRoom, PlayerInteractEvent event); + void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event); void onLivingDeath(DungeonRoom dungeonRoom, LivingDeathEvent event); void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks); void onRenderScreen(DungeonRoom dungeonRoom, float partialTicks); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java index 0a897ddd..fb1b76d7 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionChangeState.java @@ -1,5 +1,6 @@ package kr.syeyoung.dungeonsguide.dungeon.actions; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; @@ -39,10 +40,14 @@ public class ActionChangeState extends AbstractAction{ @Override public boolean isComplete(DungeonRoom dungeonRoom) { DungeonMechanic mechanic = dungeonRoom.getDungeonRoomInfo().getMechanics().get(mechanicName); + if (state.equalsIgnoreCase("navigate")) + return true; if (mechanic== null) return false; if (mechanic instanceof DungeonSecret && ((DungeonSecret) mechanic).getSecretType() != DungeonSecret.SecretType.CHEST) return true; + if (mechanic instanceof DungeonFairySoul) + return true; return mechanic.getCurrentState(dungeonRoom).equalsIgnoreCase(state); } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java new file mode 100755 index 00000000..b3be996a --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/actions/ActionInteract.java @@ -0,0 +1,62 @@ +package kr.syeyoung.dungeonsguide.dungeon.actions; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import kr.syeyoung.dungeonsguide.dungeon.EntitySpawnManager; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.events.PlayerInteractEntityEvent; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.Data; +import net.minecraft.entity.Entity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; + +import java.awt.*; +import java.util.HashSet; +import java.util.Set; + +@Data +public class ActionInteract extends AbstractAction { + private Set<Action> preRequisite = new HashSet<Action>(); + private OffsetPoint target; + private Predicate<Entity> predicate = Predicates.alwaysFalse(); + private int radius; + + public ActionInteract(OffsetPoint target) { + this.target = target; + } + + @Override + public Set<Action> getPreRequisites(DungeonRoom dungeonRoom) { + return preRequisite; + } + + @Override + public boolean isComplete(DungeonRoom dungeonRoom) { + return interacted; + } + + private boolean interacted = false; + @Override + public void onLivingInteract(DungeonRoom dungeonRoom, PlayerInteractEntityEvent event) { + if (interacted) return; + + Vec3 spawnLoc = EntitySpawnManager.getSpawnLocation().get(event.getEntity().getEntityId()); + if (spawnLoc == null) return; + if (target.getBlockPos(dungeonRoom).distanceSq(spawnLoc.xCoord, spawnLoc.yCoord, spawnLoc.zCoord) > radius * radius) return; + if (!predicate.apply(event.getEntity())) return; + interacted = true; + } + @Override + public void onRenderWorld(DungeonRoom dungeonRoom, float partialTicks) { + BlockPos pos = target.getBlockPos(dungeonRoom); + RenderUtils.highlightBlock(pos, new Color(0, 255,255,50),partialTicks, true); + RenderUtils.drawTextAtWorld("Interact", pos.getX() + 0.5f, pos.getY() + 0.3f, pos.getZ() + 0.5f, 0xFFFFFF00, 0.02f, false, false, partialTicks); + } + + @Override + public String toString() { + return "InteractEntity\n- target: "+target.toString()+"\n- radius: "+radius+"\n- predicate: "+(predicate == null ? "null" : predicate.getClass().getSimpleName()); + } +} 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 b2577371..9b32802f 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonBreakableWall.java @@ -24,6 +24,20 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } + if (!"open".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for breakable wall"); if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); @@ -89,7 +103,7 @@ public class DungeonBreakableWall implements DungeonMechanic, RouteBlocker { @Override public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { - return isBlocking(dungeonRoom) ? Collections.singleton("open") : Collections.<String>emptySet(); + return isBlocking(dungeonRoom) ? Sets.newHashSet("navigate", "open") : Sets.newHashSet("navigate"); } @Override diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java new file mode 100755 index 00000000..5f619089 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonFairySoul.java @@ -0,0 +1,89 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics; + +import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.dungeon.actions.*; +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateArmorStand; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates.PredicateBat; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.utils.RenderUtils; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.Getter; +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.BlockPos; + +import java.awt.*; +import java.util.List; +import java.util.*; + +@Data +public class DungeonFairySoul implements DungeonMechanic { + private OffsetPoint secretPoint = new OffsetPoint(0,0,0); + private List<String> preRequisite = new ArrayList<String>(); + + + @Override + public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (!"navigate".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + { + ActionInteract actionClick= new ActionInteract(secretPoint); + actionClick.setPredicate(PredicateArmorStand.INSTANCE); + actionClick.setRadius(3); + preRequisites.add(actionClick); + preRequisites = actionClick.getPreRequisite(); + } + { + ActionMove actionMove = new ActionMove(secretPoint); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + } + { + for (String str : preRequisite) { + if (str.isEmpty()) continue; + 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("F-"+name, pos.getX() +0.5f, pos.getY()+0.375f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + RenderUtils.drawTextAtWorld(getCurrentState(dungeonRoom), pos.getX() +0.5f, pos.getY()+0f, pos.getZ()+0.5f, 0xFFFFFFFF, 0.03f, false, true, partialTicks); + } + + + public DungeonFairySoul clone() throws CloneNotSupportedException { + DungeonFairySoul dungeonSecret = new DungeonFairySoul(); + dungeonSecret.secretPoint = (OffsetPoint) secretPoint.clone(); + dungeonSecret.preRequisite = new ArrayList<String>(preRequisite); + return dungeonSecret; + } + + + @Override + public String getCurrentState(DungeonRoom dungeonRoom) { + return "no-state"; + } + + @Override + public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { + return Sets.newHashSet("navigate"); + } + @Override + public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { + return Sets.newHashSet("no-state","navigate"); + } + @Override + public OffsetPoint getRepresentingPoint() { + return secretPoint; + } +} 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 a87d21fc..787208cc 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonLever.java @@ -1,11 +1,8 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; +import kr.syeyoung.dungeonsguide.dungeon.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; -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; @@ -23,6 +20,20 @@ public class DungeonLever implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } + if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); @@ -84,10 +95,10 @@ public class DungeonLever implements DungeonMechanic { public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { String currentStatus = getCurrentState(dungeonRoom); if (currentStatus.equalsIgnoreCase("untriggered")) - return Collections.singleton("triggered"); + return Sets.newHashSet("navigate", "triggered"); else if (currentStatus.equalsIgnoreCase("triggered")) - return Collections.singleton("untriggered"); - return Collections.emptySet(); + return Sets.newHashSet("navigate","untriggered"); + return Sets.newHashSet("navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { 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 ca7ca9e3..2e279b64 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayDoor.java @@ -26,6 +26,19 @@ public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } if (!("open".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for door"); if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); @@ -80,8 +93,8 @@ public class DungeonOnewayDoor implements DungeonMechanic, RouteBlocker { public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { String currentStatus = getCurrentState(dungeonRoom); if (currentStatus.equalsIgnoreCase("closed")) - return Collections.singleton("open"); - return Collections.emptySet(); + return Sets.newHashSet("navigate", "open"); + return Sets.newHashSet("navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { 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 dc9b6fcb..926c989d 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonOnewayLever.java @@ -1,10 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -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.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; @@ -23,6 +20,19 @@ public class DungeonOnewayLever implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } if (!("triggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); @@ -84,8 +94,8 @@ public class DungeonOnewayLever implements DungeonMechanic { public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { String currentStatus = getCurrentState(dungeonRoom); if (currentStatus.equalsIgnoreCase("untriggered")) - return Collections.singleton("triggered"); - return Collections.emptySet(); + return Sets.newHashSet("navigate", "triggered"); + return Sets.newHashSet("navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { 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 2677bc3b..3574c8c9 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonPressurePlate.java @@ -1,10 +1,7 @@ package kr.syeyoung.dungeonsguide.dungeon.mechanics; import com.google.common.collect.Sets; -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.actions.*; import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.utils.RenderUtils; @@ -23,6 +20,19 @@ public class DungeonPressurePlate implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } if (!("triggered".equalsIgnoreCase(state) || "untriggered".equalsIgnoreCase(state))) throw new IllegalArgumentException(state+" is not valid state for secret"); if (state.equalsIgnoreCase(getCurrentState(dungeonRoom))) return Collections.emptySet(); @@ -86,10 +96,10 @@ public class DungeonPressurePlate implements DungeonMechanic { public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { String currentStatus = getCurrentState(dungeonRoom); if (currentStatus.equalsIgnoreCase("triggered")) - return Collections.singleton("untriggered"); + return Sets.newHashSet("navigate", "untriggered"); else if (currentStatus.equalsIgnoreCase("untriggered")) - return Collections.singleton("triggered"); - return Collections.emptySet(); + return Sets.newHashSet("navigate", "triggered"); + return Sets.newHashSet("navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { 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 c12c066e..958cd286 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonSecret.java @@ -47,6 +47,19 @@ public class DungeonSecret implements DungeonMechanic { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } if (!"found".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for secret"); Set<Action> base; Set<Action> preRequisites = base = new HashSet<Action>(); @@ -114,8 +127,8 @@ public class DungeonSecret implements DungeonMechanic { @Override public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { SecretStatus status = getSecretStatus(dungeonRoom); - if (status == SecretStatus.FOUND) return Collections.emptySet(); - else return Collections.singleton("found"); + if (status == SecretStatus.FOUND) return Sets.newHashSet("navigate"); + else return Sets.newHashSet("found", "navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { 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 26f8f5f9..0f84d164 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/DungeonTomb.java @@ -24,6 +24,19 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { @Override public Set<Action> getAction(String state, DungeonRoom dungeonRoom) { + if (state.equalsIgnoreCase("navigate")) { + Set<Action> base; + Set<Action> preRequisites = base = new HashSet<Action>(); + ActionMoveNearestAir actionMove = new ActionMoveNearestAir(getRepresentingPoint()); + preRequisites.add(actionMove); + preRequisites = actionMove.getPreRequisite(); + for (String str : preRequisite) { + if (str.isEmpty()) continue; + ActionChangeState actionChangeState = new ActionChangeState(str.split(":")[0], str.split(":")[1]); + preRequisites.add(actionChangeState); + } + return base; + } if (!"open".equalsIgnoreCase(state)) throw new IllegalArgumentException(state+" is not valid state for tomb"); if (!isBlocking(dungeonRoom)) { return Collections.emptySet(); @@ -88,7 +101,7 @@ public class DungeonTomb implements DungeonMechanic, RouteBlocker { @Override public Set<String> getPossibleStates(DungeonRoom dungeonRoom) { - return isBlocking(dungeonRoom) ? Collections.singleton("open") : Collections.<String>emptySet(); + return isBlocking(dungeonRoom) ? Sets.newHashSet("open", "navigate") : Sets.newHashSet("navigate"); } @Override public Set<String> getTotalPossibleStates(DungeonRoom dungeonRoom) { diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java new file mode 100755 index 00000000..d0f7b0fb --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/mechanics/predicates/PredicateArmorStand.java @@ -0,0 +1,27 @@ +package kr.syeyoung.dungeonsguide.dungeon.mechanics.predicates; + +import com.google.common.base.Predicate; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.passive.EntityBat; +import org.jetbrains.annotations.Nullable; + + +public class PredicateArmorStand implements Predicate<Entity> { + + public static final PredicateArmorStand INSTANCE = new PredicateArmorStand(); + + @Override + public boolean apply(@Nullable Entity input) { + return input instanceof EntityArmorStand; + } + + @Override + public int hashCode() { + return 0; + } + @Override + public boolean equals(Object o) { + return o == this || o != null && (o.getClass() == this.getClass()); + } +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java index ac730878..daa3c0e8 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/secret/FeatureMechanicBrowse.java @@ -3,7 +3,7 @@ package kr.syeyoung.dungeonsguide.features.impl.secret; import kr.syeyoung.dungeonsguide.SkyblockStatus; import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; import kr.syeyoung.dungeonsguide.dungeon.actions.tree.ActionRoute; -import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonMechanic; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.*; import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.GuiFeature; @@ -115,6 +115,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi private int dy = 0; private int selected = -1; + private int selectedState = -1; private List<Object> sortedMechanics = new ArrayList<Object>(); private void setupMechanics() { sortedMechanics.clear(); @@ -129,13 +130,61 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi if (dungeonRoom == null) return; if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + boolean found = false; for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) { - value. + if (value instanceof DungeonDoor) { + if (!found) { + sortedMechanics.add("Fairy Souls"); + found = true; + } + sortedMechanics.add(value); + } + } + found = false; + for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) { + if (value instanceof DungeonSecret) { + if (!found) { + sortedMechanics.add("Secrets"); + found = true; + } + sortedMechanics.add(value); + } + } + found = false; + for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) { + if (value instanceof DungeonTomb) { + if (!found) { + sortedMechanics.add("Crypts"); + found = true; + } + sortedMechanics.add(value); + } + } + found = false; + for (DungeonMechanic value : ((GeneralRoomProcessor) dungeonRoom.getRoomProcessor()).getDungeonRoom().getDungeonRoomInfo().getMechanics().values()) { + if (value instanceof DungeonDoor || value instanceof DungeonBreakableWall || value instanceof DungeonLever + || value instanceof DungeonOnewayDoor || value instanceof DungeonOnewayLever || value instanceof DungeonPressurePlate) { + if (!found) { + sortedMechanics.add("Walls & Doors & Levers & Pressure Plates"); + found = true; + } + sortedMechanics.add(value); + } } } @Override public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + if (!skyblockStatus.isOnDungeon()) return; + if (skyblockStatus.getContext() == null || !skyblockStatus.getContext().getMapProcessor().isInitialized()) return; + DungeonContext context = skyblockStatus.getContext(); + + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + Point roomPt = context.getMapProcessor().worldPointToRoomPoint(thePlayer.getPosition()); + DungeonRoom dungeonRoom = context.getRoomMapper().get(roomPt); + if (dungeonRoom == null) return; + if (!(dungeonRoom.getRoomProcessor() instanceof GeneralRoomProcessor)) return; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); @@ -144,6 +193,7 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi Rectangle feature = getFeatureRect(); FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; + Point popupStart = new Point(feature.x + feature.width, (selected - dy) * fr.FONT_HEIGHT + 7 + feature.y); if (feature.contains(mouseX, mouseY)) { mouseInputEvent.setCanceled(true); @@ -155,9 +205,14 @@ public class FeatureMechanicBrowse extends GuiFeature implements GuiPostRenderLi int yDiff = mouseY - feature.y - fr.FONT_HEIGHT - 7; selected = yDiff / fr.FONT_HEIGHT + dy; } - } else if (new Rectangle(feature.x + feature.width, (selected - dy) * fr.FONT_HEIGHT + 7 + feature.y, feature.x + feature.width + feature.width, (selected - dy) * fr.FONT_HEIGHT + 7 + feature.y + fr.FONT_HEIGHT).contains(mouseX, mouseY)) { + } else if (sortedMechanics.get(selected) instanceof DungeonMechanic && + new Rectangle(popupStart, new Dimension(feature.width, ((DungeonMechanic) sortedMechanics.get(selected)).getPossibleStates(dungeonRoom).size() * fr.FONT_HEIGHT + 6)).contains(mouseX, mouseY)) { mouseInputEvent.setCanceled(true); + if (Mouse.getEventButton() != -1) { + int yDiff = mouseY - popupStart.y - 2; + selected = yDiff / fr.FONT_HEIGHT + dy; + } } } } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java new file mode 100755 index 00000000..70da3b55 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/mechanicedit/ValueEditFairySoul.java @@ -0,0 +1,101 @@ +package kr.syeyoung.dungeonsguide.roomedit.mechanicedit; + +import kr.syeyoung.dungeonsguide.dungeon.data.OffsetPoint; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonFairySoul; +import kr.syeyoung.dungeonsguide.dungeon.mechanics.DungeonSecret; +import kr.syeyoung.dungeonsguide.gui.MPanel; +import kr.syeyoung.dungeonsguide.gui.elements.*; +import kr.syeyoung.dungeonsguide.roomedit.EditingContext; +import kr.syeyoung.dungeonsguide.roomedit.Parameter; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEdit; +import kr.syeyoung.dungeonsguide.roomedit.valueedit.ValueEditCreator; +import kr.syeyoung.dungeonsguide.utils.TextUtils; + +import java.awt.*; +import java.util.Arrays; +import java.util.Collections; + +public class ValueEditFairySoul extends MPanel implements ValueEdit<DungeonSecret> { + private Parameter parameter; + + // scroll pane + // just create + // add set + private DungeonFairySoul dungeonSecret; + + private MLabel label; + private MValue<OffsetPoint> value; + private MTextField preRequisite; + private MLabelAndElement preRequisite2; + + public ValueEditFairySoul(final Parameter parameter2) { + this.parameter = parameter2; + this.dungeonSecret = (DungeonFairySoul) parameter2.getNewData(); + + + label = new MLabel(); + label.setText("FairySoul Point"); + label.setAlignment(MLabel.Alignment.LEFT); + add(label); + + value = new MValue(dungeonSecret.getSecretPoint(), Collections.emptyList()); + add(value); + + 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,40,getBounds().width,20)); + add(preRequisite2); + } + + @Override + public void onBoundsUpdate() { + label.setBounds(new Rectangle(0,0,getBounds().width, 20)); + value.setBounds(new Rectangle(0,20,getBounds().width, 20)); + preRequisite2.setBounds(new Rectangle(0,40,getBounds().width,20)); + } + + @Override + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + @Override + public void renderWorld(float partialTicks) { + dungeonSecret.highlight(new Color(0,255,0,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<ValueEditFairySoul> { + + @Override + public ValueEditFairySoul createValueEdit(Parameter parameter) { + return new ValueEditFairySoul(parameter); + } + + @Override + public Object createDefaultValue(Parameter parameter) { + return new DungeonFairySoul(); + } + + @Override + public Object cloneObj(Object object) { + try { + return ((DungeonFairySoul)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 33c9d61b..a19dbb0c 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/valueedit/ValueEditRegistry.java @@ -36,6 +36,7 @@ public class ValueEditRegistry { valueEditMap.put(DungeonSecret.class.getName(), new ValueEditSecret.Generator()); + valueEditMap.put(DungeonFairySoul.class.getName(), new ValueEditFairySoul.Generator()); valueEditMap.put(DungeonTomb.class.getName(), new ValueEditTomb.Generator()); valueEditMap.put(DungeonBreakableWall.class.getName(), new ValueEditBreakableWall.Generator()); |