public static Vector3[] Positions4(string worldseed, Vector3i chunk, int maxsize) { Printer.Log(55, "ZChunk.Positions4 start", worldseed, chunk, maxsize); int len00 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x, chunk.z)); int len10 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x + 1, chunk.z)); int len01 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x, chunk.z + 1)); int len11 = Hashes.Rand(1, maxsize, String.Format("{0}{1}", chunk.x + 1, chunk.z + 1)); List <Vector3> pos = new List <Vector3>(); for (int index = 0; index < maxsize; index++) // todo : 4 boolean to optimize test and break { if (index < len00) { pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk, index)); } if (index < len10) { pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(1, 0, 0), index)); } if (index < len01) { pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(0, 0, 1), index)); } if (index < len11) { pos.Append(ZChunk.Position(Zombiome.worldSeed, chunk + new Vector3i(1, 0, 1), index)); } } Printer.Log(55, "ZChunk.Positions4 OK", pos.Count(), pos); return(pos.ToArray()); }
public override IEnumerator<Vector3> Get(Vector3 position) { int maxsize = 10; Vector3i zchunk = ZChunk.TL4(position); bool D0 = false; int L0 = ZChunk.Len(zchunk + ZChunk.adjacents[0], maxsize); bool D1 = false; int L1 = ZChunk.Len(zchunk + ZChunk.adjacents[1], maxsize); bool D2 = false; int L2 = ZChunk.Len(zchunk + ZChunk.adjacents[2], maxsize); bool D3 = false; int L3 = ZChunk.Len(zchunk + ZChunk.adjacents[3], maxsize); for (int step=0; step<maxsize; step++) { if (! D0 && step > L0) D0 = true; if (! D0) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[0], step); if (! D1 && step > L1) D1 = true; if (! D1) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[1], step); if (! D2 && step > L2) D2 = true; if (! D2) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[2], step); if (! D3 && step > L3) D3 = true; if (! D3) yield return ZChunk.Position(Zombiome.worldSeed, zchunk + ZChunk.adjacents[3], step); if (D0 && D1 && D2 && D3) break; } }