private static IEnumerable <(string key, IItemFactory itemFactory)> GetItemFactories(
            IJsonAssetsApi jaApi
            )
        {
            // Big craftables
            foreach (var(jaKey, id) in jaApi.GetAllBigCraftableIds())
            {
                var key         = $"{ItemTypes.BigCraftable}/{jaKey}";
                var itemFactory = new SimpleItemFactory(
                    ItemTypes.BigCraftable,
                    () => new SObject(Vector2.Zero, id)
                    );
                yield return(key, itemFactory);
            }

            // Clothing
            foreach (var(jaKey, id) in jaApi.GetAllClothingIds())
            {
                var key         = $"{ItemTypes.Clothing}/{jaKey}";
                var itemFactory = new SimpleItemFactory(ItemTypes.Clothing, () => new Clothing(id));
                yield return(key, itemFactory);
            }

            // Hats
            foreach (var(jaKey, id) in jaApi.GetAllHatIds())
            {
                var key         = $"{ItemTypes.Hat}/{jaKey}";
                var itemFactory = new SimpleItemFactory(ItemTypes.Hat, () => new Hat(id));
                yield return(key, itemFactory);
            }

            // Weapons
            foreach (var(jaKey, id) in jaApi.GetAllWeaponIds())
            {
                var key         = $"{ItemTypes.Weapon}/{jaKey}";
                var itemFactory = new SimpleItemFactory(
                    ItemTypes.Weapon,
                    () => new MeleeWeapon(id)
                    );
                yield return(key, itemFactory);
            }

            // Objects
            foreach (var(jaKey, id) in jaApi.GetAllObjectIds())
            {
                var key         = $"{ItemTypes.Object}/{jaKey}";
                var itemFactory = new SimpleItemFactory(ItemTypes.Object, () => new SObject(id, 1));
                yield return(key, itemFactory);
            }
        }
Exemplo n.º 2
0
        private string[] Token_WeaponId(ITokenString input)
        {
            if (input == null)
            {
                return(ja.GetAllWeaponIds().Values.Select((i) => i.ToString()).ToArray <string>());
            }

            var str = input.Value;
            int id  = ja.GetWeaponId(str);

            if (id == -1)
            {
                return new string[] { }
            }
            ;
            return(new[] { id.ToString() });
        }
    }