Layer-and-chunk classes (no internal layers)
The template below contains just the minimal structure needed in a layer-and-chunk pair of classes without further example code.
public class ExampleChunk : LayerChunk<ExampleLayer, ExampleChunk> {
public override void Create(int level, bool destroy) {
if (destroy) {
}
else {
}
}
}
public class ExampleLayer : ChunkBasedDataLayer<ExampleLayer, ExampleChunk> {
public override int chunkW { get { return 256; } }
public override int chunkH { get { return 256; } }
public ExampleLayer() {
}
}
Definition CollectionExtensions.cs:12
Definition AbstractDataLayer.cs:13
Layer-and-chunk classes with internal layers
The template below is for a layer-and-chunk pair of classes with multiple internal layer levels.
public class ExampleChunk : LayerChunk<ExampleLayer, ExampleChunk> {
public override void Create(int level, bool destroy) {
if (level == (int)ExampleLayer.Levels.Level0) {
if (destroy) {
}
else {
}
}
if (level == (int)ExampleLayer.Levels.Level1) {
if (destroy) {
}
else {
}
}
if (level == (int)ExampleLayer.Levels.Level2) {
if (destroy) {
}
else {
}
}
}
}
public class ExampleLayer : ChunkBasedDataLayer<ExampleLayer, ExampleChunk> {
public override int chunkW { get { return 256; } }
public override int chunkH { get { return 256; } }
public enum Levels { Level0, Level1, Level2, Length }
public override int GetLevelCount() { return (int)Levels.Length; }
public ExampleLayer() {
}
public IEnumerable<ExampleChunk> GetNeighborChunks(ExampleChunk chunk) {
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
yield return chunks[chunk.index.x + i, chunk.index.y + j];
}
}
}
}
Intermediary base classes
If you have functionality you want to share between all your layers, or just multiple of your layers, you can off course modify the ChunkBasedDataLayer and LayerChunk classes directly.
However, if you'd prefer not to alter the classes of the LayerProcGen framework, you can instead implement intermediary classes with custom functionality and make your layers derive from those. You can use the template below as a starting point for that.
public abstract class MyBaseLayerChunk<L, C> : LayerChunk<L, C>
where L : MyBaseChunkBasedDataLayer<L, C>, new()
where C : MyBaseLayerChunk<L, C>, new()
{
}
public abstract class MyBaseChunkBasedDataLayer<L, C> : ChunkBasedDataLayer<L, C>
where L : MyBaseChunkBasedDataLayer<L, C>, new()
where C : MyBaseLayerChunk<L, C>, new()
{
}