Runegates and portals now loaded from database.
This commit is contained in:
@@ -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;
|
||||
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 {
|
||||
|
||||
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 {
|
||||
// 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 {
|
||||
// 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 {
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -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) {
|
||||
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() {
|
||||
|
||||
@@ -74,18 +65,22 @@ 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();
|
||||
|
||||
for (int gateID : gateList) {
|
||||
|
||||
Building gateBuilding = (Building) DbManager.getObject(Enum.GameObjectType.Building, gateID);
|
||||
|
||||
Runegate runegate = new Runegate(gateBuilding);
|
||||
_runegates.put(gateID, runegate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void _serializeForEnterWorld(ByteBufferWriter writer) {
|
||||
|
||||
Building gateBuilding;
|
||||
|
||||
gateBuilding = BuildingManager.getBuilding(this.gateType.getGateUUID());
|
||||
|
||||
writer.putInt(gateBuilding.getObjectType().ordinal());
|
||||
writer.putInt(gateBuilding.getObjectUUID());
|
||||
writer.putString(gateBuilding.getParentZone().getName());
|
||||
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user