2013-06-10 23:03:52 +02:00
|
|
|
package StevenDimDoors.mod_pocketDim;
|
|
|
|
|
2013-08-05 15:48:49 +02:00
|
|
|
import java.io.File;
|
2013-06-10 23:03:52 +02:00
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2013-08-05 15:48:49 +02:00
|
|
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
|
|
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
|
|
|
|
2013-06-10 23:03:52 +02:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2013-06-11 20:42:11 +02:00
|
|
|
public class DungeonGenerator implements Serializable
|
2013-06-10 23:03:52 +02:00
|
|
|
{
|
2013-08-05 15:48:49 +02:00
|
|
|
//This static field is hax so that I don't have to add an instance field to DungeonGenerator to support DungeonType.
|
|
|
|
//Otherwise it would have to be serializable and all sorts of problems would arise.
|
|
|
|
private static final HashMap<DungeonGenerator, DungeonType> dungeonTypes = new HashMap<DungeonGenerator, DungeonType>();
|
|
|
|
|
2013-06-10 23:03:52 +02:00
|
|
|
public int weight;
|
|
|
|
public String schematicPath;
|
|
|
|
public ArrayList<HashMap> sideRifts = new ArrayList<HashMap>();
|
2013-08-05 01:27:34 +02:00
|
|
|
public LinkData exitLink;
|
2013-06-10 23:03:52 +02:00
|
|
|
public boolean isOpen;
|
2013-06-24 06:11:14 +02:00
|
|
|
|
2013-06-10 23:03:52 +02:00
|
|
|
public int sideDoorsSoFar=0;
|
|
|
|
public int exitDoorsSoFar=0;
|
|
|
|
public int deadEndsSoFar=0;
|
|
|
|
|
2013-08-05 15:48:49 +02:00
|
|
|
public DungeonGenerator(int weight, String schematicPath, boolean isOpen, DungeonType dungeonType)
|
|
|
|
{
|
|
|
|
this.weight = weight;
|
|
|
|
this.schematicPath = schematicPath;
|
|
|
|
this.isOpen = isOpen;
|
|
|
|
|
|
|
|
dungeonTypes.put(this, dungeonType); //Hax...
|
|
|
|
}
|
|
|
|
|
|
|
|
public DungeonType getDungeonType()
|
|
|
|
{
|
|
|
|
DungeonType type = dungeonTypes.get(this);
|
|
|
|
if (type == null)
|
|
|
|
{
|
|
|
|
//Infer the dungeon's type from its file name
|
|
|
|
//There is minimal risk of us applying this to untagged dungeons and this'll be phased out
|
|
|
|
//when we get the new save format.
|
|
|
|
try
|
|
|
|
{
|
|
|
|
File file = new File(schematicPath);
|
|
|
|
String typeName = file.getName().split("_")[0];
|
|
|
|
type = DungeonHelper.instance().RuinsPack.getType(typeName);
|
|
|
|
}
|
|
|
|
catch (Exception e) { }
|
|
|
|
if (type == null)
|
|
|
|
{
|
|
|
|
type = DungeonType.UNKNOWN_TYPE;
|
|
|
|
}
|
|
|
|
dungeonTypes.put(this, type);
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
|
|
|
return (schematicPath != null) ? schematicPath.hashCode() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other)
|
|
|
|
{
|
|
|
|
return equals((DungeonGenerator) other);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(DungeonGenerator other)
|
2013-06-10 23:03:52 +02:00
|
|
|
{
|
2013-08-05 15:48:49 +02:00
|
|
|
return ((this.schematicPath != null && this.schematicPath.equals(other.schematicPath)) ||
|
|
|
|
(this.schematicPath == other.schematicPath));
|
2013-06-10 23:03:52 +02:00
|
|
|
}
|
|
|
|
}
|