Browse Source

Runegates and portals now loaded from database.

master
MagicBot 2 years ago
parent
commit
2c0a46e652
  1. 66
      src/engine/Enum.java
  2. 73
      src/engine/db/handlers/dbRunegateHandler.java
  3. 12
      src/engine/devcmd/cmds/GateInfoCmd.java
  4. 2
      src/engine/gameManager/DbManager.java
  5. 2
      src/engine/gameManager/SimulationManager.java
  6. 10
      src/engine/jobs/CloseGateJob.java
  7. 14
      src/engine/net/client/ClientMessagePump.java
  8. 15
      src/engine/net/client/msg/WorldObjectMsg.java
  9. 92
      src/engine/objects/Portal.java
  10. 173
      src/engine/objects/Runegate.java
  11. 28
      src/engine/powers/poweractions/OpenGatePowerAction.java
  12. 15
      src/engine/powers/poweractions/RunegateTeleportPowerAction.java

66
src/engine/Enum.java

@ -9,7 +9,6 @@
package engine; package engine;
import ch.claude_martin.enumbitset.EnumBitSetHelper; import ch.claude_martin.enumbitset.EnumBitSetHelper;
import engine.gameManager.BuildingManager;
import engine.gameManager.PowersManager; import engine.gameManager.PowersManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector2f; import engine.math.Vector2f;
@ -18,7 +17,6 @@ import engine.objects.*;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
@ -561,74 +559,16 @@ public class Enum {
FORBID(0.0f, 0.0f, 0); FORBID(0.0f, 0.0f, 0);
public final Vector2f offset; public final Vector2f offset;
public final int bitFlag; public final int effectFlag;
PortalType(float offsetX, float offsetY, int bitFlag) { PortalType(float offsetX, float offsetY, int effectFlag) {
this.offset = new Vector2f(offsetX, offsetY); this.offset = new Vector2f(offsetX, offsetY);
this.bitFlag = bitFlag; this.effectFlag = effectFlag;
} }
} }
public enum RunegateType {
EARTH(6f, 19.5f, 128, 33213),
AIR(-6f, 19.5f, 256, 33170),
FIRE(15f, 7.5f, 512, 49612),
WATER(-15f, 8.5f, 1024, 53073),
SPIRIT(0, 10.5f, 2048, 33127),
CHAOS(22f, 3.5f, 8192, 58093),
OBLIV(0f, 42f, 16384, 60198),
MERCHANT(-22f, 4.5f, 4096, 60245),
FORBID(0.0f, 0.0f, 0, 54617);
private final Vector2f offset;
private final int bitFlag;
private final int buildingUUID;
RunegateType(float offsetX, float offsetY, int bitFlag,
int buildingUUID) {
this.offset = new Vector2f(offsetX, offsetY);
this.bitFlag = bitFlag;
this.buildingUUID = buildingUUID;
}
public Vector2f getOffset() {
return this.offset;
}
public int getEffectFlag() {
return this.bitFlag;
}
public int getGateUUID() {
return this.buildingUUID;
}
public Building getGateBuilding() {
return BuildingManager.getBuilding(this.buildingUUID);
}
public static RunegateType getGateTypeFromUUID(int uuid) {
RunegateType outType = RunegateType.AIR;
for (RunegateType gateType : RunegateType.values()) {
if (gateType.buildingUUID == uuid) {
outType = gateType;
return outType;
}
}
return outType;
}
}
// Enum for ItemBase flags // Enum for ItemBase flags

73
src/engine/db/handlers/dbRunegateHandler.java

