コード例 #1
0
        private static void MakeModeFloatMenu(Bill bill)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("PrisonLabor_ColonyOnly".Translate(), delegate
            {
                BillAssignationUtility.SetFor(bill, GroupMode.ColonyOnly);
            }));
            list.Add(new FloatMenuOption("PrisonLabor_ColonistsOnly".Translate(), delegate
            {
                BillAssignationUtility.SetFor(bill, GroupMode.ColonistsOnly);
            }));
            list.Add(new FloatMenuOption("PrisonLabor_PrisonersOnly".Translate(), delegate
            {
                BillAssignationUtility.SetFor(bill, GroupMode.PrisonersOnly);
            }));
            Find.WindowStack.Add(new FloatMenu(list));
        }
コード例 #2
0
 static void SlavePostFix(Bill __instance)
 {
     BillAssignationUtility.SetFor(__instance, GroupMode.SlavesOnly);
 }
コード例 #3
0
        static IEnumerable <Widgets.DropdownMenuElement <Pawn> > Postfix_GenerateFields(IEnumerable <Widgets.DropdownMenuElement <Pawn> > values, Dialog_BillConfig __instance)
        {
            int             check = ModsConfig.IdeologyActive ? 1 : 0;
            int             i     = 0;
            Bill_Production bill  = Traverse.Create(__instance).Field("bill").GetValue <Bill_Production>();

            Widgets.DropdownMenuElement <Pawn> anyone = new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("PrisonLabor_ColonyOnly".Translate(), delegate
                {
                    Traverse.Create(bill).Field("slavesOnly").SetValue(true);
                    Traverse.Create(bill).Field("pawnRestriction").SetValue(null);
                    BillAssignationUtility.SetFor(bill, GroupMode.ColonyOnly);
                }),
                payload = null
            };
            yield return(anyone);

            foreach (Widgets.DropdownMenuElement <Pawn> value in values)
            {
                yield return(value);

                if (check == i)
                {
                    Widgets.DropdownMenuElement <Pawn> prisonerMenu = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption("PrisonLabor_PrisonersOnly".Translate(), delegate
                        {
                            bill.SetAnyPawnRestriction();
                            BillAssignationUtility.SetFor(bill, GroupMode.PrisonersOnly);
                        }),
                        payload = null
                    };
                    yield return(prisonerMenu);

                    Widgets.DropdownMenuElement <Pawn> anyCaptive = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption("PrisonLabor_PrisonersAndSlaveOnly".Translate(), delegate
                        {
                            bill.SetAnySlaveRestriction();
                            BillAssignationUtility.SetFor(bill, GroupMode.CaptiveOnly);
                        }),
                        payload = null
                    };
                    yield return(anyCaptive);
                }
                i++;
            }
            WorkGiverDef       workGiver            = bill.billStack.billGiver.GetWorkgiver();
            SkillDef           workSkill            = bill.recipe.workSkill;
            IEnumerable <Pawn> allPrisonersOfColony = PawnsFinder.AllMaps_PrisonersOfColony;

            allPrisonersOfColony = allPrisonersOfColony.OrderBy((Pawn pawn) => pawn.LabelShortCap);
            if (workSkill != null)
            {
                allPrisonersOfColony = allPrisonersOfColony.OrderByDescending((Pawn pawn) => pawn.skills.GetSkill(bill.recipe.workSkill).Level);
            }
            if (workGiver == null)
            {
                Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148);
                yield break;
            }
            allPrisonersOfColony = allPrisonersOfColony.OrderByDescending((Pawn pawn) => pawn.workSettings.WorkIsActive(workGiver.workType));
            allPrisonersOfColony = allPrisonersOfColony.OrderBy((Pawn pawn) => pawn.WorkTypeIsDisabled(workGiver.workType));

            Widgets.DropdownMenuElement <Pawn> dropdownMenuElement;
            foreach (Pawn pawn in allPrisonersOfColony)
            {
                if (PrisonLaborUtility.LaborEnabled(pawn))
                {
                    if (pawn.WorkTypeIsDisabled(workGiver.workType))
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option  = new FloatMenuOption(string.Format("P: {0} ({1})", pawn.LabelShortCap, "WillNever".Translate(workGiver.verb)), null),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else if (bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("P: {0} ({1} {2}, {3})", pawn.LabelShortCap, pawn.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate
                            {
                                bill.SetPawnRestriction(pawn);
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else if (!pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("P: {0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate
                            {
                                bill.SetPawnRestriction(pawn);
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else if (bill.recipe.workSkill != null)
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption($"P: {pawn.LabelShortCap} ({pawn.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate
                            {
                                bill.SetPawnRestriction(pawn);
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption($"P: {pawn.LabelShortCap}", delegate
                            {
                                bill.SetPawnRestriction(pawn);
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                }
            }
        }
コード例 #4
0
 static void ColonistPostFix(Bill __instance)
 {
     BillAssignationUtility.SetFor(__instance, GroupMode.ColonistsOnly);
 }