Working on dungeon deletion

This commit is contained in:
StevenRS11
2013-10-02 00:52:18 -04:00
parent eef5117c04
commit 69864ea9ad
4 changed files with 75 additions and 49 deletions

View File

@@ -470,26 +470,11 @@ public class DDTeleporter
private static boolean initializeDestination(DimLink link, DDProperties properties, Block door)
{
//TODO implement blackList
if (link.hasDestination())
{
//Need to check if the destination is a dungeon, not only the link because non-dungeon links could still link to a dungeon at this point.
if(PocketManager.getDimensionData(link.destination().getDimension()).isDungeon)
{
NewDimData dimData = PocketManager.getDimensionData(link.destination().getDimension());
if(!dimData.isFilled())
{
if(!PocketBuilder.regenerateDungeonPocket(dimData, link, properties))
{
//If we fail to regenerate, send the player to the parent dimension.
return generateSafeExit(link, properties);
}
}
}
return true;
}
// Check the destination type and respond accordingly

View File

@@ -52,7 +52,7 @@ public abstract class NewDimData
tail = new LinkTail(0, null);
}
public boolean overwrite(InnerDimLink nextParent)
public boolean overwrite(InnerDimLink nextParent,int orientation)
{
if (nextParent == null)
{
@@ -86,10 +86,11 @@ public abstract class NewDimData
parent = nextParent;
tail = nextParent.tail;
nextParent.children.add(this);
this.orientation=orientation;
return true;
}
public void overwrite(int linkType)
public void overwrite(int linkType, int orientation)
{
//Release children
for (DimLink child : children)
@@ -107,6 +108,8 @@ public abstract class NewDimData
//Attach to new parent
parent = null;
tail = new LinkTail(linkType, null);
//Set new orientation
this.orientation=orientation;
}
}
@@ -261,7 +264,7 @@ public abstract class NewDimData
}
else
{
link.overwrite(linkType);
link.overwrite(linkType,orientation);
}
//Link created!
linkWatcher.onCreated(link.source);
@@ -295,7 +298,7 @@ public abstract class NewDimData
}
else
{
if (link.overwrite(parent))
if (link.overwrite(parent, parent.orientation))
{
//Link created!
linkWatcher.onCreated(link.source);

View File

@@ -185,25 +185,6 @@ public class PocketManager
isLoaded = true;
isLoading = false;
}
public static boolean resetDungeon(NewDimData target)
{
// We can't reset the dimension if it's currently loaded or if it's not a dungeon.
// We cast to InnerDimData so that if anyone tries to be a smartass and create their
// own version of NewDimData, this will throw an exception.
InnerDimData dimension = (InnerDimData) target;
if (dimension.isDungeon() && DimensionManager.getWorld(dimension.id()) == null)
{
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
if (DeleteFolder.deleteFolder(saveDirectory))
{
dimension.setFilled(false);
return true;
}
}
return false;
}
public static boolean deletePocket(NewDimData target, boolean deleteFolder)
{
// We can't delete the dimension if it's currently loaded or if it's not actually a pocket.
@@ -214,10 +195,32 @@ public class PocketManager
{
if (deleteFolder)
{
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(saveDirectory);
deleteDimensionFolder(target);
}
dimensionData.remove(dimension.id());
deleteDimensionData(dimension.id);
return true;
}
return false;
}
public static boolean deleteDimensionFolder(NewDimData target)
{
InnerDimData dimension = (InnerDimData) target;
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
{
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
DeleteFolder.deleteFolder(saveDirectory);
return true;
}
return false;
}
public static boolean deleteDimensionData(int dimensionID)
{
if(dimensionData.containsKey(dimensionID)&& DimensionManager.getWorld(dimensionID) == null)
{
NewDimData target = PocketManager.getDimensionData(dimensionID);
InnerDimData dimension = (InnerDimData) target;
dimensionData.remove(dimensionID);
// Raise the dim deleted event
dimWatcher.onDeleted(new ClientDimData(dimension));
dimension.clear();
@@ -226,6 +229,18 @@ public class PocketManager
return false;
}
public static int deleteDimensionData(ArrayList<Integer> dimensions)
{
int deletedCount=0;
for(int dimID : dimensions)
{
if(deleteDimensionData(dimID))
{
deletedCount++;
}
}
return deletedCount;
}
private static void registerPockets(DDProperties properties)
{
for (NewDimData dimension : dimensionData.values())