@ -0,0 +1,73 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.db.handlers;
import engine.Enum;
import engine.gameManager.DbManager;
import engine.objects.Building;
import engine.objects.Portal;
import engine.objects.Resists;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class dbRunegateHandler extends dbHandlerBase {
public dbRunegateHandler() {
}
public ArrayList<Integer> GET_RUNEGATE_LIST() {
ArrayList<Integer> gateList = new ArrayList<>();
prepareCallable("SELECT DISTINCT `source_Building` FROM `static_runegate_portals`;");
try {
ResultSet rs = executeQuery();
if (rs.next()) {
gateList.add(rs.getInt("sourceBuilding"));
}
} catch (SQLException e) {
} finally {
closeCallable();
}
return gateList;
}
public ArrayList<Portal> GET_PORTAL_LIST(int gateUID) {
ArrayList<Portal> portalList = new ArrayList<>();
Building sourceBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateUID);
prepareCallable("SELECT * FROM `static_runegate_portals` WHERE `sourceBuilding` = ?;");
setInt(1, gateUID);
try {
ResultSet rs = executeQuery();
if (rs.next()) {
int targetBuildingID = rs.getInt("sourceBuilding");
Building targetBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, targetBuildingID);
Enum.PortalType portalType = Enum.PortalType.valueOf(rs.getString("portalType"));
Portal portal = new Portal(sourceBuilding, portalType, targetBuilding);
portalList.add(portal);
}
} catch (SQLException e) {
} finally {
closeCallable();
}
return portalList;
}
}

12
src/engine/devcmd/cmds/GateInfoCmd.java

