Exemplo n.º 1
0
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            /*
             * ISurrogateSelector _selector;
             * ISerializationSurrogate billmaker = selector.GetSurrogate(typeof(Bill), context, out _selector);
             * Bill b = (Bill)billmaker.SetObjectData(obj, info, context, _selector);
             * return (Bill_Production)b;*/
            string recipeDefName = info.GetString("recipedef");
            string loadID        = info.GetString("loadID");

            foreach (var b in BillUtility.GlobalBills())
            {
                if (b.GetUniqueLoadID() == loadID)
                {
                    return(b);
                }
            }

            foreach (var rec in DefDatabase <RecipeDef> .AllDefsListForReading)
            {
                if (rec.defName == recipeDefName)
                {
                    RimLog.Message("bill production restored via recipedef!");
                    Bill b = BillUtility.MakeNewBill(rec);
                    return(b);
                }
            }

            RimLog.Message("could not make bill_production!");
            return(null);
        }
Exemplo n.º 2
0
        public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
        {
            string    recipeDefName = info.GetString("recipedef");
            BillStack st            = (BillStack)info.GetValue("bill_stack", typeof(BillStack));

            RimLog.Message("bill lacks pawn restriction in surrogate!");
            RimLog.Message("billstack is null ? " + (st == null ? "yes" : "no"));
            RimLog.Message("bill giver as thing : " + (st.billGiver as Thing));
            RimLog.Message("bill giver def as thing : " + (st.billGiver as Thing).def);

            foreach (var rec in (st.billGiver as Thing).def.recipes)
            {
                if (rec.defName == recipeDefName)
                {
                    return(BillUtility.MakeNewBill(rec));
                }
            }

            RimLog.Message("could not make bill!");
            return(null);
        }
Exemplo n.º 3
0
        public Job MakeShardingJob(Pawn selPawn, IBillGiver billGiver, int count)
        {
            var  bills    = billGiver.BillStack.Bills;
            Bill workBill = null;

            foreach (var bill in bills)
            {
                if (!bill.suspended && (bill.PawnAllowedToStartAnew(selPawn)) && bill.ingredientFilter.Allows(this.parent))
                {
                    Log.Message(bill.ingredientFilter.AllowedThingDefs.ToStringSafeEnumerable());
                    workBill = bill;
                    break;
                }
            }
            if (workBill == null)             // this techprinter didn't have a suitable bill, so add one I guess
            {
                Bill newBill;
                if (count == 1)
                {
                    newBill = BillUtility.MakeNewBill(Base.DefOf.DTechprintingRecipe);
                }
                else
                {
                    newBill = BillUtility.MakeNewBill(Base.DefOf.DTechprintingStackRecipe);
                }
                newBill.ingredientFilter.SetDisallowAll();
                newBill.ingredientFilter.SetAllow(this.parent.def, true);

                billGiver.BillStack.AddBill(newBill);
                workBill = newBill;
            }
            ThingCount tc = new ThingCount(this.parent, count);
            Job        haulOff;

            return(WorkGiver_DoBill.TryStartNewDoBillJob(selPawn, workBill, billGiver, new List <ThingCount> {
                tc
            }, out haulOff, false));
        }
Exemplo n.º 4
0
 public static void MakeNewBillAt(Building_WorkTable table, RecipeDef recipe)
 {
     table.BillStack.AddBill(BillUtility.MakeNewBill(recipe));
 }