Beispiel #1
0
        public IRecipe Build()
        {
            CraftingType type = Type switch
            {
                SmeltingType.Default => CraftingType.Smelting,
                SmeltingType.Blasting => CraftingType.Blasting,
                SmeltingType.Smoking => CraftingType.Smoking,
                SmeltingType.CampfireCooking => CraftingType.CampfireCooking
            };

            if (this.Ingredient.Count <= 0)
            {
                throw new InvalidOperationException("Recipe must atleast have 1 item as an ingredient");
            }

            return(new SmeltingRecipe
            {
                Name = this.Name ?? throw new NullReferenceException("Recipe must have a name"),
                Type = type,
                Group = this.Group,
                Ingredient = this.Ingredient,
                Cookingtime = this.CookingTime,
                Experience = this.Experience,
                Result = this.Result != null ? new Ingredient {
                    this.Result
                } : throw new NullReferenceException("Result is not set.")
            });
 public void Start(CraftingType type)
 {
     if (!bStarted)
     {
         Thread thread;
         if (type == CraftingType.ScrapbankSmeltWeps)
         {
             thread = new Thread(new ThreadStart(ScrapbankMethod));
         }
         else if (type == CraftingType.HatbankCrafting)
         {
             thread = new Thread(new ThreadStart(HatbankMethod));
         }
         else if (type == CraftingType.ScrapbankMetalToScrap)
         {
             thread = new Thread(new ThreadStart(MetalToScrapMethod));
         }
         else if (type == CraftingType.CombineMetal)
         {
             thread = new Thread(new ThreadStart(CompactMetal));
         }
         else if (type == CraftingType.KeybankCrafting)
         {
             thread = new Thread(new ThreadStart(KeybankMethod));
         }
         else
         {
             return;
         }
         thread.Start();
         bStarted = true;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Get all crafting stations from a crafting type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <CraftingStation> GetCraftingStationsFromCraftingType(CraftingType type)
        {
            List <CraftingStation> stations = new List <CraftingStation>();

            switch (type)
            {
            case CraftingType.AssemblingMachine:
                stations.Add(CraftingStation.AssemblingMachine1);
                stations.Add(CraftingStation.AssemblingMachine2);
                stations.Add(CraftingStation.AssemblingMachine3);
                break;

            case CraftingType.Furnace:
                stations.Add(CraftingStation.StoneFurnace);
                stations.Add(CraftingStation.SteelFurnace);
                stations.Add(CraftingStation.ElectricFurnace);
                break;

            case CraftingType.ChemicalPlant:
                stations.Add(CraftingStation.ChemicalPlant);
                break;

            case CraftingType.Refinery:
                stations.Add(CraftingStation.Refinary);
                break;

            case CraftingType.Drill:
                break;

            default:
                break;
            }

            return(stations);
        }
Beispiel #4
0
    // Changed Item when they get moved around in the inventory
    public void ChangeInventoryItem(ItemSlot slot)
    {
        CraftingType ct     = Utils.ConvertCollectableType(slot.Item.Type);
        BulletData   bullet = mInventory.GetActiveBulletItem();
        WeaponData   weapon = mInventory.GetActiveWeaponItem();
        CoreData     core   = mInventory.GetActiveCoreItem();

        ScriptableObject slotItem = slot.Item;

        if (!slot.IsInventorySlot)
        {
            slotItem = null;
        }

        switch (ct)
        {
        case CraftingType.BULLET: bullet = (BulletData)slotItem; break;

        case CraftingType.WEAPON: weapon = (WeaponData)slotItem; break;

        case CraftingType.CORE: core = (CoreData)slotItem; break;
        }

        mInventory.SetActiveItems(bullet, weapon, core);
        updateCraftingItems();
    }
Beispiel #5
0
 public ShapelessRecipe(string name, CraftingType type, string?group, Ingredient result, IReadOnlyList <Ingredient> ingredients)
 {
     Name        = name;
     Type        = type;
     Group       = group;
     Result      = result;
     Ingredients = ingredients;
 }
Beispiel #6
0
 public CuttingRecipe(string name, CraftingType type, string?group, Ingredient result, Ingredient ingredient, int count)
 {
     Name       = name;
     Type       = type;
     Group      = group;
     Result     = result;
     Ingredient = ingredient;
     Count      = count;
 }
 /// <summary>
 /// Create a <see cref="FactorioItem"/> with a name, craft amount and a crafting time
 /// </summary>
 /// <param name="name"></param>
 /// <param name="output"></param>
 /// <param name="time"></param>
 public FactorioItem(string name, int output, double time, CraftingType crafting = CraftingType.AssemblingMachine, string path = null)
 {
     Id                  = idCounter++;
     Name                = name;
     CraftingOutput      = output;
     CraftingTime        = time;
     DefaultCraftingType = crafting;
     ImagePath           = path;
 }
Beispiel #8
0
 public ShapedRecipe(string name, CraftingType type, string?group, Ingredient result, IReadOnlyList <string> pattern, IReadOnlyDictionary <char, Ingredient> key)
 {
     Name    = name;
     Type    = type;
     Group   = group;
     Result  = result;
     Pattern = pattern;
     Key     = key;
 }
Beispiel #9
0
 public SmithingRecipe(string name, CraftingType type, string?group, Ingredient result, Ingredient @base, Ingredient addition)
 {
     Name     = name;
     Type     = type;
     Group    = group;
     Result   = result;
     Base     = @base;
     Addition = addition;
 }
 public FactorioItem(int id, string name, int output, double time, CraftingType crafting = CraftingType.AssemblingMachine, string path = null)
 {
     Id                  = id;
     Name                = name;
     CraftingOutput      = output;
     CraftingTime        = time;
     Productivity        = output / time;
     DefaultCraftingType = crafting;
     ImagePath           = path;
 }
Beispiel #11
0
 public SmeltingRecipe(string name, CraftingType type, string?group, Ingredient result, Ingredient ingredient, float experience, int cookingTime)
 {
     Name        = name;
     Type        = type;
     Group       = group;
     Result      = result;
     Ingredient  = ingredient;
     Experience  = experience;
     Cookingtime = cookingTime;
 }
Beispiel #12
0
        /// <summary>
        /// Add a new item to the Items list and save Items list to xml file
        /// </summary>
        /// <param name="name"></param>
        /// <param name="output"></param>
        /// <param name="time"></param>
        /// <param name="crafting"></param>
        /// <exception cref="FactorioException"></exception>
        public void AddItem(string name, int output, double time, CraftingType crafting, string path)
        {
            // If item already exists throw exception
            if (this.Items.Any(i => i.Name == name))
            {
                throw new FactorioException(DiagnosticEvents.ItemAlreadyExists, "Item already exists!");
            }

            // Add item and save
            this.Items.Add(new FactorioItem(name, output, time, crafting, path));
            this.SaveItems();
        }
        /// <summary>
        /// Try creating a new item. Closing the window if successfull, else show error message.
        /// </summary>
        private void Ok_Click()
        {
            // Check if entries are existing
            if (
                TxtItemName == "" || string.IsNullOrWhiteSpace(TxtItemName) ||
                TxtItemOutput == null || TxtItemOutput == "" ||
                TxtItemTime == null || TxtItemTime == ""
                )
            {
                throw new ArgumentNullException("Enter a value.");
            }

            // Convert entries
            string       name     = TxtItemName;
            int          output   = Convert.ToInt32(TxtItemOutput);
            double       time     = Convert.ToDouble(TxtItemTime);
            CraftingType crafting = (CraftingType)Enum.Parse(typeof(CraftingType), SelectedCrafting);

            m_item.Name                = name;
            m_item.CraftingOutput      = output;
            m_item.CraftingTime        = time;
            m_item.DefaultCraftingType = crafting;
            m_item.ImagePath           = this.PicturePath;

            m_item.Recipe.Clear();

            // Copy recipe from the dummy item to the original
            foreach (var recipeItem in m_itemDummy.Recipe)
            {
                m_item.AddRecipeItem(recipeItem.Key, recipeItem.Value);
            }

            if (m_itemDummy.Id == -1)
            {
                m_fLogic.Items.Add(m_item);
            }

            m_fLogic.SaveItems();

            m_currentWindow?.Close();
        }
Beispiel #14
0
    public void SetData(ItemData data)
    {
        _itemData = data;
        _baseItem = DataHolder._data.BaseItems.GetItemById(data.baseItemID);
        itemName  = data.itemName;
        type      = _baseItem.Type;
        rarity    = data.rarity;
        level     = data.level;
        icon      = _baseItem.GetIcon(level);
        smithed   = CraftingType.Unsmithed;

        main = new List <ItemMainStatValue>();
        var power = 0;

        if (data.mainStatChanges.Length > 0)
        {
            foreach (var value in data.mainStatChanges)
            {
                main.Add(value);
                power += value.value;
            }
        }

        sub = new List <ItemSubStatValue>();
        if (data.subStatChanges.Length > 0)
        {
            foreach (var value in data.subStatChanges)
            {
                sub.Add(value);
                power += value.value;
            }
        }

        powerLevel = power;
        price      = (priceByRarity[data.rarity] * power);
    }
 public CraftingPair(CraftingType Type)
 {
     this.Type = Type;
 }