Switch to a serious name I like

This commit is contained in:
polytomous 2017-11-08 23:48:19 -08:00
parent 22b944a189
commit 0bb3541d23
21 changed files with 44 additions and 44 deletions

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace TrueCraft.API.World namespace TrueCraft.API.World
{ {
public interface IChunk : IEventSubject, IDisposable, ApplesauceChunk public interface IChunk : IEventSubject, IDisposable, ISpatialBlockInformationProvider
{ {
bool IsModified { get; set; } bool IsModified { get; set; }
bool LightPopulated { get; set; } bool LightPopulated { get; set; }

View File

@ -11,6 +11,6 @@ namespace TrueCraft.API.World
/// </summary> /// </summary>
public interface IChunkDecorator public interface IChunkDecorator
{ {
void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository); void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository);
} }
} }

View File

@ -8,6 +8,6 @@ namespace TrueCraft.API.World
public interface IDecoration public interface IDecoration
{ {
bool ValidLocation(Coordinates3D location); bool ValidLocation(Coordinates3D location);
bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location); bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location);
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace TrueCraft.API.World namespace TrueCraft.API.World
{ {
public interface ApplesauceChunk public interface ISpatialBlockInformationProvider
{ {
int X {get;} int X {get;}
int Z { get; } int Z { get; }

View File

@ -22,7 +22,7 @@ namespace TrueCraft.Core.Test.World
public void DecoratorGrowsNoInvalidSugarCane() public void DecoratorGrowsNoInvalidSugarCane()
{ {
var aWorld = new WorldWithJustASeed(9001); var aWorld = new WorldWithJustASeed(9001);
ApplesauceChunk aChunk = new PrimeSugarCaneGrowingSeasonChunk(); ISpatialBlockInformationProvider aChunk = new PrimeSugarCaneGrowingSeasonChunk();
IBiomeRepository aBiomeRepository = new BiomeRepository(); IBiomeRepository aBiomeRepository = new BiomeRepository();
var decorator = GetDecoratorForTestChunk(aWorld, aChunk, aBiomeRepository); var decorator = GetDecoratorForTestChunk(aWorld, aChunk, aBiomeRepository);
@ -35,7 +35,7 @@ namespace TrueCraft.Core.Test.World
public void DecoratorDoesNotGrowSugarcaneUniformly() public void DecoratorDoesNotGrowSugarcaneUniformly()
{ {
IWorldSeed aWorld = new WorldWithJustASeed(9001); IWorldSeed aWorld = new WorldWithJustASeed(9001);
ApplesauceChunk aChunk = new PrimeSugarCaneGrowingSeasonChunk(); ISpatialBlockInformationProvider aChunk = new PrimeSugarCaneGrowingSeasonChunk();
IBiomeRepository aBiomeRepository = new BiomeRepository(); IBiomeRepository aBiomeRepository = new BiomeRepository();
var decorator = GetDecoratorForTestChunk(aWorld, aChunk, aBiomeRepository); var decorator = GetDecoratorForTestChunk(aWorld, aChunk, aBiomeRepository);
@ -44,7 +44,7 @@ namespace TrueCraft.Core.Test.World
AssertChunkSugarCaneGrowthIsNotUniform(aChunk); AssertChunkSugarCaneGrowthIsNotUniform(aChunk);
} }
private void AssertChunkHasNoSugarCaneInColumnsWhereItShouldNot(ApplesauceChunk aChunk) private void AssertChunkHasNoSugarCaneInColumnsWhereItShouldNot(ISpatialBlockInformationProvider aChunk)
{ {
for (int x = 0; x < 6; x++) for (int x = 0; x < 6; x++)
{ {
@ -59,7 +59,7 @@ namespace TrueCraft.Core.Test.World
} }
} }
private void AssertChunkSugarCaneGrowthIsNotUniform(ApplesauceChunk aChunk) private void AssertChunkSugarCaneGrowthIsNotUniform(ISpatialBlockInformationProvider aChunk)
{ {
var counts = new List<double>(); var counts = new List<double>();
for (int x = 0; x < 6; x++) for (int x = 0; x < 6; x++)
@ -82,7 +82,7 @@ namespace TrueCraft.Core.Test.World
} }
} }
private static SugarCaneDecorator GetDecoratorForTestChunk(IWorldSeed aWorld, ApplesauceChunk aChunk, private static SugarCaneDecorator GetDecoratorForTestChunk(IWorldSeed aWorld, ISpatialBlockInformationProvider aChunk,
IBiomeRepository aBiomeRepository) IBiomeRepository aBiomeRepository)
{ {
var decorator = new SugarCaneDecorator(new NoiseAlwaysGrowsSugarCaneInTestBounds()); var decorator = new SugarCaneDecorator(new NoiseAlwaysGrowsSugarCaneInTestBounds());
@ -90,7 +90,7 @@ namespace TrueCraft.Core.Test.World
return decorator; return decorator;
} }
static int CountBlockInColumn(ApplesauceChunk aChunk, int x, int z, byte blockId) static int CountBlockInColumn(ISpatialBlockInformationProvider aChunk, int x, int z, byte blockId)
{ {
int counter = 0; int counter = 0;
@ -113,7 +113,7 @@ namespace TrueCraft.Core.Test.World
var ourDictionary = PrimeSugarCaneGrowingSeasonChunk.createStartingBlockDictionary(); var ourDictionary = PrimeSugarCaneGrowingSeasonChunk.createStartingBlockDictionary();
Mock<ApplesauceChunk> aChunk = new Mock<ApplesauceChunk>(); Mock<ISpatialBlockInformationProvider> aChunk = new Mock<ISpatialBlockInformationProvider>();
aChunk.Setup(foo => foo.GetBlockID(It.IsAny<Coordinates3D>())).Returns((Coordinates3D coordinates) => aChunk.Setup(foo => foo.GetBlockID(It.IsAny<Coordinates3D>())).Returns((Coordinates3D coordinates) =>
{ {

View File

@ -8,7 +8,7 @@ using TrueCraft.Core.Logic.Blocks;
using TrueCraft.Core.TerrainGen.Biomes; using TrueCraft.Core.TerrainGen.Biomes;
using TrueCraft.Core.World; using TrueCraft.Core.World;
public class PrimeSugarCaneGrowingSeasonChunk : ApplesauceChunk public class PrimeSugarCaneGrowingSeasonChunk : ISpatialBlockInformationProvider
{ {
public int X => 6; public int X => 6;
public int Z => 6; public int Z => 6;
@ -172,7 +172,7 @@ public class PrimeSugarCaneGrowingSeasonChunk : ApplesauceChunk
return result; return result;
} }
byte ApplesauceChunk.GetMetadata(Coordinates3D locationToCheck) byte ISpatialBlockInformationProvider.GetMetadata(Coordinates3D locationToCheck)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -26,7 +26,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
if (!ValidLocation(location)) if (!ValidLocation(location))
return false; return false;

View File

@ -25,7 +25,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
if (!ValidLocation(location)) if (!ValidLocation(location))
return false; return false;

View File

@ -13,7 +13,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
{ {
const int LeafRadius = 2; const int LeafRadius = 2;
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
if (!ValidLocation(location)) if (!ValidLocation(location))
return false; return false;

View File

@ -12,7 +12,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
{ {
public virtual bool ValidLocation(Coordinates3D location) { return true; } public virtual bool ValidLocation(Coordinates3D location) { return true; }
public abstract bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location); public abstract bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location);
public static bool IsCuboidWall(Coordinates2D location, Coordinates3D start, Vector3 size) public static bool IsCuboidWall(Coordinates2D location, Coordinates3D start, Vector3 size)
{ {
@ -30,7 +30,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
|| location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z + (int)size.Z - 1); || location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z + (int)size.Z - 1);
} }
public static bool NeighboursBlock(ApplesauceChunk chunk, Coordinates3D location, byte block, byte meta = 0x0) public static bool NeighboursBlock(ISpatialBlockInformationProvider chunk, Coordinates3D location, byte block, byte meta = 0x0)
{ {
var surrounding = new[] { var surrounding = new[] {
location + Coordinates3D.Left, location + Coordinates3D.Left,
@ -53,7 +53,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return false; return false;
} }
public static void GenerateColumn(ApplesauceChunk chunk, Coordinates3D location, int height, byte block, byte meta = 0x0) public static void GenerateColumn(ISpatialBlockInformationProvider chunk, Coordinates3D location, int height, byte block, byte meta = 0x0)
{ {
for (int offset = 0; offset < height; offset++) for (int offset = 0; offset < height; offset++)
{ {
@ -71,7 +71,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
* 0x1 - Hollow cuboid of the specified block * 0x1 - Hollow cuboid of the specified block
* 0x2 - Outlines the area of the cuboid using the specified block * 0x2 - Outlines the area of the cuboid using the specified block
*/ */
public static void GenerateCuboid(ApplesauceChunk chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0) public static void GenerateCuboid(ISpatialBlockInformationProvider chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0)
{ {
//If mode is 0x2 offset the size by 2 and change mode to 0x1 //If mode is 0x2 offset the size by 2 and change mode to 0x1
if (mode.Equals(0x2)) if (mode.Equals(0x2))
@ -102,7 +102,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
protected void GenerateVanillaLeaves(ApplesauceChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0) protected void GenerateVanillaLeaves(ISpatialBlockInformationProvider chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
{ {
int radiusOffset = radius; int radiusOffset = radius;
for (int yOffset = -radius; yOffset <= radius; yOffset = (yOffset + 1)) for (int yOffset = -radius; yOffset <= radius; yOffset = (yOffset + 1))
@ -116,7 +116,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
protected void GenerateVanillaCircle(ApplesauceChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0, double corner = 0) protected void GenerateVanillaCircle(ISpatialBlockInformationProvider chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0, double corner = 0)
{ {
for (int i = -radius; i <= radius; i = (i + 1)) for (int i = -radius; i <= radius; i = (i + 1))
{ {
@ -146,7 +146,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
protected void GenerateCircle(ApplesauceChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0) protected void GenerateCircle(ISpatialBlockInformationProvider chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
{ {
for (int i = -radius; i <= radius; i = (i + 1)) for (int i = -radius; i <= radius; i = (i + 1))
{ {
@ -172,7 +172,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
protected static void GenerateSphere(ApplesauceChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0) protected static void GenerateSphere(ISpatialBlockInformationProvider chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
{ {
for (int i = -radius; i <= radius; i = (i + 1)) for (int i = -radius; i <= radius; i = (i + 1))
{ {

View File

@ -26,7 +26,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
Console.WriteLine("Dungeon in chunk {0}", chunk.Coordinates); Console.WriteLine("Dungeon in chunk {0}", chunk.Coordinates);
if (!ValidLocation(location)) if (!ValidLocation(location))
@ -52,7 +52,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
private void CreateEntraces(ApplesauceChunk chunk, Coordinates3D location, Random random) private void CreateEntraces(ISpatialBlockInformationProvider chunk, Coordinates3D location, Random random)
{ {
int entrances = 0; int entrances = 0;
var above = location + Coordinates3D.Up; var above = location + Coordinates3D.Up;
@ -80,7 +80,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
private void MossFloor(ApplesauceChunk chunk, Coordinates3D location, Random random) private void MossFloor(ISpatialBlockInformationProvider chunk, Coordinates3D location, Random random)
{ {
for (int x = location.X; x < location.X + Size.X; x++) for (int x = location.X; x < location.X + Size.X; x++)
{ {
@ -96,7 +96,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
} }
} }
private void PlaceChests(ApplesauceChunk chunk, Coordinates3D location, Random random) private void PlaceChests(ISpatialBlockInformationProvider chunk, Coordinates3D location, Random random)
{ {
var above = location + Coordinates3D.Up; var above = location + Coordinates3D.Up;
var chests = random.Next(0, 2); var chests = random.Next(0, 2);

View File

@ -23,7 +23,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
if (!ValidLocation(location)) if (!ValidLocation(location))
return false; return false;

View File

@ -23,7 +23,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
return true; return true;
} }
public override bool GenerateAt(IWorldSeed world, ApplesauceChunk chunk, Coordinates3D location) public override bool GenerateAt(IWorldSeed world, ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
if (!ValidLocation(location)) if (!ValidLocation(location))
return false; return false;
@ -51,7 +51,7 @@ namespace TrueCraft.Core.TerrainGen.Decorations
* 0x0 - two level topper * 0x0 - two level topper
* 0x1 - three level topper * 0x1 - three level topper
*/ */
protected void GenerateTopper(ApplesauceChunk chunk, Coordinates3D location, byte type = 0x0) protected void GenerateTopper(ISpatialBlockInformationProvider chunk, Coordinates3D location, byte type = 0x0)
{ {
const int sectionRadius = 1; const int sectionRadius = 1;
GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockID, 0x1); GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockID, 0x1);

View File

@ -14,7 +14,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
{ {
public class CactusDecorator : IChunkDecorator public class CactusDecorator : IChunkDecorator
{ {
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
var noise = new Perlin(world.Seed); var noise = new Perlin(world.Seed);
var chanceNoise = new ClampNoise(noise); var chanceNoise = new ClampNoise(noise);

View File

@ -21,7 +21,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
this.BaseLevel = groundLevel; this.BaseLevel = groundLevel;
} }
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
for (int attempts = 0; attempts < 8; attempts++) for (int attempts = 0; attempts < 8; attempts++)
{ {

View File

@ -12,7 +12,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
{ {
class FreezeDecorator : IChunkDecorator class FreezeDecorator : IChunkDecorator
{ {
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
{ {
@ -51,7 +51,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
} }
} }
bool CoverIce(ApplesauceChunk chunk, IBiomeRepository biomes, Coordinates3D location) bool CoverIce(ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, Coordinates3D location)
{ {
const int maxDistance = 4; const int maxDistance = 4;
var adjacent = new[] { var adjacent = new[] {

View File

@ -15,7 +15,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
{ {
public static readonly int WaterLevel = 40; public static readonly int WaterLevel = 40;
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
for (int x = 0; x < Chunk.Width; x++) for (int x = 0; x < Chunk.Width; x++)
{ {

View File

@ -54,7 +54,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
Ores.Add(redstone); Ores.Add(redstone);
} }
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
var perlin = new Perlin(world.Seed); var perlin = new Perlin(world.Seed);
perlin.Lacunarity = 1; perlin.Lacunarity = 1;

View File

@ -13,7 +13,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
{ {
public class PlantDecorator : IChunkDecorator public class PlantDecorator : IChunkDecorator
{ {
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
var noise = new Perlin(world.Seed); var noise = new Perlin(world.Seed);
var chanceNoise = new ClampNoise(noise); var chanceNoise = new ClampNoise(noise);
@ -68,23 +68,23 @@ namespace TrueCraft.Core.TerrainGen.Decorators
} }
} }
void GenerateRose(ApplesauceChunk chunk, Coordinates3D location) void GenerateRose(ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
chunk.SetBlockID(location, RoseBlock.BlockID); chunk.SetBlockID(location, RoseBlock.BlockID);
} }
void GenerateDandelion(ApplesauceChunk chunk, Coordinates3D location) void GenerateDandelion(ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
chunk.SetBlockID(location, DandelionBlock.BlockID); chunk.SetBlockID(location, DandelionBlock.BlockID);
} }
void GenerateTallGrass(ApplesauceChunk chunk, Coordinates3D location, byte meta) void GenerateTallGrass(ISpatialBlockInformationProvider chunk, Coordinates3D location, byte meta)
{ {
chunk.SetBlockID(location, TallGrassBlock.BlockID); chunk.SetBlockID(location, TallGrassBlock.BlockID);
chunk.SetMetadata(location, meta); chunk.SetMetadata(location, meta);
} }
void GenerateDeadBush(ApplesauceChunk chunk, Coordinates3D location) void GenerateDeadBush(ISpatialBlockInformationProvider chunk, Coordinates3D location)
{ {
chunk.SetBlockID(location, DeadBushBlock.BlockID); chunk.SetBlockID(location, DeadBushBlock.BlockID);
} }

View File

@ -25,7 +25,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
{ {
suppliedNoise = suppliedNoiseSource; suppliedNoise = suppliedNoiseSource;
} }
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
NoiseGen noise; NoiseGen noise;
if (suppliedNoise == null) if (suppliedNoise == null)

View File

@ -17,7 +17,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
public Perlin Noise { get; set; } public Perlin Noise { get; set; }
public ClampNoise ChanceNoise { get; set; } public ClampNoise ChanceNoise { get; set; }
public void Decorate(IWorldSeed world, ApplesauceChunk chunk, IBiomeRepository biomes, IBlockRepository blockRepository) public void Decorate(IWorldSeed world, ISpatialBlockInformationProvider chunk, IBiomeRepository biomes, IBlockRepository blockRepository)
{ {
Noise = new Perlin(world.Seed); Noise = new Perlin(world.Seed);
ChanceNoise = new ClampNoise(Noise); ChanceNoise = new ClampNoise(Noise);