public void EnsureMapFullyLoaded() { int chunksize = api.World.BlockAccessor.ChunkSize; nowVisible.Clear(); nowHidden.Clear(); Cuboidi chunkviewBounds = CurrentBlockViewBounds.ToCuboidi(); chunkviewBounds.Div(chunksize); BlockPos cur = new BlockPos().Set(chunkviewBounds.X1, 0, chunkviewBounds.Z1); bool beforeBoundsEmpty = chunkViewBoundsBefore.SizeX == 0 && chunkViewBoundsBefore.SizeZ == 0; while (cur.X <= chunkviewBounds.X2) { cur.Z = chunkviewBounds.Z1; while (cur.Z <= chunkviewBounds.Z2) { if (beforeBoundsEmpty || !chunkViewBoundsBefore.ContainsOrTouches(cur)) { nowVisible.Add(new Vec2i(cur.X, cur.Z)); } cur.Z++; } cur.X++; } cur.Set(chunkViewBoundsBefore.X1, 0, chunkViewBoundsBefore.Z1); while (cur.X <= chunkViewBoundsBefore.X2) { cur.Z = chunkViewBoundsBefore.Z1; while (cur.Z <= chunkViewBoundsBefore.Z2) { if (!chunkviewBounds.ContainsOrTouches(cur)) { nowHidden.Add(new Vec2i(cur.X, cur.Z)); } cur.Z++; } cur.X++; } chunkViewBoundsBefore = chunkviewBounds.Clone(); if (nowHidden.Count > 0 || nowVisible.Count > 0) { viewChanged(nowVisible, nowHidden); } }
public void EnsureMapFullyLoaded() { int chunksize = api.World.BlockAccessor.ChunkSize; nowVisible.Clear(); nowHidden.Clear(); Cuboidi worldBounds = CurrentViewBounds.ToCuboidi(); worldBounds.Div(chunksize); //worldBounds.GrowBy(1); BlockPos cur = new BlockPos().Set(worldBounds.X1, 0, worldBounds.Z1); // StringBuilder debug = new StringBuilder(); while (cur.X <= worldBounds.X2) { cur.Z = worldBounds.Z1; while (cur.Z <= worldBounds.Z2) { if (!worldBoundsBefore.ContainsOrTouches(cur)) { nowVisible.Add(new Vec2i(cur.X, cur.Z)); // debug.Append(string.Format("{0}/{1}, ", cur.X, cur.Z)); } cur.Z++; } cur.X++; } // if (nowVisible.Count > 0) Console.WriteLine("{0} chunks now visible: {1}", nowVisible.Count, debug.ToString()); cur.Set(worldBoundsBefore.X1, 0, worldBoundsBefore.Z1); while (cur.X <= worldBoundsBefore.X2) { cur.Z = worldBoundsBefore.Z1; while (cur.Z <= worldBoundsBefore.Z2) { if (!worldBounds.ContainsOrTouches(cur)) { nowHidden.Add(new Vec2i(cur.X, cur.Z)); } cur.Z++; } cur.X++; } worldBoundsBefore = worldBounds.Clone(); viewChanged(nowVisible, nowHidden); }