@ -2,7 +2,6 @@ package engine.devcmd.cmds;
import engine.Enum.BuildingGroup; import engine.Enum.BuildingGroup;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.RunegateType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.*; import engine.objects.*;
@ -21,7 +20,6 @@ public class GateInfoCmd extends AbstractDevCmd {
Building targetBuilding; Building targetBuilding;
String outString; String outString;
RunegateType runegateType;
Runegate runeGate; Runegate runeGate;
Blueprint blueprint; Blueprint blueprint;
String newline = "\r\n "; String newline = "\r\n ";
@ -41,10 +39,10 @@ public class GateInfoCmd extends AbstractDevCmd {
return; return;
} }
runegateType = RunegateType.getGateTypeFromUUID(targetBuilding.getObjectUUID());
runeGate = Runegate.getRunegates()[runegateType.ordinal()];
outString = "RungateType: " + runegateType.name(); runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
outString = "RungateType: " + runeGate.gateBuilding.getName();
outString += newline; outString += newline;
outString += "Portal State:"; outString += "Portal State:";
@ -52,9 +50,9 @@ public class GateInfoCmd extends AbstractDevCmd {
for (Portal portal : runeGate.getPortals()) { for (Portal portal : runeGate.getPortals()) {
outString += "Portal: " + portal.getPortalType().name(); outString += "Portal: " + portal.portalType.name();
outString += " Active: " + portal.isActive(); outString += " Active: " + portal.isActive();
outString += " Dest: " + portal.getDestinationGateType().name(); outString += " Dest: " + portal.targetGate.getName();
outString += newline; outString += newline;
outString += " Origin: " + portal.getPortalLocation().x + 'x'; outString += " Origin: " + portal.getPortalLocation().x + 'x';
outString += " " + portal.getPortalLocation().y + 'y'; outString += " " + portal.getPortalLocation().y + 'y';

2
src/engine/gameManager/DbManager.java

@ -311,4 +311,6 @@ public enum DbManager {
public static final dbBoonHandler BoonQueries = new dbBoonHandler(); public static final dbBoonHandler BoonQueries = new dbBoonHandler();
public static final dbShrineHandler ShrineQueries = new dbShrineHandler(); public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler(); public static final dbHeightMapHandler HeightMapQueries = new dbHeightMapHandler();
public static final dbRunegateHandler RunegateQueries = new dbRunegateHandler();
} }

2
src/engine/gameManager/SimulationManager.java

@ -206,7 +206,7 @@ public enum SimulationManager {
*/ */
private void pulseRunegates() { private void pulseRunegates() {
for (Runegate runegate : Runegate.getRunegates()) { for (Runegate runegate : Runegate._runegates.values()) {
runegate.collidePortals(); runegate.collidePortals();
} }

10
src/engine/jobs/CloseGateJob.java

@ -9,7 +9,8 @@
package engine.jobs; package engine.jobs;
import engine.Enum.RunegateType; import engine.Enum;
import engine.Enum.PortalType;
import engine.job.AbstractScheduleJob; import engine.job.AbstractScheduleJob;
import engine.objects.Building; import engine.objects.Building;
import engine.objects.Runegate; import engine.objects.Runegate;
@ -18,9 +19,10 @@ import org.pmw.tinylog.Logger;
public class CloseGateJob extends AbstractScheduleJob { public class CloseGateJob extends AbstractScheduleJob {
private final Building building; private final Building building;
private final RunegateType portalType; private final Enum.PortalType portalType;
public CloseGateJob(Building building, PortalType portalType) {
public CloseGateJob(Building building, RunegateType portalType) {
super(); super();
this.building = building; this.building = building;
this.portalType = portalType; this.portalType = portalType;
@ -34,7 +36,7 @@ public class CloseGateJob extends AbstractScheduleJob {
return; return;
} }
Runegate.getRunegates()[RunegateType.getGateTypeFromUUID(building.getObjectUUID()).ordinal()].deactivatePortal(portalType); Runegate._runegates.get(building.getObjectUUID()).deactivatePortal(portalType);
} }
@Override @Override

14
src/engine/net/client/ClientMessagePump.java

@ -2183,23 +2183,17 @@ boolean updateCity = false;
Building rg = null; Building rg = null;
Vector3fImmutable rgLoc; Vector3fImmutable rgLoc;
for (Runegate runegate : Runegate.getRunegates()) { for (Runegate runegate : Runegate._runegates.values()) {
if ((runegate.getGateType() == RunegateType.OBLIV) || rgLoc = runegate.gateBuilding.getLoc();
(runegate.getGateType() == RunegateType.CHAOS))
continue;
for (Runegate thisGate : Runegate.getRunegates()) {
rgLoc = thisGate.getGateType().getGateBuilding().getLoc();
float distanceSquaredToRunegate = player.getLoc().distanceSquared2D(rgLoc); float distanceSquaredToRunegate = player.getLoc().distanceSquared2D(rgLoc);
if (distanceSquaredToRunegate < sqr(dist)) if (distanceSquaredToRunegate < sqr(dist))
rg = thisGate.getGateType().getGateBuilding(); rg = runegate.gateBuilding;
} }
}
//nearest runegate found. teleport characterTarget //nearest runegate found. teleport characterTarget
if (rg != null) { if (rg != null) {

15
src/engine/net/client/msg/WorldObjectMsg.java

@ -10,7 +10,6 @@
package engine.net.client.msg; package engine.net.client.msg;
import engine.Enum; import engine.Enum;
import engine.Enum.RunegateType;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.net.AbstractConnection; import engine.net.AbstractConnection;
import engine.net.ByteBufferReader; import engine.net.ByteBufferReader;
@ -128,11 +127,10 @@ public class WorldObjectMsg extends ClientNetMsg {
if (this.updateRunegates) { if (this.updateRunegates) {
writer.put((byte) 0); writer.put((byte) 0);
writer.putInt(RunegateType.values().length); writer.putInt(Runegate._runegates.values().size());
for(RunegateType gateType : engine.Enum.RunegateType.values()) { for(Runegate runegate : Runegate._runegates.values()) {
runegate._serializeForEnterWorld(writer);
Runegate.getRunegates()[gateType.ordinal()]._serializeForEnterWorld(writer);
} }
} else } else
writer.put((byte) 1); writer.put((byte) 1);
@ -210,11 +208,10 @@ public class WorldObjectMsg extends ClientNetMsg {
// Serialize runegates // Serialize runegates
temp.putInt(RunegateType.values().length); temp.putInt(Runegate._runegates.values().size());
for(RunegateType gateType : engine.Enum.RunegateType.values()) {
Runegate.getRunegates()[gateType.ordinal()]._serializeForEnterWorld(temp); for(Runegate runegate : Runegate._runegates.values()) {
runegate._serializeForEnterWorld(temp);
} }
ArrayList<Mine> mineList = new ArrayList<>(); ArrayList<Mine> mineList = new ArrayList<>();

92
src/engine/objects/Portal.java

@ -1,13 +1,13 @@
package engine.objects; package engine.objects;
import engine.Enum.RunegateType; import engine.Enum;
import engine.Enum.PortalType;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.gameManager.ConfigManager; import engine.gameManager.ConfigManager;
import engine.job.JobScheduler; import engine.job.JobScheduler;
import engine.jobs.CloseGateJob; import engine.jobs.CloseGateJob;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger;
import java.util.HashSet; import java.util.HashSet;
@ -19,28 +19,20 @@ import java.util.HashSet;
public class Portal { public class Portal {
private boolean active; private boolean active;
private RunegateType sourceGateType; public Enum.PortalType portalType;
private RunegateType portalType; public Building sourceGate;
private RunegateType destinationGateType; public Building targetGate;
private final Vector3fImmutable portalLocation; public final Vector3fImmutable portalLocation;
private long lastActive = 0; private long lastActive = 0;
public Portal(RunegateType gateType, RunegateType portalType, RunegateType destinationGate) { public Portal(Building sourceGate, PortalType portalType, Building targetGate) {
Building gateBuilding;
this.active = false; this.active = false;
this.sourceGateType = gateType; this.sourceGate = sourceGate;
this.destinationGateType = destinationGate; this.targetGate = targetGate;
this.portalType = portalType; this.portalType = portalType;
gateBuilding = this.sourceGateType.getGateBuilding(); this.portalLocation = sourceGate.getLoc().add(new Vector3fImmutable(portalType.offset.x, 6, portalType.offset.y));
if (gateBuilding == null) {
Logger.error("Gate building " + this.sourceGateType.getGateUUID() + " for " + this.sourceGateType.name() + " missing");
}
this.portalLocation = gateBuilding.getLoc().add(new Vector3fImmutable(portalType.getOffset().x, 6, portalType.getOffset().y));
} }
public boolean isActive() { public boolean isActive() {
@ -51,15 +43,12 @@ public class Portal {
public void deactivate() { public void deactivate() {
Building sourceBuilding;
// Remove effect bit from the runegate building, which turns off this // Remove effect bit from the runegate building, which turns off this
// portal type's particle effect // portal type's particle effect
sourceBuilding = this.sourceGateType.getGateBuilding(); sourceGate.removeEffectBit(portalType.effectFlag);
sourceBuilding.removeEffectBit(portalType.getEffectFlag());
this.active = false; this.active = false;
sourceBuilding.updateEffects(); sourceGate.updateEffects();
} }
public void activate(boolean autoClose) { public void activate(boolean autoClose) {
@ -70,8 +59,8 @@ public class Portal {
// Apply effect bit to the runegate building, which turns on this // Apply effect bit to the runegate building, which turns on this
// portal type's particle effect // portal type's particle effect
sourceBuilding = this.sourceGateType.getGateBuilding();
sourceBuilding.addEffectBit(portalType.getEffectFlag()); sourceGate.addEffectBit(portalType.effectFlag);
this.lastActive = System.currentTimeMillis(); this.lastActive = System.currentTimeMillis();
this.active = true; this.active = true;
@ -79,10 +68,10 @@ public class Portal {
// tries to send a dispatch. // tries to send a dispatch.
if (ConfigManager.worldServer.isRunning == true) if (ConfigManager.worldServer.isRunning == true)
sourceBuilding.updateEffects(); sourceGate.updateEffects();
if (autoClose == true) { if (autoClose == true) {
CloseGateJob cgj = new CloseGateJob(sourceBuilding, portalType); CloseGateJob cgj = new CloseGateJob(sourceGate, portalType);
JobScheduler.getInstance().scheduleJob(cgj, MBServerStatics.RUNEGATE_CLOSE_TIME); JobScheduler.getInstance().scheduleJob(cgj, MBServerStatics.RUNEGATE_CLOSE_TIME);
} }
} }
@ -107,59 +96,12 @@ public class Portal {
if (player.getTimeStamp("lastMoveGate") < this.lastActive) if (player.getTimeStamp("lastMoveGate") < this.lastActive)
return; return;
Building gateBuilding;
gateBuilding = destinationGateType.getGateBuilding(); player.teleport(targetGate.getLoc());
if (gateBuilding != null){
player.teleport(gateBuilding.getLoc());
player.setSafeMode(); player.setSafeMode();
}
} }
/**
* @return the sourceGateType
*/
public RunegateType getSourceGateType() {
return sourceGateType;
}
/**
* @param sourceGateType the sourceGateType to set
*/
public void setSourceGateType(RunegateType sourceGateType) {
this.sourceGateType = sourceGateType;
}
/**
* @return the portalType
*/
public RunegateType getPortalType() {
return portalType;
}
/**
* @param portalType the portalType to set
*/
public void setPortalType(RunegateType portalType) {
this.portalType = portalType;
}
/**
* @return the destinationGateType
*/
public RunegateType getDestinationGateType() {
return destinationGateType;
}
/**
* @param destinationGateType the destinationGateType to set
*/
public void setDestinationGateType(RunegateType destinationGateType) {
this.destinationGateType = destinationGateType;
}
/** /**
* @return the portalLocation * @return the portalLocation
*/ */

173
src/engine/objects/Runegate.java

@ -1,61 +1,52 @@
package engine.objects; package engine.objects;
import engine.Enum.RunegateType; import engine.Enum;
import engine.gameManager.BuildingManager; import engine.Enum.PortalType;
import engine.gameManager.DbManager;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
/* Runegates are tied to particular buildings at /* Runegates are tied to particular buildings at
* bootstrap. They aren't tighly coupled, with * bootstrap derived from the Portal creation.
* the Runegate merely toggling effect bits on it's * This is only to enable the toggling of effect
* parent building. * bits when traveler is used.
*/ */
public class Runegate { public class Runegate {
// Runegate class Instance variables // Runegate class Instance variables
private static final Runegate[] _runegates = new Runegate[9]; public static HashMap<Integer, Runegate> _runegates = new HashMap<>();
private final Portal[] _portals; public Portal[] _portals;
private final RunegateType gateType; public Building gateBuilding;
private Runegate(RunegateType gateType) { private Runegate(Building gateBuilding) {
this._portals = new Portal[8]; this._portals = new Portal[8];
this.gateType = gateType; this.gateBuilding = gateBuilding;
// Each Runegate has a different destination
// for each portal opened.
configureGatePortals();
// Chaos, Khar and Oblivion are on by default // Chaos, Khar and Oblivion are on by default
_portals[RunegateType.CHAOS.ordinal()].activate(false); _portals[Enum.PortalType.CHAOS.ordinal()].activate(false);
_portals[RunegateType.OBLIV.ordinal()].activate(false); _portals[Enum.PortalType.OBLIV.ordinal()].activate(false);
_portals[RunegateType.MERCHANT.ordinal()].activate(false); _portals[Enum.PortalType.MERCHANT.ordinal()].activate(false);
} }
public void activatePortal(RunegateType gateType) { public void activatePortal(Enum.PortalType portalType) {
this._portals[gateType.ordinal()].activate(true); this._portals[portalType.ordinal()].activate(true);
} }
public void deactivatePortal(RunegateType gateType) { public void deactivatePortal(Enum.PortalType portalType) {
this._portals[gateType.ordinal()].deactivate();
} this._portals[portalType.ordinal()].deactivate();
public RunegateType getGateType() {
return this.gateType;
} }
public static Runegate[] getRunegates() {
return Runegate._runegates;
}
public Portal[] getPortals() { public Portal[] getPortals() {
@ -74,17 +65,21 @@ public class Runegate {
public static void loadAllRunegates() { public static void loadAllRunegates() {
for (RunegateType runegateType : RunegateType.values()) { ArrayList<Integer> gateList;
_runegates[runegateType.ordinal()] = new Runegate(runegateType);
}
} gateList = DbManager.RunegateQueries.GET_RUNEGATE_LIST();
public void _serializeForEnterWorld(ByteBufferWriter writer) { for (int gateID : gateList) {
Building gateBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateID);
Building gateBuilding; Runegate runegate = new Runegate(gateBuilding);
_runegates.put(gateID, runegate);
}
}
gateBuilding = BuildingManager.getBuilding(this.gateType.getGateUUID()); public void _serializeForEnterWorld(ByteBufferWriter writer) {
writer.putInt(gateBuilding.getObjectType().ordinal()); writer.putInt(gateBuilding.getObjectType().ordinal());
writer.putInt(gateBuilding.getObjectUUID()); writer.putInt(gateBuilding.getObjectUUID());
@ -94,114 +89,6 @@ public class Runegate {
writer.putFloat(gateBuilding.getLoc().getLong()); writer.putFloat(gateBuilding.getLoc().getLong());
} }
private void configureGatePortals() {
// Source gate type, portal type and destination gate type;
switch (this.gateType) {
case EARTH:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.FIRE, RunegateType.FORBID);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.EARTH, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case AIR:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.AIR, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.AIR, RunegateType.AIR, RunegateType.FORBID);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.AIR, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.AIR, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.AIR, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.AIR, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.AIR, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.AIR, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case FIRE:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.FIRE, RunegateType.FORBID);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.FIRE, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case WATER:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.WATER, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.WATER, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.WATER, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.WATER, RunegateType.WATER, RunegateType.FORBID);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.WATER, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.WATER, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.WATER, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.WATER, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case SPIRIT:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.SPIRIT, RunegateType.FORBID);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.SPIRIT, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case CHAOS:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.CHAOS, RunegateType.MERCHANT);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.CHAOS, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case OBLIV:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.OBLIV, RunegateType.MERCHANT);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.OBLIV, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
case MERCHANT:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.MERCHANT, RunegateType.MERCHANT, RunegateType.FORBID);
break;
case FORBID:
_portals[RunegateType.EARTH.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.EARTH, RunegateType.EARTH);
_portals[RunegateType.AIR.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.AIR, RunegateType.AIR);
_portals[RunegateType.FIRE.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.FIRE, RunegateType.FIRE);
_portals[RunegateType.WATER.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.WATER, RunegateType.WATER);
_portals[RunegateType.SPIRIT.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.SPIRIT, RunegateType.SPIRIT);
_portals[RunegateType.CHAOS.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.CHAOS, RunegateType.CHAOS);
_portals[RunegateType.OBLIV.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.OBLIV, RunegateType.OBLIV);
_portals[RunegateType.MERCHANT.ordinal()] = new Portal(RunegateType.FORBID, RunegateType.MERCHANT, RunegateType.MERCHANT);
break;
}
}
public static ArrayList<String> GetAllOpenGateIDStrings(){ public static ArrayList<String> GetAllOpenGateIDStrings(){
ArrayList<String> openGateIDStrings = new ArrayList<>(); ArrayList<String> openGateIDStrings = new ArrayList<>();

28
src/engine/powers/poweractions/OpenGatePowerAction.java

@ -12,7 +12,7 @@ package engine.powers.poweractions;
import engine.Enum; import engine.Enum;
import engine.Enum.BuildingGroup; import engine.Enum.BuildingGroup;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.Enum.RunegateType; import engine.Enum.PortalType;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject; import engine.objects.AbstractWorldObject;
@ -46,9 +46,6 @@ public class OpenGatePowerAction extends AbstractPowerAction {
return; return;
Building targetBuilding = (Building) awo; Building targetBuilding = (Building) awo;
Runegate runeGate;
RunegateType runegateType;
RunegateType portalType;
int token; int token;
// Sanity check. // Sanity check.
@ -69,39 +66,39 @@ public class OpenGatePowerAction extends AbstractPowerAction {
// Which portal was opened? // Which portal was opened?
token = pb.getToken(); token = pb.getToken();
portalType = RunegateType.AIR; PortalType portalType = PortalType.AIR;
switch (token) { switch (token) {
case 428937084: //Death Gate case 428937084: //Death Gate
portalType = RunegateType.OBLIV; portalType = PortalType.OBLIV;
break; break;
case 429756284: //Chaos Gate case 429756284: //Chaos Gate
portalType = RunegateType.CHAOS; portalType = PortalType.CHAOS;
break; break;
case 429723516: //Khar Gate case 429723516: //Khar Gate
portalType = RunegateType.MERCHANT; portalType = PortalType.MERCHANT;
break; break;
case 429559676: //Spirit Gate case 429559676: //Spirit Gate
portalType = RunegateType.SPIRIT; portalType = PortalType.SPIRIT;
break; break;
case 429592444: //Water Gate case 429592444: //Water Gate
portalType = RunegateType.WATER; portalType = PortalType.WATER;
break; break;
case 429428604: //Fire Gate case 429428604: //Fire Gate
portalType = RunegateType.FIRE; portalType = PortalType.FIRE;
break; break;
case 429526908: //Air Gate case 429526908: //Air Gate
portalType = RunegateType.AIR; portalType = PortalType.AIR;
break; break;
case 429625212: //Earth Gate case 429625212: //Earth Gate
portalType = RunegateType.EARTH; portalType = PortalType.EARTH;
break; break;
default: default:
@ -109,12 +106,9 @@ public class OpenGatePowerAction extends AbstractPowerAction {
// Which runegate was clicked on? // Which runegate was clicked on?
runegateType = RunegateType.getGateTypeFromUUID(targetBuilding.getObjectUUID()); Runegate runeGate = Runegate._runegates.get(targetBuilding.getObjectUUID());
runeGate = Runegate.getRunegates()[runegateType.ordinal()];
runeGate.activatePortal(portalType); runeGate.activatePortal(portalType);
} }
@Override @Override

15
src/engine/powers/poweractions/RunegateTeleportPowerAction.java

@ -10,7 +10,7 @@
package engine.powers.poweractions; package engine.powers.poweractions;
import engine.Enum; import engine.Enum;
import engine.Enum.RunegateType; import engine.Enum.PortalType;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
@ -45,24 +45,17 @@ public class RunegateTeleportPowerAction extends AbstractPowerAction {
Building rg = null; Building rg = null;
Vector3fImmutable rgLoc; Vector3fImmutable rgLoc;
for (Runegate runegate: Runegate.getRunegates()) { for (Runegate runegate: Runegate._runegates.values()) {
if ((runegate.getGateType() == RunegateType.OBLIV) || rgLoc = runegate.gateBuilding.getLoc();
(runegate.getGateType() == RunegateType.CHAOS))
continue;
for (Runegate thisGate : Runegate.getRunegates()) {
rgLoc = thisGate.getGateType().getGateBuilding().getLoc();
float distanceToRunegateSquared = source.getLoc().distanceSquared2D(rgLoc); float distanceToRunegateSquared = source.getLoc().distanceSquared2D(rgLoc);
if (distanceToRunegateSquared < sqr(dist)) { if (distanceToRunegateSquared < sqr(dist)) {
dist = sqrt(distanceToRunegateSquared); dist = sqrt(distanceToRunegateSquared);
rg = thisGate.getGateType().getGateBuilding(); rg = runegate.gateBuilding;
} }
} }
}
if(source.getObjectUUID() != pc.getObjectUUID()) { if(source.getObjectUUID() != pc.getObjectUUID()) {
pc.setTimeStampNow("PromptRecall"); pc.setTimeStampNow("PromptRecall");

Loading…
Cancel
Save