private void setPortal(Portal portal) { switch (portal.getColor()) { case BLUE: bluePortal = portal; break; case ORANGE: orangePortal = portal; break; default: throw new NoSuchElementException(portal.getColor() + " is not a valid PortalColor"); } }
/** Creates a Portal of the specified color */ private void createPortal(PortalColor color) { Portal portal = getPortal(color); if (portal == null) { portal = new Portal(level, raycast.getPosition(), color, raycast.getPortalNormal()); level.add(portal); setPortal(portal); linkPortals(); } else { portal.setPosition(raycast.getPosition()); portal.setNormal(raycast.getPortalNormal()); } }
public boolean arePortalsLinked() { return orangePortal != null && orangePortal.isLinked() && bluePortal != null && bluePortal.isLinked(); }
/** * Sets the opposite portal of both portals. * * @see Portal#oppositePortal */ protected void linkPortals() { if (orangePortal != null && bluePortal != null) { bluePortal.setOppositePortal(orangePortal); orangePortal.setOppositePortal(bluePortal); } }