Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significant upgrade for Maze worlds, more to come though
- Loading branch information
1 parent
1a56c45
commit 2a345c8
Showing
28 changed files
with
1,107 additions
and
417 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/me/daddychurchill/CityWorld/Context/Maze/MazeCampgroundContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package me.daddychurchill.CityWorld.Context.Maze; | ||
|
||
import me.daddychurchill.CityWorld.CityWorldGenerator; | ||
import me.daddychurchill.CityWorld.Plats.NatureLot; | ||
import me.daddychurchill.CityWorld.Plats.PlatLot; | ||
import me.daddychurchill.CityWorld.Plats.Nature.MountainTentLot; | ||
import me.daddychurchill.CityWorld.Support.Odds; | ||
import me.daddychurchill.CityWorld.Support.PlatMap; | ||
|
||
public class MazeCampgroundContext extends MazeConstructContext { | ||
|
||
public MazeCampgroundContext(CityWorldGenerator generator) { | ||
super(generator); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
protected PlatLot generateSpecialLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new MountainTentLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
@Override | ||
protected PlatLot generateNormalLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
if (odds.playOdds(Odds.oddsSomewhatUnlikely)) | ||
return new MountainTentLot(platmap, chunkX, chunkZ); | ||
else | ||
return new NatureLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/me/daddychurchill/CityWorld/Context/Maze/MazeCastleContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.daddychurchill.CityWorld.Context.Maze; | ||
|
||
import me.daddychurchill.CityWorld.CityWorldGenerator; | ||
import me.daddychurchill.CityWorld.Plats.NatureLot; | ||
import me.daddychurchill.CityWorld.Plats.PlatLot; | ||
import me.daddychurchill.CityWorld.Plats.Nature.OldCastleLot; | ||
import me.daddychurchill.CityWorld.Support.Odds; | ||
import me.daddychurchill.CityWorld.Support.PlatMap; | ||
|
||
public class MazeCastleContext extends MazeConstructContext { | ||
|
||
public MazeCastleContext(CityWorldGenerator generator) { | ||
super(generator); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
protected PlatLot generateSpecialLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new OldCastleLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
@Override | ||
protected PlatLot generateNormalLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new NatureLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
} |
132 changes: 132 additions & 0 deletions
132
src/me/daddychurchill/CityWorld/Context/Maze/MazeConstructContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package me.daddychurchill.CityWorld.Context.Maze; | ||
|
||
import me.daddychurchill.CityWorld.CityWorldGenerator; | ||
import me.daddychurchill.CityWorld.Plats.PlatLot; | ||
import me.daddychurchill.CityWorld.Support.HeightInfo; | ||
import me.daddychurchill.CityWorld.Support.Odds; | ||
import me.daddychurchill.CityWorld.Support.PlatMap; | ||
import me.daddychurchill.CityWorld.Support.SupportChunk; | ||
|
||
public abstract class MazeConstructContext extends MazeNatureContext { | ||
|
||
public MazeConstructContext(CityWorldGenerator generator) { | ||
super(generator); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
// private enum whatToBuild { | ||
// FARM, PARK, HOUSE, TOWN, CITY, UNFINISHED, STORAGE, | ||
// STATUE, FOREST, CAMPGROUND, CASTLE, BOX, THEPIT, // TREEHOUSE, PYRAMID, | ||
// | ||
// // 1.8 ones from here on, if you add more remember to update the numberWithNewStuff const | ||
// LAVA, WATER, MYSTERY}; | ||
// private int numberWithNewStuff = 3; | ||
// | ||
// private whatToBuild pickRandomWhat(CityWorldGenerator generator, Odds odds) { | ||
// if (generator.minecraftVer > 1.7) { | ||
// return whatToBuild.values()[odds.getRandomInt(whatToBuild.values().length)]; | ||
// } else { | ||
// return whatToBuild.values()[odds.getRandomInt(whatToBuild.values().length - numberWithNewStuff)]; | ||
// } | ||
// } | ||
|
||
private int openingWidth = 6; | ||
|
||
private double getSpecialOdds(Odds odds, int x, int z, boolean specialMade) { | ||
if (specialMade) | ||
return Odds.oddsNeverGoingToHappen; | ||
else if (x == openingWidth - 1 && z == openingWidth - 1) | ||
return Odds.oddsAlwaysGoingToHappen; | ||
else { | ||
double theOdds = Odds.oddsSomewhatLikely; | ||
if (x == 0 || x == openingWidth - 1) | ||
theOdds = theOdds / 2; | ||
if (z == 0 || z == openingWidth - 1) | ||
theOdds = theOdds / 2; | ||
return theOdds; | ||
} | ||
} | ||
|
||
private boolean placeSpecial(Odds odds, int x, int z, boolean specialMade) { | ||
double theOdds = getSpecialOdds(odds, x, z, specialMade); | ||
return odds.playOdds(theOdds); | ||
} | ||
|
||
protected abstract PlatLot generateSpecialLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ); | ||
protected abstract PlatLot generateNormalLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ); | ||
|
||
// I am pretty sure there is a GREAT reason to do this in this specific order but | ||
// for the life of me I can't remember why I do it this way. This just goes to show | ||
// you that you should comment the heck out of your code, especially the "clever" bits | ||
// Ok, I just remembered what this is about. By starting in the middle and circling out | ||
// there much better chance the special lot will be in the middle | ||
// private static int[] xS = {1, 2, 2, 1, 1, 2, 3, 3, 1, 2, 0, 0, 0, 3, 3, 0}; | ||
// private static int[] zS = {1, 1, 2, 2, 0, 0, 1, 2, 3, 3, 1, 2, 0, 0, 3, 3}; | ||
|
||
private static int[] xS = {2, 3, 3, 2, | ||
2, 3, 4, 4, 3, 2, 1, 1, 1, 4, 4, 1, | ||
1, 2, 3, 4, 5, 5, 5, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 5, 5, 0}; | ||
private static int[] zS = {2, 2, 3, 3, | ||
1, 1, 2, 3, 4, 4, 3, 2, 1, 1, 4, 4, | ||
0, 0, 0, 0, 1, 2, 3, 4, 5, 5, 5, 5, 4, 3, 2, 1, 0, 0, 5, 5}; | ||
|
||
@Override | ||
public void populateMap(CityWorldGenerator generator, PlatMap platmap) { | ||
|
||
// random stuff? | ||
Odds platmapOdds = platmap.getOddsGenerator(); | ||
// whatToBuild what = pickRandomWhat(generator, platmapOdds); | ||
// int waterDepth = ParkLot.getWaterDepth(platmapOdds); | ||
|
||
// where it all begins | ||
int originX = platmap.originX; | ||
int originZ = platmap.originZ; | ||
int offsetX = platmapOdds.getRandomInt(1, 3); | ||
int offsetZ = platmapOdds.getRandomInt(1, 3); | ||
HeightInfo heights; | ||
boolean specialMade = false; | ||
PlatLot lastOne = null; | ||
|
||
// what to build? | ||
for (int i = 0; i < xS.length; i++) { | ||
int x = xS[i]; | ||
int z = zS[i]; | ||
PlatLot current = platmap.getLot(offsetX + x, offsetZ + z); | ||
if (current == null) { | ||
|
||
// what is the world location of the lot? | ||
int chunkX = originX + offsetX + x; | ||
int chunkZ = originZ + offsetZ + z; | ||
int blockX = chunkX * SupportChunk.chunksBlockWidth; | ||
int blockZ = chunkZ * SupportChunk.chunksBlockWidth; | ||
|
||
// get the height info for this chunk | ||
heights = HeightInfo.getHeightsFaster(generator, blockX, blockZ); | ||
if (heights.isBuildable()) { | ||
if (placeSpecial(platmapOdds, x, z, specialMade)) { | ||
current = generateSpecialLot(platmap, platmapOdds, chunkX, chunkZ); | ||
specialMade = true; | ||
} else | ||
current = generateNormalLot(platmap, platmapOdds, chunkX, chunkZ); | ||
|
||
// put it somewhere then | ||
if (current != null) { | ||
|
||
// maybe? | ||
if (z != 0 && lastOne != null && lastOne.isConnectable(current)) | ||
current.makeConnected(lastOne); | ||
|
||
// place it | ||
platmap.setLot(offsetX + x, offsetZ + z, current); | ||
lastOne = current; | ||
} | ||
} | ||
} | ||
} | ||
|
||
//TODO surround the thing we just created with partial walls | ||
|
||
// pass on the effort | ||
super.populateMap(generator, platmap); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/me/daddychurchill/CityWorld/Context/Maze/MazeFarmContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.daddychurchill.CityWorld.Context.Maze; | ||
|
||
import me.daddychurchill.CityWorld.CityWorldGenerator; | ||
import me.daddychurchill.CityWorld.Plats.PlatLot; | ||
import me.daddychurchill.CityWorld.Plats.Rural.FarmLot; | ||
import me.daddychurchill.CityWorld.Plats.Rural.HouseLot; | ||
import me.daddychurchill.CityWorld.Support.Odds; | ||
import me.daddychurchill.CityWorld.Support.PlatMap; | ||
|
||
public class MazeFarmContext extends MazeConstructContext { | ||
|
||
public MazeFarmContext(CityWorldGenerator generator) { | ||
super(generator); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
protected PlatLot generateSpecialLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new HouseLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
@Override | ||
protected PlatLot generateNormalLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new FarmLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
src/me/daddychurchill/CityWorld/Context/Maze/MazeMineContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package me.daddychurchill.CityWorld.Context.Maze; | ||
|
||
import me.daddychurchill.CityWorld.CityWorldGenerator; | ||
import me.daddychurchill.CityWorld.Plats.PlatLot; | ||
import me.daddychurchill.CityWorld.Plats.Nature.GravelMineLot; | ||
import me.daddychurchill.CityWorld.Plats.Nature.GravelworksLot; | ||
import me.daddychurchill.CityWorld.Support.Odds; | ||
import me.daddychurchill.CityWorld.Support.PlatMap; | ||
|
||
public class MazeMineContext extends MazeConstructContext { | ||
|
||
public MazeMineContext(CityWorldGenerator generator) { | ||
super(generator); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
protected PlatLot generateSpecialLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new GravelMineLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
@Override | ||
protected PlatLot generateNormalLot(PlatMap platmap, Odds odds, int chunkX, int chunkZ) { | ||
return new GravelworksLot(platmap, chunkX, chunkZ); | ||
} | ||
|
||
} |
Oops, something went wrong.