Example #1
0
        protected override void LoadFields(StreamReader reader)
        {
            List <Dictionary <string, string> > fieldlist = new List <Dictionary <string, string> > {
                new Dictionary <string, string>()
            };

            while (!reader.EndOfStream)
            {
                if (TryReadField(reader, out Pair <string, string> pair))
                {
                    fieldlist[fieldlist.Count - 1].Add(pair.First, pair.Second);

                    if (pair.First == BREAK)
                    {
                        fieldlist.Add(new Dictionary <string, string>());
                    }
                }
            }


            List <Bill_Production> bills = new List <Bill_Production>();

            for (int i = 0; i < fieldlist.Count - 1; i++)
            {
                var fields = fieldlist[i];

                if (TryCreateBill(fields, out Bill_Production productionBill))
                {
                    if (Bills.Count < BillStack.MaxCount)
                    {
                        bills.Add(productionBill);
                    }
                    else
                    {
                        Log.Warning("Work Table has too many bills. Bill for [" + productionBill.recipe.defName + "] will not be added.");
                    }
                }
            }


            if (bills.Count > 0 && !Append)
            {
                Bills.Clear();
            }
            foreach (Bill_Production bill in bills)
            {
                Bills.AddBill(bill);
            }
        }