|
|
@ -9,8 +9,8 @@ |
|
|
|
package engine.InterestManagement; |
|
|
|
package engine.InterestManagement; |
|
|
|
|
|
|
|
|
|
|
|
/* This class is the main interface for Magicbane's |
|
|
|
/* This class is the main interface for Magicbane's |
|
|
|
* Interest management facilities. |
|
|
|
* Interest management facilities. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
@ -24,15 +24,26 @@ import engine.server.MBServerStatics; |
|
|
|
import engine.util.MapLoader; |
|
|
|
import engine.util.MapLoader; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
|
|
|
|
import static engine.objects.Realm.getRealm; |
|
|
|
import static engine.objects.Realm.getRealm; |
|
|
|
|
|
|
|
|
|
|
|
public class RealmMap { |
|
|
|
public enum RealmMap { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
REALM_MAP; |
|
|
|
|
|
|
|
|
|
|
|
// Spatial hashmap. Used for detecting which Realm
|
|
|
|
// Spatial hashmap. Used for determining which Realm
|
|
|
|
// a player is currently in..
|
|
|
|
// a player is currently located within.
|
|
|
|
|
|
|
|
|
|
|
|
public static int[][] _realmImageMap; |
|
|
|
public static int[][] _realmImageMap; |
|
|
|
|
|
|
|
private static final HashMap<Integer, Integer> _rgbToIDMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static int getRealmIDByRGB(int realmRGB) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return _rgbToIDMap.get(realmRGB); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static int getRealmIDAtLocation(Vector3fImmutable pos) { |
|
|
|
public static int getRealmIDAtLocation(Vector3fImmutable pos) { |
|
|
|
|
|
|
|
|
|
|
@ -49,6 +60,10 @@ public class RealmMap { |
|
|
|
return RealmMap._realmImageMap[xBuckets][yBuckets]; |
|
|
|
return RealmMap._realmImageMap[xBuckets][yBuckets]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void addToColorMap(Color color, int realmID) { |
|
|
|
|
|
|
|
_rgbToIDMap.put(color.getRGB(), realmID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static Realm getRealmForCity(City city) { |
|
|
|
public static Realm getRealmForCity(City city) { |
|
|
|
Realm outRealm = null; |
|
|
|
Realm outRealm = null; |
|
|
|
outRealm = city.getRealm(); |
|
|
|
outRealm = city.getRealm(); |
|
|
@ -61,28 +76,28 @@ public class RealmMap { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void updateRealm(PlayerCharacter player){ |
|
|
|
public static void updateRealm(PlayerCharacter player) { |
|
|
|
|
|
|
|
|
|
|
|
int realmID = RealmMap.getRealmIDAtLocation(player.getLoc()); |
|
|
|
int realmID = RealmMap.getRealmIDAtLocation(player.getLoc()); |
|
|
|
|
|
|
|
|
|
|
|
if (realmID != player.getLastRealmID()){ |
|
|
|
if (realmID != player.getLastRealmID()) { |
|
|
|
player.setLastRealmID(realmID); |
|
|
|
player.setLastRealmID(realmID); |
|
|
|
Realm realm = Realm.getRealm(realmID); |
|
|
|
Realm realm = Realm.getRealm(realmID); |
|
|
|
if (realm != null){ |
|
|
|
if (realm != null) { |
|
|
|
if (realm.isRuled()){ |
|
|
|
if (realm.isRuled()) { |
|
|
|
City city = realm.getRulingCity(); |
|
|
|
City city = realm.getRulingCity(); |
|
|
|
if (city != null){ |
|
|
|
if (city != null) { |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage((PlayerCharacter)realm.getRulingCity().getOwner(),realm); |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage((PlayerCharacter) realm.getRulingCity().getOwner(), realm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage(null,realm); |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage(null, realm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage(null,realm); |
|
|
|
TerritoryChangeMessage tcm = new TerritoryChangeMessage(null, realm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
Dispatch dispatch = Dispatch.borrow(player, tcm); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY); |
|
|
|
} |
|
|
|
} |
|
|
|