Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CreatureFactory"/> class.
        /// </summary>
        /// <param name="monsterLoader">A reference to the monster type loader in use.</param>
        /// <param name="itemFactory">A reference to the item factory in use.</param>
        public CreatureFactory(IMonsterTypeLoader monsterLoader, IItemFactory itemFactory)
        {
            monsterLoader.ThrowIfNull(nameof(monsterLoader));
            itemFactory.ThrowIfNull(nameof(itemFactory));

            this.monsterTypeCatalog = monsterLoader.LoadTypes();

            this.ItemFactory = itemFactory;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MonsterTypeReadOnlyRepository"/> class.
        /// </summary>
        /// <param name="monsterTypeLoader">A reference to the monster type loader in use.</param>
        public MonsterTypeReadOnlyRepository(IMonsterTypeLoader monsterTypeLoader)
        {
            monsterTypeLoader.ThrowIfNull(nameof(monsterTypeLoader));

            if (monsterTypeCatalog == null)
            {
                lock (MonsterTypeCatalogLock)
                {
                    if (monsterTypeCatalog == null)
                    {
                        monsterTypeCatalog = monsterTypeLoader.LoadTypes();
                    }
                }
            }
        }