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 @@ @@ -9,7 +9,6 @@
package engine;
import ch.claude_martin.enumbitset.EnumBitSetHelper;
import engine.gameManager.BuildingManager;
import engine.gameManager.PowersManager;
import engine.gameManager.ZoneManager;
import engine.math.Vector2f;
@ -18,7 +17,6 @@ import engine.objects.*; @@ -18,7 +17,6 @@ import engine.objects.*;
import engine.powers.EffectsBase;
import org.pmw.tinylog.Logger;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
@ -561,74 +559,16 @@ public class Enum { @@ -561,74 +559,16 @@ public class Enum {
FORBID(0.0f, 0.0f, 0);
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.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

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

@ -0,0 +1,73 @@ @@ -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; @@ -2,7 +2,6 @@ package engine.devcmd.cmds;
import engine.Enum.BuildingGroup;
import engine.Enum.GameObjectType;
import engine.Enum.RunegateType;
import engine.devcmd.AbstractDevCmd;
import engine.math.Vector3fImmutable;
import engine.objects.*;
@ -21,7 +20,6 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -21,7 +20,6 @@ public class GateInfoCmd extends AbstractDevCmd {
Building targetBuilding;
String outString;
RunegateType runegateType;
Runegate runeGate;
Blueprint blueprint;
String newline = "\r\n ";
@ -41,10 +39,10 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -41,10 +39,10 @@ public class GateInfoCmd extends AbstractDevCmd {
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 += "Portal State:";
@ -52,9 +50,9 @@ public class GateInfoCmd extends AbstractDevCmd { @@ -52,9 +50,9 @@ public class GateInfoCmd extends AbstractDevCmd {
for (Portal portal : runeGate.getPortals()) {
outString += "Portal: " + portal.getPortalType().name();
outString += "Portal: " + portal.portalType.name();
outString += " Active: " + portal.isActive();
outString += " Dest: " + portal.getDestinationGateType().name();
outString += " Dest: " + portal.targetGate.getName();
outString += newline;
outString += " Origin: " + portal.getPortalLocation().x + 'x';
outString += " " + portal.getPortalLocation().y + 'y';

2
src/engine/gameManager/DbManager.java

@ -311,4 +311,6 @@ public enum DbManager { @@ -311,4 +311,6 @@ public enum DbManager {
public static final dbBoonHandler BoonQueries = new dbBoonHandler();
public static final dbShrineHandler ShrineQueries = new dbShrineHandler();
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 { @@ -206,7 +206,7 @@ public enum SimulationManager {
*/
private void pulseRunegates() {
for (Runegate runegate : Runegate.getRunegates()) {
for (Runegate runegate : Runegate._runegates.values()) {
runegate.collidePortals();
}

10
src/engine/jobs/CloseGateJob.java

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

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

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

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

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

92
src/engine/objects/Portal.java

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

173
src/engine/objects/Runegate.java

@ -1,61 +1,52 @@ @@ -1,61 +1,52 @@
package engine.objects;
import engine.Enum.RunegateType;
import engine.gameManager.BuildingManager;
import engine.Enum;
import engine.Enum.PortalType;
import engine.gameManager.DbManager;
import engine.net.ByteBufferWriter;
import java.util.ArrayList;
import java.util.HashMap;
/* Runegates are tied to particular buildings at
* bootstrap. They aren't tighly coupled, with
* the Runegate merely toggling effect bits on it's
* parent building.
* bootstrap derived from the Portal creation.
* This is only to enable the toggling of effect
* bits when traveler is used.
*/
public class Runegate {
// Runegate class Instance variables
private static final Runegate[] _runegates = new Runegate[9];
public static HashMap<Integer, Runegate> _runegates = new HashMap<>();
private final Portal[] _portals;
private final RunegateType gateType;
public Portal[] _portals;
public Building gateBuilding;
private Runegate(RunegateType gateType) {
private Runegate(Building gateBuilding) {
this._portals = new Portal[8];
this.gateType = gateType;
// Each Runegate has a different destination
// for each portal opened.
configureGatePortals();
this.gateBuilding = gateBuilding;
// Chaos, Khar and Oblivion are on by default
_portals[RunegateType.CHAOS.ordinal()].activate(false);
_portals[RunegateType.OBLIV.ordinal()].activate(false);
_portals[RunegateType.MERCHANT.ordinal()].activate(false);
_portals[Enum.PortalType.CHAOS.ordinal()].activate(false);
_portals[Enum.PortalType.OBLIV.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) {
this._portals[gateType.ordinal()].deactivate();
public void deactivatePortal(Enum.PortalType portalType) {
}
this._portals[portalType.ordinal()].deactivate();
public RunegateType getGateType() {
return this.gateType;
}
public static Runegate[] getRunegates() {
return Runegate._runegates;
}
public Portal[] getPortals() {
@ -74,17 +65,21 @@ public class Runegate { @@ -74,17 +65,21 @@ public class Runegate {
public static void loadAllRunegates() {
for (RunegateType runegateType : RunegateType.values()) {
_runegates[runegateType.ordinal()] = new Runegate(runegateType);
}
ArrayList<Integer> gateList;
}
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.getObjectUUID());
@ -94,114 +89,6 @@ public class Runegate { @@ -94,114 +89,6 @@ public class Runegate {
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(){
ArrayList<String> openGateIDStrings = new ArrayList<>();

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

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

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

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

Loading…
Cancel
Save