/// <summary> /// Constructs a new map. Requires a BlockHandler to get things done, as well as /// a starting center position to begin caching from. /// </summary> /// <param name="handler"></param> /// <param name="startCenterChunkX"></param> /// <param name="startCenterChunkZ"></param> public Map(int startCenterChunkX, int startCenterChunkZ) { this.CenterChunkX = startCenterChunkX; this.CenterChunkZ = startCenterChunkZ; this.Cache = new ChunkCache(this, CacheRadius); }
/// <summary> /// Called when the data in this object is no longer what we /// want it to be. The arguments are used to determine if we /// really need to mark this as a new task (if it's already /// saved, don't bother, it's just extra work). /// </summary> /// <param name="newChunkX"></param> /// <param name="newChunkZ"></param> /// <param name="cache"></param> public void Invalidate(int newChunkX, int newChunkZ, ChunkCache cache) { lock (this) { if (cache.HasSavedChunk(newChunkX, newChunkZ)) { NeedsToBeLoaded = false; } else { NeedsToBeLoaded = true; } EntitiesSpawned = false; TouchingEntities.Clear(); } }
/// <summary> /// Called when the data in this object is no longer what we /// want it to be. The arguments are used to determine if we /// really need to mark this as a new task (if it's already /// saved, don't bother, it's just extra work). /// </summary> /// <param name="newChunkX"></param> /// <param name="newChunkZ"></param> /// <param name="cache"></param> public void Invalidate(int newChunkX, int newChunkZ, ChunkCache cache) { lock (this) { if (cache.HasSavedChunk(newChunkX, newChunkZ)) NeedsToBeLoaded = false; else NeedsToBeLoaded = true; EntitiesSpawned = false; TouchingEntities.Clear(); } }