예제 #1
0
        public bool TryGetItemFactory(
            NamespacedKey key,
            [NotNullWhen(true)] out IItemFactory?factory
            )
        {
            this.ReloadIfNeeded();

            factory = default;
            return(this.namespaceProviders.TryGetValue(key.Namespace, out var provider) &&
                   provider.TryGetItemFactory(key.Key, out factory));
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomEventArgs"/> class.
 /// </summary>
 /// <param name="catch">The catch info.</param>
 /// <param name="eventKey">The key for the event.</param>
 /// <exception cref="ArgumentNullException">An argument was null.</exception>
 public CustomEventArgs(CatchInfo @catch, NamespacedKey eventKey)
 {
     this.Catch    = @catch ?? throw new ArgumentNullException(nameof(@catch));
     this.EventKey = eventKey;
 }
예제 #3
0
        private static IEnumerable <(string key, IItemFactory itemFactory)> GetItemFactories(
            IAssetProvider assetProvider
            )
        {
            foreach (var quality in Enumerable.Range(Tool.stone, Tool.iridium - Tool.stone + 1))
            {
                // Axe
                var axeKey     = NamespacedKey.SdvTool(ToolTypes.Axe, quality).Key;
                var axeFactory = new SimpleItemFactory(
                    ItemTypes.Tool,
                    () => ToolFactory.getToolFromDescription(ToolFactory.axe, quality)
                    );
                yield return(axeKey, axeFactory);

                // Hoe
                var hoeKey     = NamespacedKey.SdvTool(ToolTypes.Hoe, quality).Key;
                var hoeFactory = new SimpleItemFactory(
                    ItemTypes.Tool,
                    () => ToolFactory.getToolFromDescription(ToolFactory.hoe, quality)
                    );
                yield return(hoeKey, hoeFactory);

                // Pickaxe
                var pickKey     = NamespacedKey.SdvTool(ToolTypes.Pickaxe, quality).Key;
                var pickFactory = new SimpleItemFactory(
                    ItemTypes.Tool,
                    () => ToolFactory.getToolFromDescription(ToolFactory.pickAxe, quality)
                    );
                yield return(pickKey, pickFactory);

                // Watering can
                var canKey     = NamespacedKey.SdvTool(ToolTypes.WateringCan, quality).Key;
                var canFactory = new SimpleItemFactory(
                    ItemTypes.Tool,
                    () => ToolFactory.getToolFromDescription(ToolFactory.wateringCan, quality)
                    );
                yield return(canKey, canFactory);

                // Fishing rod
                if (quality < Tool.iridium)
                {
                    var rodKey     = NamespacedKey.SdvTool(ToolTypes.FishingRod, quality).Key;
                    var rodFactory = new SimpleItemFactory(
                        ItemTypes.Tool,
                        () => ToolFactory.getToolFromDescription(ToolFactory.fishingRod, quality)
                        );
                    yield return(rodKey, rodFactory);
                }
            }

            yield return(NamespacedKey.SdvTool(ToolTypes.MilkPail).Key,
                         new SimpleItemFactory(ItemTypes.Tool, () => new MilkPail()));

            yield return(NamespacedKey.SdvTool(ToolTypes.Shears).Key,
                         new SimpleItemFactory(ItemTypes.Tool, () => new Shears()));

            yield return(NamespacedKey.SdvTool(ToolTypes.Pan).Key,
                         new SimpleItemFactory(ItemTypes.Tool, () => new Pan()));

            yield return(NamespacedKey.SdvTool(ToolTypes.Wand).Key,
                         new SimpleItemFactory(ItemTypes.Tool, () => new Wand()));

            // Clothing
            // TODO: dynamic clothing?
            var clothingInformation = assetProvider.Load <Dictionary <int, string> >(@"Data\ClothingInformation");
            var clothingIds         = clothingInformation.Keys.ToHashSet();

            foreach (var id in clothingIds)
            {
                var key         = NamespacedKey.SdvClothing(id).Key;
                var itemFactory = new SimpleItemFactory(ItemTypes.Clothing, () => new Clothing(id));
                yield return(key, itemFactory);
            }

            // Wallpapers
            foreach (var id in Enumerable.Range(0, 112))
            {
                var key         = NamespacedKey.SdvWallpaper(id).Key;
                var itemFactory = new SimpleItemFactory(ItemTypes.Wallpaper, () => new Wallpaper(id));
                yield return(key, itemFactory);
            }

            // Flooring
            foreach (var id in Enumerable.Range(0, 56))
            {
                var key         = NamespacedKey.SdvFlooring(id).Key;
                var itemFactory = new SimpleItemFactory(ItemTypes.Flooring, () => new Wallpaper(id, true));
                yield return(key, itemFactory);
            }

            // Boots
            var boots = assetProvider.Load <Dictionary <int, string> >(@"Data\Boots");

            foreach (var id in boots.Keys)
            {
                var key         = NamespacedKey.SdvBoots(id).Key;
                var itemFactory = new SimpleItemFactory(ItemTypes.Boots, () => new Boots(id));
                yield return(key, itemFactory);
            }

            // Hats
            var hats = assetProvider.Load <Dictionary <int, string> >(@"Data\hats");

            foreach (var id in hats.Keys)
            {
                var key         = NamespacedKey.SdvHat(id).Key;
                var itemFactory = new SimpleItemFactory(ItemTypes.Hat, () => new Hat(id));
                yield return(key, itemFactory);
            }

            // Weapons
            var weapons = assetProvider.Load <Dictionary <int, string> >(@"Data\weapons");

            foreach (var id in weapons.Keys)
            {
                var key         = NamespacedKey.SdvWeapon(id).Key;
                var itemFactory = id switch
                {