Example #1
0
        public static void GroupExclusionButton(Listing_Standard listing, Bill bill)
        {
            string label;

            switch (BillAssignationUtility.IsFor(bill))
            {
            case GroupMode.ColonistsOnly:
                label = "PrisonLabor_ColonistsOnlyShort".Translate();
                break;

            case GroupMode.PrisonersOnly:
                label = "PrisonLabor_PrisonersOnlyShort".Translate();
                break;

            case GroupMode.ColonyOnly:
                label = "PrisonLabor_ColonyOnlyShort".Translate();
                break;

            default:
                label = "no label";
                break;
            }

            if (listing.ButtonText(label))
            {
                MakeModeFloatMenu(bill);
            }

            listing.Gap(12f);
        }
        public static bool IsForCertainGroup(Pawn pawn, Bill bill)
        {
            var group = BillAssignationUtility.IsFor(bill);

            if (group == GroupMode.ColonyOnly)
            {
                return(true);
            }
            if (group == GroupMode.ColonistsOnly && !pawn.IsPrisoner && !pawn.IsSlave)
            {
                return(true);
            }
            if (group == GroupMode.PrisonersOnly && pawn.IsPrisoner)
            {
                return(true);
            }
            if (group == GroupMode.SlavesOnly && bill.SlavesOnly && pawn.IsSlave)
            {
                return(true);
            }

            if (group == GroupMode.CaptiveOnly && (pawn.IsPrisoner || (bill.SlavesOnly && pawn.IsSlave)))
            {
                return(true);
            }
            return(false);
        }
        public static string GetDropLabel(Dialog_BillConfig dialog)
        {
            Bill_Production bill      = Traverse.Create(dialog).Field("bill").GetValue <Bill_Production>();
            GroupMode       groupMode = BillAssignationUtility.IsFor(bill);

            switch (groupMode)
            {
            case GroupMode.ColonyOnly:
                return("PrisonLabor_ColonyOnly".Translate());

            case GroupMode.PrisonersOnly:
                return("PrisonLabor_PrisonersOnly".Translate());

            case GroupMode.ColonistsOnly:
                return("AnyWorker".Translate());

            case GroupMode.SlavesOnly:
                return("AnySlave".Translate());

            case GroupMode.CaptiveOnly:
                return("PrisonLabor_PrisonersAndSlaveOnly".Translate());

            default:
                return((!ModsConfig.IdeologyActive || !bill.SlavesOnly) ? ("AnyWorker".Translate()) : ("AnySlave".Translate()));
            }
        }
        static bool Postfix(bool __result, Bill __instance, Pawn p)
        {
            if (__result == false && __instance.PawnRestriction == null)
            {
                GroupMode group = BillAssignationUtility.IsFor(__instance);

                if (group == GroupMode.ColonyOnly && __instance.SlavesOnly && p.IsSlave)
                {
                    return(true);
                }
                if (group == GroupMode.SlavesOnly && __instance.SlavesOnly && p.IsSlave)
                {
                    return(true);
                }

                if (group == GroupMode.CaptiveOnly && __instance.SlavesOnly && p.IsSlave)
                {
                    return(true);
                }
                if (__instance.recipe.workSkill != null)
                {
                    int level = p.skills.GetSkill(__instance.recipe.workSkill).Level;
                    if (level < __instance.allowedSkillRange.min)
                    {
                        JobFailReason.Is("UnderAllowedSkill".Translate(__instance.allowedSkillRange.min), __instance.Label);
                        return(false);
                    }
                    if (level > __instance.allowedSkillRange.max)
                    {
                        JobFailReason.Is("AboveAllowedSkill".Translate(__instance.allowedSkillRange.max), __instance.Label);
                        return(false);
                    }
                }
                if (group == GroupMode.ColonyOnly || (group == GroupMode.CaptiveOnly && p.IsPrisoner))
                {
                    return(true);
                }
            }
            return(__result);
        }