public WPObjectDynmapWorld(WPObject object) { super(object.getName(), object.getDimensions().z, 0); this.object = object; chunkCache = new WPObjectMapChunkCache(this, object); Point3i offset = object.getOffset(); xOffset = offset.x; yOffset = offset.y; Point3i dimensions = object.getDimensions(); bounds = new Box(xOffset, dimensions.x + xOffset, yOffset, dimensions.y + yOffset, 0, dimensions.z); }
@Override public WPObject getObject() { if (weightedObjects == null) { weightedObjects = new TreeMap<Integer, WPObject>(); totalObjectWeight = 0; for (WPObject object : objects) { int frequency = object.getAttribute(ATTRIBUTE_FREQUENCY, 100); totalObjectWeight += frequency; weightedObjects.put(totalObjectWeight, object); } } return weightedObjects.tailMap(random.nextInt(totalObjectWeight)).values().iterator().next(); }