コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SectorMapLoader"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger instance in use.</param>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        /// <param name="sectorMapLoaderOptions">The options for this map loader.</param>
        public SectorMapLoader(
            ILogger <SectorMapLoader> logger,
            IItemFactory itemFactory,
            ITileFactory tileFactory,
            IOptions <SectorMapLoaderOptions> sectorMapLoaderOptions)
        {
            logger.ThrowIfNull(nameof(logger));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));
            sectorMapLoaderOptions.ThrowIfNull(nameof(sectorMapLoaderOptions));

            DataAnnotationsValidator.ValidateObjectRecursive(sectorMapLoaderOptions.Value);

            this.mapDirInfo = new DirectoryInfo(sectorMapLoaderOptions.Value.LiveMapDirectory);

            if (!this.mapDirInfo.Exists)
            {
                throw new ApplicationException($"The map directory '{sectorMapLoaderOptions.Value.LiveMapDirectory}' could not be found.");
            }

            this.logger      = logger;
            this.itemFactory = itemFactory;
            this.tileFactory = tileFactory;

            this.totalTileCount   = 1;
            this.totalLoadedCount = default;

            this.loadLock = new object();

            this.sectorsLengthX = 1 + SectorXMax - SectorXMin;
            this.sectorsLengthY = 1 + SectorYMax - SectorYMin;
            this.sectorsLengthZ = 1 + SectorZMax - SectorZMin;

            this.sectorsLoaded = new bool[this.sectorsLengthX, this.sectorsLengthY, this.sectorsLengthZ];
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GrassOnlyDummyMapLoader"/> class.
        /// </summary>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        public GrassOnlyDummyMapLoader(IItemFactory itemFactory, ITileFactory tileFactory)
        {
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));

            this.itemFactory = itemFactory;
            this.tileFactory = tileFactory;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GrassOnlyDummyMapLoader"/> class.
        /// </summary>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        public GrassOnlyDummyMapLoader(IItemFactory itemFactory, ITileFactory tileFactory)
        {
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));

            this.ItemFactory = itemFactory;
            this.TileFactory = tileFactory;

            this.tilesAndLocations = new ConcurrentDictionary <Location, ITile>();
        }