Search in sources :

Example 1 with DisplacementType

use of com.lilithsthrone.game.inventory.clothing.DisplacementType in project liliths-throne-public by Innoxia.

the class CharacterInventory method getNextClothingToRemoveForCoverableAreaAccess.

public SimpleEntry<AbstractClothing, DisplacementType> getNextClothingToRemoveForCoverableAreaAccess(CoverableArea coverableArea) {
    // TODO
    AbstractClothing clothingToRemove = null;
    DisplacementType displacement = null;
    List<AbstractClothing> zLayerSortedList = new ArrayList<>(clothingCurrentlyEquipped);
    zLayerSortedList.sort(new ClothingZLayerComparator().reversed());
    outerloop: for (AbstractClothing clothing : zLayerSortedList) {
        for (BlockedParts bp : clothing.getClothingType().getBlockedPartsList()) if (bp.blockedBodyParts.contains(coverableArea) && !clothing.getDisplacedList().contains(bp.displacementType)) {
            if (!isCoverableAreaExposedFromElsewhere(clothing, coverableArea)) {
                // this clothing is blocking the part we want access to, so make that our starting point:
                clothingToRemove = clothing;
                displacement = bp.displacementType;
                break outerloop;
            }
        }
    }
    if (clothingToRemove == null) {
        throw new IllegalArgumentException("There is no clothing covering this part!");
    }
    boolean finished = false;
    while (!finished) {
        finished = true;
        outerloop2: for (BlockedParts bp : clothingToRemove.getClothingType().getBlockedPartsList()) {
            if (bp.displacementType == displacement) {
                for (ClothingAccess ca : bp.clothingAccessRequired) {
                    for (AbstractClothing clothing : zLayerSortedList) {
                        if (clothing != clothingToRemove) {
                            for (BlockedParts bpIterated : clothing.getClothingType().getBlockedPartsList()) {
                                if (bpIterated.clothingAccessBlocked.contains(ca) && !clothing.getDisplacedList().contains(bpIterated.displacementType)) {
                                    if (!isCoverableAreaExposedFromElsewhere(clothing, coverableArea)) {
                                        // this clothing is blocking the clothing we wanted to displace, so now we re-start by wanting to displace this new clothing:
                                        clothingToRemove = clothing;
                                        displacement = bpIterated.displacementType;
                                        finished = false;
                                        break outerloop2;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return new SimpleEntry<AbstractClothing, DisplacementType>(clothingToRemove, displacement);
}
Also used : DisplacementType(com.lilithsthrone.game.inventory.clothing.DisplacementType) SimpleEntry(java.util.AbstractMap.SimpleEntry) ReverseClothingZLayerComparator(com.lilithsthrone.utils.ReverseClothingZLayerComparator) ClothingZLayerComparator(com.lilithsthrone.utils.ClothingZLayerComparator) BlockedParts(com.lilithsthrone.game.inventory.clothing.BlockedParts) AbstractClothing(com.lilithsthrone.game.inventory.clothing.AbstractClothing) ArrayList(java.util.ArrayList) ClothingAccess(com.lilithsthrone.game.inventory.clothing.ClothingAccess)

Aggregations

AbstractClothing (com.lilithsthrone.game.inventory.clothing.AbstractClothing)1 BlockedParts (com.lilithsthrone.game.inventory.clothing.BlockedParts)1 ClothingAccess (com.lilithsthrone.game.inventory.clothing.ClothingAccess)1 DisplacementType (com.lilithsthrone.game.inventory.clothing.DisplacementType)1 ClothingZLayerComparator (com.lilithsthrone.utils.ClothingZLayerComparator)1 ReverseClothingZLayerComparator (com.lilithsthrone.utils.ReverseClothingZLayerComparator)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ArrayList (java.util.ArrayList)1