Added method to return dungeons already generated.

This commit is contained in:
StevenRS11 2013-07-12 23:40:21 -04:00
parent d6e7fbbde5
commit 314b2dee04

View file

@ -15,6 +15,7 @@ import net.minecraft.block.BlockContainer;
import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World; import net.minecraft.world.World;
import StevenDimDoors.mod_pocketDim.DDProperties; import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.DungeonGenerator; import StevenDimDoors.mod_pocketDim.DungeonGenerator;
import StevenDimDoors.mod_pocketDim.LinkData; import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
@ -531,6 +532,8 @@ public class DungeonHelper
int depth = dimHelper.instance.getDimDepth(incoming.locDimID); int depth = dimHelper.instance.getDimDepth(incoming.locDimID);
int depthWeight = rand.nextInt(depth + 2) + rand.nextInt(depth + 2) - 2; int depthWeight = rand.nextInt(depth + 2) + rand.nextInt(depth + 2) - 2;
ArrayList array = getDungeonDataBelow(dimHelper.dimList.get(incoming.destDimID));
array.hashCode();
int count = 10; int count = 10;
boolean flag = true; boolean flag = true;
try try
@ -718,4 +721,36 @@ public class DungeonHelper
WeightedContainer<DungeonGenerator> resultContainer = (WeightedContainer<DungeonGenerator>) WeightedRandom.getRandomItem(random, weights); WeightedContainer<DungeonGenerator> resultContainer = (WeightedContainer<DungeonGenerator>) WeightedRandom.getRandomItem(random, weights);
return (resultContainer != null) ? resultContainer.getData() : null; return (resultContainer != null) ? resultContainer.getData() : null;
} }
public static ArrayList<DungeonGenerator> getDungeonDataBelow(DimData dimData)
{
DimData startingDim = dimHelper.dimList.get(dimHelper.instance.getLinkDataFromCoords(dimData.exitDimLink.destXCoord, dimData.exitDimLink.destYCoord, dimData.exitDimLink.destZCoord, dimData.exitDimLink.destDimID).destDimID);
return getDungeonDataAbove(startingDim);
}
private static ArrayList<DungeonGenerator> getDungeonDataAbove(DimData dimData)
{
ArrayList<DungeonGenerator> dungeonData = new ArrayList<DungeonGenerator>();
if(dimData.dungeonGenerator!=null)
{
dungeonData.add(dimData.dungeonGenerator);
for(LinkData link : dimData.getLinksInDim())
{
if(dimHelper.dimList.containsKey(link.destDimID))
{
if(dimHelper.dimList.get(link.destDimID).dungeonGenerator!=null&&dimHelper.instance.getDimDepth(link.destDimID)==dimData.depth+1)
{
for(DungeonGenerator dungeonGen :getDungeonDataAbove(dimHelper.dimList.get(link.destDimID)) )
{
if(!dungeonData.contains(dungeonGen))
{
dungeonData.add(dungeonGen);
}
}
}
}
}
}
return dungeonData;
}
} }