public static void GroupExclusionButton(Listing_Standard listing, Bill bill)
 {
     if (BillUtility.IsFor(bill) == GroupMode.ColonistsOnly)
     {
         if (listing.ButtonText("PrisonLabor_ColonistsOnly".Translate()))
         {
             BillUtility.SetFor(bill, GroupMode.PrisonersOnly);
             SoundDefOf.Click.PlayOneShotOnCamera();
         }
     }
     else if (BillUtility.IsFor(bill) == GroupMode.PrisonersOnly)
     {
         if (listing.ButtonText("PrisonLabor_PrisonersOnly".Translate()))
         {
             BillUtility.SetFor(bill, GroupMode.ColonyOnly);
             SoundDefOf.Click.PlayOneShotOnCamera();
         }
     }
     else
     {
         if (listing.ButtonText("PrisonLabor_ColonyOnly".Translate()))
         {
             BillUtility.SetFor(bill, GroupMode.ColonistsOnly);
             SoundDefOf.Click.PlayOneShotOnCamera();
         }
     }
     listing.Gap(12f);
 }
Example #2
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);
        }
        private static void Postfix(Bill __instance)
        {
            if (PrisonLaborPrefs.DisableMod)
            {
                return;
            }

            BillUtility.GetData(__instance).ExposeData();
        }
Example #4
0
        private static void Notify__ColonistUnavailable(Pawn pawn)
        {
            if (Settings.Bills)
            {
                return;
            }

            BillUtility.Notify_ColonistUnavailable(pawn);
        }
Example #5
0
 private void ChangeReligion(Religion religion)
 {
     this.religion = religion;
     pietyTracker  = new Pawn_PietyTracker((Pawn)parent, religion);
     prayTracker   = new Pawn_PrayTracker((Pawn)parent, religion);
     religionCompability.RecalculateCompabilities();
     religionRestrictions.RestoreToDefault();
     BillUtility.Notify_ColonistUnavailable((Pawn)this.parent);
 }
Example #6
0
 public static bool Notify_ColonistUnavailable(Pawn pawn)
 {
     //List<Bill> billList = BillUtility.GlobalBills().ToList();
     try
     {
         foreach (Bill item in BillUtility.GlobalBills())
         {
             item.ValidateSettings();
         }
     }
     catch (Exception arg)
     {
         Log.Error("Could not notify bills: " + arg);
     }
     return(false);
 }
Example #7
0
        public static bool IsForCertainGroup(Pawn pawn, Bill bill)
        {
            var group = BillUtility.IsFor(bill);

            if (group == GroupMode.ColonyOnly)
            {
                return(true);
            }
            if (group == GroupMode.ColonistsOnly && !pawn.IsPrisoner)
            {
                return(true);
            }
            if (group == GroupMode.PrisonersOnly && pawn.IsPrisoner)
            {
                return(true);
            }
            return(false);
        }
Example #8
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);
        }
Example #9
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));
        }
