private IEnumerable <Widgets.DropdownMenuElement <Zone_Stockpile> > GenerateStockpileInclusion()
        {
            Widgets.DropdownMenuElement <Zone_Stockpile> dropdownMenuElement = new Widgets.DropdownMenuElement <Zone_Stockpile>
            {
                option = new FloatMenuOption("IncludeFromAll".Translate(), delegate
                {
                    bill.includeFromZone = null;
                }),
                payload = null
            };
            yield return(dropdownMenuElement);

            List <SlotGroup> groupList = bill.billStack.billGiver.Map.haulDestinationManager.AllGroupsListInPriorityOrder;
            int groupCount             = groupList.Count;
            int i = 0;

            while (i < groupCount)
            {
                SlotGroup      slotGroup = groupList[i];
                Zone_Stockpile stockpile = slotGroup.parent as Zone_Stockpile;
                if (stockpile != null)
                {
                    if (!bill.recipe.WorkerCounter.CanPossiblyStoreInStockpile(bill, stockpile))
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Zone_Stockpile>
                        {
                            option  = new FloatMenuOption(string.Format("{0} ({1})", "IncludeSpecific".Translate(slotGroup.parent.SlotYielderLabel()), "IncompatibleLower".Translate()), null),
                            payload = stockpile
                        };
                        yield return(dropdownMenuElement);
                    }
                    else
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Zone_Stockpile>
                        {
                            option = new FloatMenuOption("IncludeSpecific".Translate(slotGroup.parent.SlotYielderLabel()), delegate
                            {
                                bill.includeFromZone = stockpile;
                            }),
                            payload = stockpile
                        };
                        yield return(dropdownMenuElement);
                    }
                }
                int num = i + 1;
                i = num;
            }
        }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = Current.Game.drugPolicyDatabase.AllPolicies.GetEnumerator();
                    num        = 4294967293u;
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        DrugPolicy assignedDrugs = enumerator.Current;
                        this.$current = new Widgets.DropdownMenuElement <DrugPolicy>
                        {
                            option = new FloatMenuOption(assignedDrugs.label, delegate()
                            {
                                < Button_GenerateMenu > c__AnonStorey.pawn.drugs.CurrentPolicy = assignedDrugs;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = assignedDrugs
                        };
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = Enum.GetValues(typeof(HostilityResponseMode)).GetEnumerator();
                    num        = 4294967293u;
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        HostilityResponseMode response = (HostilityResponseMode)enumerator.Current;
                        this.$current = new Widgets.DropdownMenuElement <HostilityResponseMode>
                        {
                            option = new FloatMenuOption(response.GetLabel(), delegate()
                            {
                                < DrawResponseButton_GenerateMenu > c__AnonStorey.p.playerSettings.hostilityResponse = response;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = response
                        };
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
Beispiel #4
0
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p)
        {
            Widgets.DropdownMenuElement <Pawn> dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
                {
                    p.playerSettings.Master = null;
                }),
                payload = null
            };
            yield return(dropdownMenuElement);

            foreach (Pawn col in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                string text   = RelationsUtility.LabelWithBondInfo(col, p);
                Action action = null;
                if (CanBeMaster(col, p))
                {
                    action = delegate
                    {
                        p.playerSettings.Master = col;
                    };
                }
                else
                {
                    int level = col.skills.GetSkill(SkillDefOf.Animals).Level;
                    int num   = MinimumHandlingSkill(p);
                    if (level < num)
                    {
                        action = null;
                        text  += " (" + "SkillTooLow".Translate(SkillDefOf.Animals.LabelCap, level, num) + ")";
                    }
                }
                dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                {
                    option  = new FloatMenuOption(text, action),
                    payload = col
                };
                yield return(dropdownMenuElement);
            }
        }
        static IEnumerable <Widgets.DropdownMenuElement <Pawn> > Postfix(IEnumerable <Widgets.DropdownMenuElement <Pawn> > values, Dialog_BillConfig __instance)
        {
            foreach (Widgets.DropdownMenuElement <Pawn> value in values)
            {
                yield return(value);
            }
            Bill_Production bill                 = Traverse.Create(__instance).Field("bill").GetValue <Bill_Production>();
            WorkGiverDef    workGiver            = bill.billStack.billGiver.GetWorkgiver();
            List <Pawn>     allPrisonersOfColony = PawnsFinder.AllMaps_PrisonersOfColony;

            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("{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("{0} ({1} {2}, {3})", pawn.LabelShortCap, pawn.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate
                            {
                                bill.pawnRestriction = pawn;
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else if (!pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate
                            {
                                bill.pawnRestriction = pawn;
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else if (bill.recipe.workSkill != null)
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption($"{pawn.LabelShortCap} ({pawn.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate
                            {
                                bill.pawnRestriction = pawn;
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                    else
                    {
                        dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption($"{pawn.LabelShortCap}", delegate
                            {
                                bill.pawnRestriction = pawn;
                            }),
                            payload = pawn
                        };
                        yield return(dropdownMenuElement);
                    }
                }
            }
        }
        private IEnumerable <Widgets.DropdownMenuElement <Pawn> > GeneratePawnRestrictionOptions()
        {
            Widgets.DropdownMenuElement <Pawn> dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("AnyWorker".Translate(), delegate
                {
                    bill.pawnRestriction = null;
                }),
                payload = null
            };
            yield return(dropdownMenuElement);

            SkillDef           workSkill             = bill.recipe.workSkill;
            IEnumerable <Pawn> allMaps_FreeColonists = PawnsFinder.AllMaps_FreeColonists;

            allMaps_FreeColonists = allMaps_FreeColonists.OrderBy((Pawn pawn) => pawn.LabelShortCap);
            if (workSkill != null)
            {
                allMaps_FreeColonists = allMaps_FreeColonists.OrderByDescending((Pawn pawn) => pawn.skills.GetSkill(bill.recipe.workSkill).Level);
            }
            WorkGiverDef workGiver = bill.billStack.billGiver.GetWorkgiver();

            if (workGiver == null)
            {
                Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148);
                yield break;
            }
            allMaps_FreeColonists = allMaps_FreeColonists.OrderByDescending((Pawn pawn) => pawn.workSettings.WorkIsActive(workGiver.workType));
            allMaps_FreeColonists = allMaps_FreeColonists.OrderBy((Pawn pawn) => pawn.WorkTypeIsDisabled(workGiver.workType));
            foreach (Pawn pawn2 in allMaps_FreeColonists)
            {
                if (pawn2.WorkTypeIsDisabled(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option  = new FloatMenuOption(string.Format("{0} ({1})", pawn2.LabelShortCap, "WillNever".Translate(workGiver.verb)), null),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (bill.recipe.workSkill != null && !pawn2.workSettings.WorkIsActive(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", pawn2.LabelShortCap, pawn2.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (!pawn2.workSettings.WorkIsActive(workGiver.workType))
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption(string.Format("{0} ({1})", pawn2.LabelShortCap, "NotAssigned".Translate()), delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else if (bill.recipe.workSkill != null)
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption($"{pawn2.LabelShortCap} ({pawn2.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
                else
                {
                    dropdownMenuElement = new Widgets.DropdownMenuElement <Pawn>
                    {
                        option = new FloatMenuOption($"{pawn2.LabelShortCap}", delegate
                        {
                            bill.pawnRestriction = pawn2;
                        }),
                        payload = pawn2
                    };
                    yield return(dropdownMenuElement);
                }
            }
        }
        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);
                    }
                }
            }
        }