Getting ready for release candidate
This commit is contained in:
parent
084e3dd348
commit
96930fc47a
18 changed files with 477 additions and 69 deletions
|
@ -36,6 +36,9 @@ import com.google.gson.GsonBuilder;
|
|||
|
||||
public class TEDemonPortal extends TileEntity
|
||||
{
|
||||
public static int buildingGridDelay = 25;
|
||||
public static int roadGridDelay = 10;
|
||||
|
||||
public static List<DemonBuilding> buildingList = new ArrayList();
|
||||
public Random rand = new Random();
|
||||
private GridSpace[][] area;
|
||||
|
@ -105,12 +108,41 @@ public class TEDemonPortal extends TileEntity
|
|||
}
|
||||
}
|
||||
|
||||
this.houseCooldown = 1000;
|
||||
this.roadCooldown = 100;
|
||||
this.houseCooldown = TEDemonPortal.buildingGridDelay;
|
||||
this.roadCooldown = TEDemonPortal.roadGridDelay;
|
||||
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(!isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.roadCooldown <= 0)
|
||||
{
|
||||
int roadsMade = this.createRandomRoad();
|
||||
if(roadsMade > 0)
|
||||
{
|
||||
this.roadCooldown = TEDemonPortal.roadGridDelay * roadsMade;
|
||||
}
|
||||
}
|
||||
else if(this.houseCooldown <= 0)
|
||||
{
|
||||
int gridsUsed = this.createRandomBuilding(0, 0);
|
||||
if(gridsUsed > 0)
|
||||
{
|
||||
this.houseCooldown = TEDemonPortal.buildingGridDelay * gridsUsed;
|
||||
}
|
||||
}
|
||||
|
||||
this.houseCooldown = Math.max(0, this.houseCooldown - 1);
|
||||
this.roadCooldown = Math.max(0, this.roadCooldown - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
|
@ -140,6 +172,9 @@ public class TEDemonPortal extends TileEntity
|
|||
}
|
||||
|
||||
this.isInitialized = par1NBTTagCompound.getBoolean("init");
|
||||
|
||||
this.tier = par1NBTTagCompound.getInteger("tier");
|
||||
this.totalPoints = par1NBTTagCompound.getInteger("totalPoints");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,6 +214,8 @@ public class TEDemonPortal extends TileEntity
|
|||
par1NBTTagCompound.setTag("Grid", gridList);
|
||||
|
||||
par1NBTTagCompound.setBoolean("init", isInitialized);
|
||||
par1NBTTagCompound.setInteger("tier", this.tier);
|
||||
par1NBTTagCompound.setInteger("totalPoints", this.totalPoints);
|
||||
}
|
||||
|
||||
public int createRandomRoad() //Return the number of road spaces
|
||||
|
@ -745,7 +782,6 @@ public class TEDemonPortal extends TileEntity
|
|||
{
|
||||
return;
|
||||
}
|
||||
Int3 roadMarker = this.getNextRoadMarker();
|
||||
|
||||
this.initialize();
|
||||
|
||||
|
@ -761,20 +797,20 @@ public class TEDemonPortal extends TileEntity
|
|||
}
|
||||
}
|
||||
|
||||
public void createRandomBuilding(int type, int tier)
|
||||
public int createRandomBuilding(int type, int tier)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case DemonBuilding.BUILDING_HOUSE:
|
||||
this.createRandomHouse(tier);
|
||||
break;
|
||||
return this.createRandomHouse(tier);
|
||||
case DemonBuilding.BUILDING_PORTAL:
|
||||
this.createPortalBuilding(tier);
|
||||
break;
|
||||
return this.createPortalBuilding(tier);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void createPortalBuilding(int buildingTier)
|
||||
public int createPortalBuilding(int buildingTier)
|
||||
{
|
||||
int x = 0;
|
||||
int z = 0;
|
||||
|
@ -797,7 +833,7 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
if(directions.isEmpty())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
|
||||
|
@ -823,7 +859,7 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
if(schemMap.keySet().isEmpty())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
|
||||
|
@ -847,9 +883,11 @@ public class TEDemonPortal extends TileEntity
|
|||
build.buildAll(worldObj, xCoord + (x)*5, yLevel, zCoord + (z)*5, chosenDirection.getOpposite());
|
||||
build.setAllGridSpaces(x, z, yLevel, chosenDirection.getOpposite(), GridSpace.MAIN_PORTAL, grid);
|
||||
this.loadGSH(grid);
|
||||
|
||||
return build.getNumberOfGridSpaces();
|
||||
}
|
||||
|
||||
public void createRandomHouse(int buildingTier)
|
||||
public int createRandomHouse(int buildingTier)
|
||||
{
|
||||
int next = rand.nextInt(4);
|
||||
ForgeDirection dir;
|
||||
|
@ -872,8 +910,6 @@ public class TEDemonPortal extends TileEntity
|
|||
dir = ForgeDirection.NORTH;
|
||||
}
|
||||
|
||||
int length = 5;
|
||||
|
||||
boolean newProtocol = true;
|
||||
|
||||
if(newProtocol)
|
||||
|
@ -890,7 +926,7 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
if(!this.getGridSpace(x, z).isRoadSegment())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
List<ForgeDirection> directions = new ArrayList();
|
||||
|
@ -906,7 +942,7 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
if(directions.isEmpty())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HashMap<ForgeDirection, List<DemonBuilding>> schemMap = new HashMap();
|
||||
|
@ -942,7 +978,7 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
if(schemMap.keySet().isEmpty())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ForgeDirection chosenDirection = (ForgeDirection) schemMap.keySet().toArray()[new Random().nextInt(schemMap.keySet().size())];
|
||||
|
@ -956,6 +992,8 @@ public class TEDemonPortal extends TileEntity
|
|||
build.buildAll(worldObj, xCoord + (x + xOff)*5, yLevel, zCoord + (z + zOff)*5, chosenDirection.getOpposite());
|
||||
build.setAllGridSpaces(x + xOff, z + zOff, yLevel, chosenDirection.getOpposite(), GridSpace.HOUSE, grid);
|
||||
this.loadGSH(grid);
|
||||
|
||||
return build.getNumberOfGridSpaces();
|
||||
}else
|
||||
{
|
||||
Int3 space = findEmptySpaceNearRoad(dir, 3*(rand.nextInt(negXRadius + negZRadius + posXRadius + posZRadius))+1, 2);
|
||||
|
@ -967,12 +1005,12 @@ public class TEDemonPortal extends TileEntity
|
|||
GridSpace newSpace = this.getGridSpace(x, z);
|
||||
if(!newSpace.isEmpty())
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(yLevel == -1)
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
GridSpaceHolder grid = this.createGSH();
|
||||
|
@ -1012,7 +1050,7 @@ public class TEDemonPortal extends TileEntity
|
|||
build = buildingList.get(new Random().nextInt(buildingList.size()));
|
||||
}else
|
||||
{
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
//TODO: Finish the selection algorythm
|
||||
//TODO: Should favour those directions that have a road right next to them.
|
||||
|
@ -1021,7 +1059,8 @@ public class TEDemonPortal extends TileEntity
|
|||
build.setAllGridSpaces(x, z, yLevel, chosenDirection, GridSpace.HOUSE, grid);
|
||||
this.loadGSH(grid);
|
||||
|
||||
System.out.println("X: " + x + " Z: " + z + " Direction: " + chosenDirection.toString());
|
||||
return build.getNumberOfGridSpaces();
|
||||
// System.out.println("X: " + x + " Z: " + z + " Direction: " + chosenDirection.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1091,34 +1130,6 @@ public class TEDemonPortal extends TileEntity
|
|||
return 10;
|
||||
}
|
||||
|
||||
public Block getRoadMarker()
|
||||
{
|
||||
return ModBlocks.ritualStone;
|
||||
}
|
||||
|
||||
public Int3 getNextRoadMarker()
|
||||
{
|
||||
int horizSearchMax = 25;
|
||||
int vertSearchMax = 10;
|
||||
|
||||
for(int xPos=xCoord-horizSearchMax; xPos<=xCoord+horizSearchMax; xPos++)
|
||||
{
|
||||
for(int zPos=zCoord-horizSearchMax; zPos<=zCoord+horizSearchMax; zPos++)
|
||||
{
|
||||
for(int yPos=yCoord-vertSearchMax; yPos<=yCoord+vertSearchMax; yPos++)
|
||||
{
|
||||
Block block = worldObj.getBlock(xPos, yPos, zPos);
|
||||
if(block == this.getRoadMarker())
|
||||
{
|
||||
return new Int3(xPos,yPos,zPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRoadSpacer()
|
||||
{
|
||||
return 1;
|
||||
|
@ -1177,4 +1188,14 @@ public class TEDemonPortal extends TileEntity
|
|||
|
||||
|
||||
}
|
||||
|
||||
public int getTotalPoints()
|
||||
{
|
||||
return this.totalPoints;
|
||||
}
|
||||
|
||||
public void addToPoints(int addition)
|
||||
{
|
||||
this.totalPoints += addition;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue