Example #1
0
 /// <summary>
 /// Erzeugt eine neue Instanz einer ChunkColumn.
 /// </summary>
 public ChunkColumn(IPlanet planet)
 {
     Heights           = new int[Chunk.CHUNKSIZE_X, Chunk.CHUNKSIZE_Y];
     entities          = new EntityList(this);
     entitieSemaphore  = new LockSemaphore(1, 1);
     DefinitionManager = TypeContainer.Get <IDefinitionManager>();
     Planet            = planet;
     globalChunkCache  = planet.GlobalChunkCache;
 }
Example #2
0
        /// <summary>
        /// Instanziert einen neuen local Chunk Cache.
        /// </summary>
        /// <param name="globalCache">Referenz auf global Chunk Cache</param>
        /// <param name="dimensions">Größe des Caches in Zweierpotenzen</param>
        /// <param name="range">Gibt die Range in alle Richtungen an.</param>
        public LocalChunkCache(IGlobalChunkCache globalCache, int dimensions, int range)
        {
            if (1 << dimensions < (range * 2) + 1)
                throw new ArgumentException("Range too big");

            this.globalCache = globalCache;
            this.range = range;

            limit = dimensions;
            mask = (1 << limit) - 1;
            chunkColumns = new IChunkColumn[(mask + 1) * (mask + 1)];
        }
        /// <summary>
        /// Instanziert einen neuen local Chunk Cache.
        /// </summary>
        /// <param name="globalCache">Referenz auf global Chunk Cache</param>
        /// <param name="dimensions">Größe des Caches in Zweierpotenzen</param>
        /// <param name="range">Gibt die Range in alle Richtungen an.</param>
        public LocalChunkCache(IGlobalChunkCache globalCache, int dimensions, int range)
        {
            if (1 << dimensions < (range * 2) + 1)
            {
                throw new ArgumentException("Range too big");
            }

            this.globalCache = globalCache;
            this.range       = range;

            limit        = dimensions;
            mask         = (1 << limit) - 1;
            chunkColumns = new IChunkColumn[(mask + 1) * (mask + 1)];
        }
Example #4
0
        /// <summary>
        /// Instanziert einen neuen local Chunk Cache.
        /// </summary>
        /// <param name="globalCache">Referenz auf global Chunk Cache</param>
        /// <param name="dimensions">Größe des Caches in Zweierpotenzen</param>
        /// <param name="range">Gibt die Range in alle Richtungen an.</param>
        public LocalChunkCache(IGlobalChunkCache globalCache, int dimensions, int range)
        {
            if (1 << dimensions < (range * 2) + 1)
                throw new ArgumentException("Range too big");

            
            semaphore = new LockSemaphore(1, 1);
            taskSemaphore = new LockSemaphore(1, 1);
            Planet = globalCache.Planet;
            this.globalCache = globalCache;
            this.range = range;

            limit = dimensions;
            mask = (1 << limit) - 1;
            chunkColumns = new IChunkColumn[(mask + 1) * (mask + 1)];
            logger = (TypeContainer.GetOrNull<ILogger>() ?? NullLogger.Default).As(typeof(LocalChunkCache));
        }
Example #5
0
 public LocalChunkCacheComponent(IGlobalChunkCache globalChunkCache, int dimensions, int range)
 {
     LocalChunkCache = new LocalChunkCache(globalChunkCache, dimensions, range);
 }
Example #6
0
 public void SetCache(IGlobalChunkCache globalChunkCache)
 => this.globalChunkCache = globalChunkCache;