Ejemplo n.º 1
0
        public static WorkGiverDef GetWorkgiver(this IBillGiver billGiver)
        {
            Thing thing = billGiver as Thing;

            if (thing == null)
            {
                Log.ErrorOnce(string.Format("Attempting to get the workgiver for a non-Thing IBillGiver {0}", billGiver.ToString()), 96810282, false);
                return(null);
            }
            List <WorkGiverDef> allDefsListForReading = DefDatabase <WorkGiverDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                WorkGiverDef     workGiverDef     = allDefsListForReading[i];
                WorkGiver_DoBill workGiver_DoBill = workGiverDef.Worker as WorkGiver_DoBill;
                if (workGiver_DoBill != null)
                {
                    if (workGiver_DoBill.ThingIsUsableBillGiver(thing))
                    {
                        return(workGiverDef);
                    }
                }
            }
            Log.ErrorOnce(string.Format("Can't find a WorkGiver for a BillGiver {0}", thing.ToString()), 57348705, false);
            return(null);
        }
Ejemplo n.º 2
0
 private bool WorkGiversRelated(WorkGiverDef current, WorkGiverDef next)
 {
     if (next == WorkGiverDefOf.Repair)
     {
         return(current == WorkGiverDefOf.Repair);
     }
     return(true);
 }
Ejemplo n.º 3
0
 private bool WorkGiversRelated(WorkGiverDef current, WorkGiverDef next)
 {
     if (next != WorkGiverDefOf.Repair || current == WorkGiverDefOf.Repair)
     {
         return(next.doesSmoothing == current.doesSmoothing);
     }
     return(false);
 }
Ejemplo n.º 4
0
 private string DebugStringFor(WorkGiverDef wg)
 {
     return(string.Concat(new object[]
     {
         "[",
         this.GetPriority(wg.workType),
         " ",
         wg.workType.defName,
         "] - ",
         wg.defName,
         " (",
         wg.priorityInType,
         ")"
     }));
 }
Ejemplo n.º 5
0
 private bool AllowsWorkGiver(WorkGiverDef workGiver)
 {
     return((workDisables & workGiver.workTags) == 0);
 }
Ejemplo n.º 6
0
 private static bool <CacheWorkGiversInOrder> m__3(WorkGiverDef wg)
 {
     return(!wg.emergency);
 }
 //
 // Constructors
 //
 public WorkGiver_RepairDroidsInactive(WorkGiverDef giverDef) : base(giverDef)
 {
 }
Ejemplo n.º 8
0
 private string DebugStringFor(WorkGiverDef wg)
 {
     return("[" + GetPriority(wg.workType) + " " + wg.workType.defName + "] - " + wg.defName + " (" + wg.priorityInType + ")");
 }
Ejemplo n.º 9
0
 private bool AllowsWorkGiver(WorkGiverDef workGiver)
 {
     return((this.workDisables & workGiver.workTags) == WorkTags.None);
 }
Ejemplo n.º 10
0
        private IEnumerable <Widgets.DropdownMenuElement <Pawn> > GeneratePawnRestrictionOptions()
        {
            yield return(new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("AnyWorker".Translate(), delegate()
                {
                    this.bill.pawnRestriction = null;
                }, MenuOptionPriority.Default, null, null, 0f, null, null),
                payload = null
            });

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

            pawns = from pawn in pawns
                    orderby pawn.LabelShortCap
                    select pawn;

            if (workSkill != null)
            {
                pawns = from pawn in pawns
                        orderby pawn.skills.GetSkill(this.bill.recipe.workSkill).Level descending
                        select pawn;
            }
            WorkGiverDef workGiver = this.bill.billStack.billGiver.GetWorkgiver();

            if (workGiver == null)
            {
                Log.ErrorOnce("Generating pawn restrictions for a BillGiver without a Workgiver", 96455148, false);
                yield break;
            }
            pawns = from pawn in pawns
                    orderby pawn.workSettings.WorkIsActive(workGiver.workType) descending
                    select pawn;

            pawns = from pawn in pawns
                    orderby pawn.story.WorkTypeIsDisabled(workGiver.workType)
                    select pawn;

            using (IEnumerator <Pawn> enumerator = pawns.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Pawn pawn = enumerator.Current;
                    if (pawn.story.WorkTypeIsDisabled(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "WillNever".Translate(new object[]
                            {
                                workGiver.verb
                            })), null, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (this.bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", new object[]
                            {
                                pawn.LabelShortCap,
                                pawn.skills.GetSkill(this.bill.recipe.workSkill).Level,
                                this.bill.recipe.workSkill.label,
                                "NotAssigned".Translate()
                            }), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (!pawn.workSettings.WorkIsActive(workGiver.workType))
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else if (this.bill.recipe.workSkill != null)
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0} ({1} {2})", pawn.LabelShortCap, pawn.skills.GetSkill(this.bill.recipe.workSkill).Level, this.bill.recipe.workSkill.label), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                    else
                    {
                        yield return(new Widgets.DropdownMenuElement <Pawn>
                        {
                            option = new FloatMenuOption(string.Format("{0}", pawn.LabelShortCap), delegate()
                            {
                                this.bill.pawnRestriction = pawn;
                            }, MenuOptionPriority.Default, null, null, 0f, null, null),
                            payload = pawn
                        });
                    }
                }
            }
            yield break;
        }
Ejemplo n.º 11
0
        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);
                }
            }
        }