@ -17,9 +17,11 @@ import engine.objects.Building;
@@ -17,9 +17,11 @@ import engine.objects.Building;
import engine.objects.City ;
import engine.objects.Zone ;
import engine.server.MBServerStatics ;
import engine.server.world.WorldServer ;
import org.pmw.tinylog.Logger ;
import java.time.Instant ;
import java.time.LocalDateTime ;
import java.time.ZoneId ;
import java.util.ArrayList ;
import java.util.Collection ;
import java.util.Collections ;
@ -33,405 +35,435 @@ import java.util.concurrent.ThreadLocalRandom;
@@ -33,405 +35,435 @@ import java.util.concurrent.ThreadLocalRandom;
* /
public enum ZoneManager {
ZONEMANAGER ;
ZONEMANAGER ;
public static Instant hotZoneLastUpdate ;
/* Instance variables */
private static Zone seaFloor = null ;
public static Zone hotZone = null ;
public static int hotZoneCycle = 0 ; // Used with HOTZONE_DURATION from config.
private static final ConcurrentHashMap < Integer , Zone > zonesByID = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
private static final ConcurrentHashMap < Integer , Zone > zonesByUUID = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
private static final ConcurrentHashMap < String , Zone > zonesByName = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
public static final Set < Zone > macroZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
private static final Set < Zone > npcCityZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
private static final Set < Zone > playerCityZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
// Find all zones coordinates fit into, starting with Sea Floor
public static ArrayList < Zone > getAllZonesIn ( final Vector3fImmutable loc ) {
ArrayList < Zone > allIn = new ArrayList < > ( ) ;
Zone zone ;
zone = ZoneManager . findSmallestZone ( loc ) ;
if ( zone ! = null ) {
allIn . add ( zone ) ;
while ( zone . getParent ( ) ! = null ) {
zone = zone . getParent ( ) ;
allIn . add ( zone ) ;
}
}
return allIn ;
}
/* Instance variables */
private static Zone seaFloor = null ;
private static Zone hotzone = null ;
private static ConcurrentHashMap < Integer , Zone > zonesByID = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
private static ConcurrentHashMap < Integer , Zone > zonesByUUID = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
private static ConcurrentHashMap < String , Zone > zonesByName = new ConcurrentHashMap < > ( MBServerStatics . CHM_INIT_CAP , MBServerStatics . CHM_LOAD ) ;
private static Set < Zone > macroZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
private static Set < Zone > npcCityZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
private static Set < Zone > playerCityZones = Collections . newSetFromMap ( new ConcurrentHashMap < > ( ) ) ;
// Find smallest zone coordinates fit into.
// Find all zones coordinates fit into, starting with Sea Floor
public static final Zone findSmallestZone ( final Vector3fImmutable loc ) {
public static ArrayList < Zone > getAllZonesIn ( final Vector3fImmutable loc ) {
Zone zone = ZoneManager . seaFloor ;
ArrayList < Zone > allIn = new ArrayList < > ( ) ;
Zone zone ;
if ( zone = = null )
return null ;
zone = ZoneManager . findSmallestZone ( loc ) ;
boolean childFound = true ;
if ( zone ! = null ) {
allIn . add ( zone ) ;
while ( zone . getParent ( ) ! = null ) {
zone = zone . getParent ( ) ;
allIn . add ( zone ) ;
}
}
return allIn ;
}
while ( childFound ) {
// Find smallest zone coordinates fit into.
childFound = false ;
public static final Zone findSmallestZone ( final Vector3fImmutable loc ) {
ArrayList < Zone > nodes = zone . getNodes ( ) ;
Zone zone = ZoneManager . seaFloor ;
// Logger.info("soze", "" + nodes.size());
if ( nodes ! = null )
for ( Zone child : nodes ) {
if ( zone = = null )
return null ;
if ( Bounds . collide ( loc , child . getBounds ( ) ) = = true ) {
zone = child ;
childFound = true ;
break ;
}
}
}
return zone ;
}
boolean childFound = true ;
public static void addZone ( final int zoneID , final Zone zone ) {
while ( childFound ) {
ZoneManager . zonesByID . put ( zoneID , zone ) ;
childFound = false ;
if ( zone ! = null )
ZoneManager . zonesByUUID . put ( zone . getObjectUUID ( ) , zone ) ;
ArrayList < Zone > nodes = zone . getNodes ( ) ;
ZoneManager . zonesByName . put ( zone . getName ( ) . toLowerCase ( ) , zone ) ;
// Logger.info("soze", "" + nodes.size());
if ( nodes ! = null )
for ( Zone child : nodes ) {
}
if ( Bounds . collide ( loc , child . getBounds ( ) ) = = true ) {
zone = child ;
childFound = true ;
break ;
}
}
}
return zone ;
}
// Returns the number of available hotZones
// remaining in this cycle (1am)
public static void addZone ( final int zoneID , final Zone zone ) {
public static int availableHotZones ( ) {
ZoneManager . zonesByID . put ( zoneID , zone ) ;
int count = 0 ;
if ( zone ! = null )
ZoneManager . zonesByUUID . put ( zone . getObjectUUID ( ) , zone ) ;
for ( Zone zone : ZoneManager . macroZones )
if ( ZoneManager . validHotZone ( zone ) )
count = count + 1 ;
ZoneManager . zonesByName . put ( zone . getName ( ) . toLowerCase ( ) , zone ) ;
return count ;
}
}
// Resets the availability of hotZones
// for this cycle
public static Zone getZoneByUUID ( final int zoneUUID ) {
return ZoneManager . zonesByUUID . get ( zoneUUID ) ;
}
public static void resetHotZones ( ) {
public static Zone getZoneByZoneID ( final int zoneID ) {
for ( Zone zone : ZoneManager . macroZones )
if ( zone . hasBeenHotzone )
zone . hasBeenHotzone = false ;
return ZoneManager . zonesByID . get ( zoneID ) ;
}
}
public static final Collection < Zone > getAllZones ( ) {
return ZoneManager . zonesByUUID . values ( ) ;
}
public static Zone getZoneByUUID ( final int zoneUUID ) {
return ZoneManager . zonesByUUID . get ( zoneUUID ) ;
}
public static final Zone getHotZone ( ) {
return ZoneManager . hotzone ;
}
public static Zone getZoneByZoneID ( final int zoneID ) {
public static final void setHotZone ( final Zone zone ) {
if ( ! zone . isMacroZone ( ) )
return ;
ZoneManager . hotzone = zone ;
}
return ZoneManager . zonesByID . get ( zoneID ) ;
}
public static boolean inHotZone ( final Vector3fImmutable loc ) {
public static final Collection < Zone > getAllZones ( ) {
return ZoneManager . zonesByUUID . values ( ) ;
}
if ( ZoneManager . hotzone = = null )
return false ;
public static final void setHotZone ( final Zone zone ) {
return ( Bounds . collide ( loc , ZoneManager . hotzone . getBounds ( ) ) = = true ) ;
}
if ( ! zone . isMacroZone ( ) )
return ;
public static void setSeaFloor ( final Zone value ) {
ZoneManager . seaFloor = value ;
}
ZoneManager . hotZone = zone ;
ZoneManager . hotZoneCycle = 1 ; // Used with HOTZONE_DURATION from config.
zone . hasBeenHotzone = true ;
ZoneManager . hotZoneLastUpdate = LocalDateTime . now ( ) . withMinute ( 0 ) . withSecond ( 0 ) . atZone ( ZoneId . systemDefault ( ) ) . toInstant ( ) ;
public static Zone getSeaFloor ( ) {
return ZoneManager . seaFloor ;
}
}
public static final void populateWorldZones ( final Zone zone ) {
public static boolean inHotZone ( final Vector3fImmutable loc ) {
int loadNum = zone . getLoadNum ( ) ;
if ( ZoneManager . hotZone = = null )
return false ;
// Zones are added to separate
// collections for quick access
// based upon their type.
return ( Bounds . collide ( loc , ZoneManager . hotZone . getBounds ( ) ) = = true ) ;
}
if ( zone . isMacroZone ( ) ) {
addMacroZone ( zone ) ;
return ;
}
public static void setSeaFloor ( final Zone value ) {
ZoneManager . seaFloor = value ;
}
public static Zone getSeaFloor ( ) {
return ZoneManager . seaFloor ;
}
if ( zone . isPlayerCity ( ) ) {
addPlayerCityZone ( zone ) ;
return ;
}
public static final void populateWorldZones ( final Zone zone ) {
if ( zone . isNPCCity ( ) )
addNPCCityZone ( zone ) ;
int loadNum = zone . getLoadNum ( ) ;
}
// Zones are added to separate
// collections for quick access
// based upon their type.
private static void addMacroZone ( final Zone zone ) {
ZoneManager . macroZones . add ( zone ) ;
}
if ( zone . isMacroZone ( ) ) {
addMacroZone ( zone ) ;
return ;
}
private static void addNPCCityZone ( final Zone zone ) {
zone . setNPCCity ( true ) ;
ZoneManager . npcCityZones . add ( zone ) ;
}
public static final void addPlayerCityZone ( final Zone zone ) {
zone . setPlayerCity ( tru e ) ;
ZoneManager . playerCityZones . add ( zone ) ;
}
if ( zone . isPlayerCity ( ) ) {
addPlayerCityZone ( zone ) ;
return ;
}
public static final void generateAndSetRandomHotzone ( ) {
if ( zone . isNPCCity ( ) )
addNPCCityZone ( zone ) ;
Zone hotzone ;
ArrayList < Integer > zoneArray = new ArrayList < > ( ) ;
}
if ( ZoneManager . macroZones . isEmpty ( ) )
return ;
private static void addMacroZone ( final Zone zone ) {
ZoneManager . macroZones . add ( zone ) ;
}
for ( Zone zone : ZoneManager . macroZones ) {
private static void addNPCCityZone ( final Zone zone ) {
zone . setNPCCity ( true ) ;
ZoneManager . npcCityZones . add ( zone ) ;
}
if ( validHotZone ( zone ) )
zoneArray . add ( zone . getObjectUUID ( ) ) ;
public static final void addPlayerCityZone ( final Zone zone ) {
zone . setPlayerCity ( true ) ;
ZoneManager . playerCityZones . add ( zone ) ;
}
}
public static final void generateAndSetRandomHotzone ( ) {
int entryIndex = ThreadLocalRandom . current ( ) . nextInt ( zoneArray . size ( ) ) ;
Zone hotZone ;
ArrayList < Integer > zoneArray = new ArrayList < > ( ) ;
hotzone = ZoneManager . getZoneByUUID ( zoneArray . get ( entryIndex ) ) ;
if ( ZoneManager . macroZones . isEmpty ( ) )
return ;
// Reset hotZone availability if none are left.
if ( hotzone = = null ) {
Logger . error ( "Hotzone is null" ) ;
return ;
}
if ( ZoneManager . availableHotZones ( ) = = 0 )
ZoneManager . resetHotZones ( ) ;
for ( Zone zone : ZoneManager . macroZones )
if ( validHotZone ( zone ) )
zoneArray . add ( zone . getObjectUUID ( ) ) ;
ZoneManager . setHotZone ( hotzone ) ;
WorldServer . setLastHZChange ( System . currentTimeMillis ( ) ) ;
int entryIndex = ThreadLocalRandom . current ( ) . nextInt ( zoneArray . size ( ) ) ;
}
hotZone = ZoneManager . getZoneByUUID ( zoneArray . get ( entryIndex ) ) ;
public static final boolean validHotZone ( Zone zone ) {
if ( hotZone = = null ) {
Logger . error ( "Hotzone is null" ) ;
return ;
}
if ( zone . getSafeZone ( ) = = ( byte ) 1 )
return false ; // no safe zone hotzones// if (this.hotzone == null)
ZoneManager . setHotZone ( hotZone ) ;
if ( zone . getNodes ( ) . isEmpty ( ) )
return false ;
}
if ( zone . equals ( ZoneManager . seaFloor ) )
return false ;
public static final boolean validHotZone ( Zone zone ) {
// return false; //first time setting, accept it
// if (this.hotzone.getUUID() == zone.getUUID())
// return true; //no same hotzone
if ( zone . getSafeZone ( ) = = ( byte ) 1 )
return false ; // no safe zone hotzones// if (this.hotzone == null)
if ( ZoneManager . hotzone ! = null )
return ZoneManager . hotzone . getObjectUUID ( ) ! = zone . getObjectUUID ( ) ;
if ( zone . getNodes ( ) . isEmpty ( ) )
return false ;
return true ;
}
if ( zone . equals ( ZoneManager . seaFloor ) )
return false ;
/ * *
* Gets a MacroZone by name .
*
* @param inputName
* MacroZone name to search for
* @return Zone of the MacroZone , or Null
* /
//no duplicate hotZones
public static Zone findMacroZoneByName ( String inputName ) {
synchronized ( ZoneManager . macroZones ) {
for ( Zone zone : ZoneManager . macroZones ) {
String zoneName = zone . getName ( ) ;
if ( zoneName . equalsIgnoreCase ( inputName ) )
return zone ;
}
}
return null ;
}
if ( zone . hasBeenHotzone = = true )
return false ;
// Converts world coordinates to coordinates local to a given zone.
// Enforce min level
public static Vector3fImmutable worldToLocal ( Vector3fImmutable worldVector ,
Zone serverZone ) {
if ( zone . minLvl < Integer . parseInt ( ConfigManager . MB_HOTZONE_MIN_LEVEL . getValue ( ) ) )
return false ;
Vector3fImmutable localCoords ;
if ( ZoneManager . hotZone ! = null )
return ZoneManager . hotZone . getObjectUUID ( ) ! = zone . getObjectUUID ( ) ;
localCoords = new Vector3fImmutable ( worldVector . x - serverZone . absX ,
worldVector . y - serverZone . absY , worldVector . z
- serverZone . absZ ) ;
return true ;
}
return localCoords ;
}
/ * *
* Gets a MacroZone by name .
*
* @param inputName MacroZone name to search for
* @return Zone of the MacroZone , or Null
* /
public static Zone findMacroZoneByName ( String inputName ) {
synchronized ( ZoneManager . macroZones ) {
for ( Zone zone : ZoneManager . macroZones ) {
String zoneName = zone . getName ( ) ;
if ( zoneName . equalsIgnoreCase ( inputName ) )
return zone ;
}
}
return null ;
}
public static Vector2f worldToZoneSpace ( Vector3fImmutable worldVector ,
Zone serverZone ) {
// Converts world coordinates to coordinates local to a given zone.
Vector2f localCoords ;
Vector2f zoneOrigin ;
public static Vector3fImmutable worldToLocal ( Vector3fImmutable worldVector ,
Zone serverZone ) {
// Top left corner of zone is calculated in world space by the center and it's extents.
Vector3fImmutable localCoords ;
zoneOrigin = new Vector2f ( serverZone . getLoc ( ) . x , serverZone . getLoc ( ) . z ) ;
zoneOrigin = zoneOrigin . subtract ( new Vector2f ( serverZone . getBounds ( ) . getHalfExtents ( ) . x , serverZone . getBounds ( ) . getHalfExtents ( ) . y ) ) ;
localCoords = new Vector3fImmutable ( worldVector . x - serverZone . absX ,
worldVector . y - serverZone . absY , worldVector . z
- serverZone . absZ ) ;
// Local coordinate in world space translated to an offset from the calculated zone origin.
return localCoords ;
}
localCoords = new Vector2f ( worldVector . x , worldVector . z ) ;
localCoords = localCoords . subtract ( zoneOrigin ) ;
public static Vector2f worldToZoneSpace ( Vector3fImmutable worldVector ,
Zone serverZone ) {
localCoords . setY ( ( serverZone . getBounds ( ) . getHalfExtents ( ) . y * 2 ) - localCoords . y ) ;
Vector2f localCoords ;
Vector2f zoneOrigin ;
// Top left corner of zone is calculated in world space by the center and it's extents.
zoneOrigin = new Vector2f ( serverZone . getLoc ( ) . x , serverZone . getLoc ( ) . z ) ;
zoneOrigin = zoneOrigin . subtract ( new Vector2f ( serverZone . getBounds ( ) . getHalfExtents ( ) . x , serverZone . getBounds ( ) . getHalfExtents ( ) . y ) ) ;
// Local coordinate in world space translated to an offset from the calculated zone origin.
// TODO : Make sure this value does not go outside the zone's bounds.
localCoords = new Vector2f ( worldVector . x , worldVector . z ) ;
localCoords = localCoords . subtract ( zoneOrigin ) ;
return localCoords ;
}
localCoords . setY ( ( serverZone . getBounds ( ) . getHalfExtents ( ) . y * 2 ) - localCoords . y ) ;
// Converts local zone coordinates to world coordinates
public static Vector3fImmutable localToWorld ( Vector3fImmutable worldVector ,
Zone serverZone ) {
// TODO : Make sure this value does not go outside the zone's bounds.
Vector3fImmutable worldCoords ;
return localCoords ;
}
worldCoords = new Vector3fImmutable ( worldVector . x + serverZone . absX ,
worldVector . y + serverZone . absY , worldVector . z
+ serverZone . absZ ) ;
// Converts local zone coordinates to world coordinates
return worldCoords ;
}
public static Vector3fImmutable localToWorld ( Vector3fImmutable worldVector ,
Zone serverZone ) {
Vector3fImmutable worldCoords ;
/ * *
* Converts from local ( relative to this building ) to world .
*
* @param localPos position in local reference ( relative to this building )
* @return position relative to world
* /
worldCoords = new Vector3fImmutable ( worldVector . x + serverZone . absX ,
worldVector . y + serverZone . absY , worldVector . z
+ serverZone . absZ ) ;
public static Vector3fImmutable convertLocalToWorld ( Building building , Vector3fImmutable localPos ) {
return worldCoords ;
}
// convert from SB rotation value to radians
if ( building . getBounds ( ) . getQuaternion ( ) = = null )
return building . getLoc ( ) ;
Vector3fImmutable rotatedLocal = Vector3fImmutable . rotateAroundPoint ( Vector3fImmutable . ZERO , localPos , building . getBounds ( ) . getQuaternion ( ) ) ;
// handle building rotation
// handle building translation
return building . getLoc ( ) . add ( rotatedLocal . x , rotatedLocal . y , rotatedLocal . z ) ;
}
//used for regions, Building bounds not set yet.
public static Vector3f convertLocalToWorld ( Building building , Vector3f localPos , Bounds bounds ) {
/ * *
* Converts from local ( relative to this building ) to world .
*
* @param localPos position in local reference ( relative to this building )
* @return position relative to world
* /
// convert from SB rotation value to radians
Vector3f rotatedLocal = Vector3f . rotateAroundPoint ( Vector3f . ZERO , localPos , bounds . getQuaternion ( ) ) ;
// handle building rotation
// handle building translation
public static Vector3fImmutable convertLocalToWorld ( Building building , Vector3fImmutable localPos ) {
return new Vector3f ( building . getLoc ( ) . add ( rotatedLocal . x , rotatedLocal . y , rotatedLocal . z ) ) ;
}
// convert from SB rotation value to radians
public static Vector3fImmutable convertWorldToLocal ( Building building , Vector3fImmutable WorldPos ) {
Vector3fImmutable convertLoc = Vector3fImmutable . rotateAroundPoint ( building . getLoc ( ) , WorldPos , - building . getBounds ( ) . getQuaternion ( ) . angleY ) ;
convertLoc = convertLoc . subtract ( building . getLoc ( ) ) ;
// convert from SB rotation value to radians
return convertLoc ;
if ( building . getBounds ( ) . getQuaternion ( ) = = null )
return building . getLoc ( ) ;
Vector3fImmutable rotatedLocal = Vector3fImmutable . rotateAroundPoint ( Vector3fImmutable . ZERO , localPos , building . getBounds ( ) . getQuaternion ( ) ) ;
// handle building rotation
// handle building translation
}
return building . getLoc ( ) . add ( rotatedLocal . x , rotatedLocal . y , rotatedLocal . z ) ;
}
//used for regions, Building bounds not set yet.
public static Vector3f convertLocalToWorld ( Building building , Vector3f localPos , Bounds bounds ) {
public static Vector3fImmutable convertNPCLoc ( Building building , Vector3fImmutable npcLoc ) {
// convert from SB rotation value to radians
return Vector3fImmutable . rotateAroundPoint ( Vector3fImmutable . ZERO , npcLoc , - building . getBounds ( ) . getQuaternion ( ) . angleY ) ;
}
Vector3f rotatedLocal = Vector3f . rotateAroundPoint ( Vector3f . ZERO , localPos , bounds . getQuaternion ( ) ) ;
// handle building rotation
// handle building translation
return new Vector3f ( building . getLoc ( ) . add ( rotatedLocal . x , rotatedLocal . y , rotatedLocal . z ) ) ;
}
public static Vector3fImmutable convertWorldToLocal ( Building building , Vector3fImmutable WorldPos ) {
Vector3fImmutable convertLoc = Vector3fImmutable . rotateAroundPoint ( building . getLoc ( ) , WorldPos , - building . getBounds ( ) . getQuaternion ( ) . angleY ) ;
// Method returns a city if the given location is within
// a city siege radius.
public static City getCityAtLocation ( Vector3fImmutable worldLoc ) {
convertLoc = convertLoc . subtract ( building . getLoc ( ) ) ;
Zone currentZone ;
ArrayList < Zone > zoneList ;
City city ;
// convert from SB rotation value to radians
currentZone = ZoneManager . findSmallestZone ( worldLoc ) ;
return convertLoc ;
if ( currentZone . isPlayerCity ( ) )
return City . getCity ( currentZone . getPlayerCityUUID ( ) ) ;
}
public static Vector3fImmutable convertNPCLoc ( Building building , Vector3fImmutable npcLoc ) {
return Vector3fImmutable . rotateAroundPoint ( Vector3fImmutable . ZERO , npcLoc , - building . getBounds ( ) . getQuaternion ( ) . angleY ) ;
}
// Not currently on a city grid. Test nearby cities
// to see if we are on one of their seige bounds.
// Method returns a city if the given location is within
// a city siege radiu s.
zoneList = currentZone . getNodes ( ) ;
public static City getCityAtLocation ( Vector3fImmutable worldLoc ) {
for ( Zone zone : zoneList ) {
Zone currentZone ;
ArrayList < Zone > zoneList ;
City city ;
if ( zone = = currentZone )
continue ;
currentZone = ZoneManager . findSmallestZone ( worldLoc ) ;
if ( currentZone . isPlayerCity ( ) )
return City . getCity ( currentZone . getPlayerCityUUID ( ) ) ;
// Not currently on a city grid. Test nearby cities
// to see if we are on one of their seige bounds.
zoneList = currentZone . getNodes ( ) ;
for ( Zone zone : zoneList ) {
if ( zone = = currentZone )
continue ;
if ( zone . isPlayerCity ( ) = = false )
continue ;
city = City . getCity ( zone . getPlayerCityUUID ( ) ) ;
if ( worldLoc . isInsideCircle ( city . getLoc ( ) , Enum . CityBoundsType . SIEGE . extents ) )
return city ;
}
return null ;
}
if ( zone . isPlayerCity ( ) = = false )
continue ;
/ * Method is called when creating a new player city to
* validate that the new zone does not overlap any other
* zone that might currently exist
* /
city = City . getCity ( zone . getPlayerCityUUID ( ) ) ;
public static boolean validTreePlacementLoc ( Zone currentZone , float positionX , float positionZ ) {
if ( worldLoc . isInsideCircle ( city . getLoc ( ) , Enum . CityBoundsType . SIEGE . extents ) )
return city ;
}
// Member Variable declaration
return null ;
}
ArrayList < Zone > zoneList ;
boolean validLocation = true ;
Bounds treeBounds ;
/ * Method is called when creating a new player city to
* validate that the new zone does not overlap any other
* zone that might currently exist
* /
if ( currentZone . isContininent ( ) = = false )
return false ;
public static boolean validTreePlacementLoc ( Zone currentZone , float positionX , float positionZ ) {
// Member Variable declaration
treeBounds = Bounds . borrow ( ) ;
treeBounds . setBounds ( new Vector2f ( positionX , positionZ ) , new Vector2f ( Enum . CityBoundsType . SIEGE . extents , Enum . CityBoundsType . SIEGE . extents ) , 0 . 0f ) ;
ArrayList < Zone > zoneList ;
boolean validLocation = true ;
Bounds treeBounds ;
if ( currentZone . isContininent ( ) = = false )
return false ;
treeBounds = Bounds . borrow ( ) ;
treeBounds . setBounds ( new Vector2f ( positionX , positionZ ) , new Vector2f ( Enum . CityBoundsType . SIEGE . extents , Enum . CityBoundsType . SIEGE . extents ) , 0 . 0f ) ;
zoneList = currentZone . getNodes ( ) ;
zoneList = currentZone . getNodes ( ) ;
for ( Zone zone : zoneList ) {
for ( Zone zone : zoneList ) {
if ( zone . isContininent ( ) )
continue ;
if ( zone . isContininent ( ) )
continue ;
if ( Bounds . collide ( treeBounds , zone . getBounds ( ) , 0 . 0f ) )
validLocation = false ;
}
if ( Bounds . collide ( treeBounds , zone . getBounds ( ) , 0 . 0f ) )
validLocation = false ;
}
treeBounds . release ( ) ;
return validLocation ;
treeBounds . release ( ) ;
return validLocation ;
}
}