Example #10
0
        protected override void FillTab()
        {
            IStoreSettingsParent selStoreSettingsParent = this.SelStoreSettingsParent;
            StorageSettings      settings = selStoreSettingsParent.GetStoreSettings();

            Rect position = new Rect(0f, 0f, ITab_Lazy.WinSize.x, ITab_Lazy.WinSize.y).ContractedBy(10f);

            GUI.BeginGroup(position);
            if (this.IsPrioritySettingVisible)
            {
                Text.Font = GameFont.Small;
                Rect rect = new Rect(0f, 0f, 160f, this.TopAreaHeight - 6f);
                if (Widgets.ButtonText(rect, "Priority".Translate() + ": " + settings.Priority.Label(), true, false, true))
                {
                    List <FloatMenuOption> list = new List <FloatMenuOption>();
                    foreach (StoragePriority storagePriority in Enum.GetValues(typeof(StoragePriority)))
                    {
                        if (storagePriority != StoragePriority.Unstored)
                        {
                            StoragePriority localPr = storagePriority;
                            list.Add(new FloatMenuOption(localPr.Label().CapitalizeFirst(), delegate
                            {
                                settings.Priority = localPr;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                UIHighlighter.HighlightOpportunity(rect, "StoragePriority");
            }
            //Lazy button & Threshold Sliders
            {
                Text.Font = GameFont.Small;
                Rect         rect      = new Rect(0f, 35f, 160f, this.TopAreaHeight - 6f);
                LazySettings stockpile = LazySettingsManager.AddOrGetSettings(settings);
                if (stockpile == null)
                {
                    Log.Error(string.Format($"Lazy Tab Error: Attempted to load {SelObject} settings as LazySettings, when it was of type {settings.GetType()}"));
                }
                else
                {
                    //Type Button
                    if (Widgets.ButtonText(rect, "Type: " + stockpile.type.ToString(), true, false, true))
                    {
                        List <FloatMenuOption> list = new List <FloatMenuOption>();
                        foreach (LazyType type in Enum.GetValues(typeof(LazyType)))
                        {
                            LazyType localTy = type;
                            list.Add(new FloatMenuOption(type.ToString(), delegate
                            {
                                stockpile.type = type;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null));
                            Find.WindowStack.Add(new FloatMenu(list));
                        }
                    }
                    //Cache Threshold Slider
                    if (stockpile.type == LazyType.Cache)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Cache Threshold: {stockpile.CacheThreshold * 100:0}%"));
                        stockpile.CacheThreshold = stand.Slider(stockpile.CacheThreshold, 0f, 0.75f);
                        stand.End();
                    }
                    //Buffer Threshold Slider
                    else if (stockpile.type == LazyType.Buffer)
                    {
                        Rect             sliderRect = new Rect(0f, 66f, WinSize.x - 20f, 70f);
                        Listing_Standard stand      = new Listing_Standard();
                        stand.Begin(sliderRect);
                        stand.Label(string.Format($"Buffer Threshold: {stockpile.BufferThreshold * 100:0}%"));
                        stockpile.BufferThreshold = stand.Slider(stockpile.BufferThreshold, 0.25f, 1f);
                        stand.End();
                    }
                }
            }


            ThingFilter parentFilter = null;

            if (selStoreSettingsParent.GetParentStoreSettings() != null)
            {
                parentFilter = selStoreSettingsParent.GetParentStoreSettings().filter;
            }
            Rect rect2 = new Rect(0f, (this.TopAreaHeight * 3) + 5, position.width, position.height - (this.TopAreaHeight * 2));

            Bill[] first = (from b in BillUtility.GlobalBills()
                            where b is Bill_Production && b.GetStoreZone() == selStoreSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                            select b).ToArray();


            ThingFilterUI.DoThingFilterConfigWindow(rect2, ref this.scrollPosition, settings.filter, parentFilter, 8, null, null, false, null, null);

            Bill[] second = (from b in BillUtility.GlobalBills()
                             where b is Bill_Production && b.GetStoreZone() == selStoreSettingsParent && b.recipe.WorkerCounter.CanPossiblyStoreInStockpile((Bill_Production)b, b.GetStoreZone())
                             select b).ToArray();

            IEnumerable <Bill> enumerable = first.Except(second);

            foreach (Bill item in enumerable)
            {
                Messages.Message("MessageBillValidationStoreZoneInsufficient".Translate(item.LabelCap, item.billStack.billGiver.LabelShort.CapitalizeFirst(), item.GetStoreZone().label), item.billStack.billGiver as Thing, MessageTypeDefOf.RejectInput, false);
            }

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.StorageTab, KnowledgeAmount.FrameDisplayed);
            GUI.EndGroup();
        }
Example #11
0
 public static void MakeNewBillAt(Building_WorkTable table, RecipeDef recipe)
 {
     table.BillStack.AddBill(BillUtility.MakeNewBill(recipe));
 }
Example #12
0
 public static void Postfix(Bill bill)
 {
     BillUtility.Remove(bill);
 }