Search in sources :

Example 1 with ConnectType

use of mods.railcraft.api.electricity.IElectricGrid.ChargeHandler.ConnectType in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class GridTools method getMutuallyConnectedObjects.

public static Set<IElectricGrid> getMutuallyConnectedObjects(IElectricGrid gridObject) {
    Set<IElectricGrid> connectedObjects = new HashSet<IElectricGrid>();
    WorldCoordinate myPos = new WorldCoordinate(gridObject.getTile());
    for (Map.Entry<WorldCoordinate, EnumSet<ConnectType>> position : gridObject.getChargeHandler().getPossibleConnectionLocations().entrySet()) {
        IElectricGrid otherObj = getGridObjectAt(gridObject.getTile().getWorldObj(), position.getKey());
        if (otherObj != null && position.getValue().contains(otherObj.getChargeHandler().getType())) {
            EnumSet<ConnectType> otherType = otherObj.getChargeHandler().getPossibleConnectionLocations().get(myPos);
            if (otherType != null && otherType.contains(gridObject.getChargeHandler().getType()))
                connectedObjects.add(otherObj);
        }
    }
    return connectedObjects;
}
Also used : WorldCoordinate(mods.railcraft.api.core.WorldCoordinate) EnumSet(java.util.EnumSet) Map(java.util.Map) HashSet(java.util.HashSet) ConnectType(mods.railcraft.api.electricity.IElectricGrid.ChargeHandler.ConnectType)

Aggregations

EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 WorldCoordinate (mods.railcraft.api.core.WorldCoordinate)1 ConnectType (mods.railcraft.api.electricity.IElectricGrid.ChargeHandler.ConnectType)1