Search in sources :

Example 1 with Vector2i

use of com.flowpowered.math.vector.Vector2i in project Skree by Skelril.

the class CacheBasedAllocator method regionFor.

@Override
public <T> void regionFor(String managerName, Function<Clause<ZoneRegion, ZoneRegion.State>, T> initMapper, Consumer<T> callBack) {
    Optional<ZoneBoundingBox> optBoundingBox = pool.getIfAvailable(managerName);
    Vector3i origin = new Vector3i(lastEnd.getX(), 0, lastEnd.getY());
    if (optBoundingBox.isPresent()) {
        origin = optBoundingBox.get().getOrigin();
    }
    ZoneWorldBoundingBox incompleteRegion = decorator.pasteAt(worldResolver, origin, managerName, box -> initMapper.apply(new Clause<>(new ZoneRegion(this, box), ZoneRegion.State.NEW_LOADING)), callBack::accept);
    if (!optBoundingBox.isPresent()) {
        pool.claimNew(managerName, incompleteRegion);
        Vector3i lastMax = incompleteRegion.getMaximumPoint();
        lastEnd = new Vector2i(lastMax.getX() + 1, lastMax.getZ() + 1);
    }
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) Clause(com.skelril.nitro.Clause) Vector2i(com.flowpowered.math.vector.Vector2i)

Example 2 with Vector2i

use of com.flowpowered.math.vector.Vector2i in project Skree by Skelril.

the class ZonePool method getLastMarkedPoint.

public Vector2i getLastMarkedPoint() throws IllegalStateException {
    if (globalBoxList.isEmpty()) {
        return new Vector2i(0, 0);
    }
    globalBoxList.sort((a, b) -> {
        Vector3i aMax = a.getMaximumPoint();
        Vector3i bMax = b.getMaximumPoint();
        if (aMax.getX() < bMax.getX() || aMax.getZ() < bMax.getZ()) {
            return -1;
        }
        return 1;
    });
    Vector3i lastMax = globalBoxList.get(globalBoxList.size() - 1).getMaximumPoint();
    return new Vector2i(lastMax.getX() + 1, lastMax.getZ() + 1);
}
Also used : Vector3i(com.flowpowered.math.vector.Vector3i) Vector2i(com.flowpowered.math.vector.Vector2i)

Aggregations

Vector2i (com.flowpowered.math.vector.Vector2i)2 Vector3i (com.flowpowered.math.vector.Vector3i)2 Clause (com.skelril.nitro.Clause)1