コード例 #1
0
        public DocumentService()
        {
            if (DocumentServiceState.Mode == StoreMode.Private)
            {
                try
                {
                    store = new LocalStore.RecipeCollection();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("\"Private\" store initialization failed", ex);
                }
            }

            if (DocumentServiceState.Mode == StoreMode.Shell)
            {
                try
                {
                    store = new ShellStore.RecipeCollection();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("\"Shell\" store initialization failed", ex);
                }
            }

            if (DocumentServiceState.Mode == StoreMode.Shared)
            {
                throw new NotImplementedException("\"Shared\" store is not implemented");
            }
        }
コード例 #2
0
    private void InitReipes(IRecipeCollection recipes)
    {
        var i = 0;

        _options.Clear();
        Dropdown.options.Clear();

        if (recipes.GetRecipes().Any())
        {
            foreach (var recipe in recipes.GetRecipes().OrderBy(r => r.Result.Prototype.Name))
            {
                Dropdown.options.Add(new Dropdown.OptionData(recipe.Result.Prototype.Name));
                _options.Add(i, recipe);
                i++;
            }
        }
        else
        {
            Dropdown.options.Add(new Dropdown.OptionData("---------------"));
        }

        // hack
        Dropdown.value = -1;
        Dropdown.value = 0;
    }
コード例 #3
0
ファイル: CraftMachine.cs プロジェクト: Kalavarda/Unity
        public CraftMachine([NotNull] IBag bag, [NotNull] IRecipeCollection recipeCollection)
        {
            if (recipeCollection == null)
            {
                throw new ArgumentNullException(nameof(recipeCollection));
            }
            _bag = bag ?? throw new ArgumentNullException(nameof(bag));

            Recipes = recipeCollection.GetRecipes();
        }