Exemple #1
0
 private void DrawPawnPriorities(ref float curY, float width)
 {
     try
     {
         if (!PawnForWork.Dead)
         {
             string pawnKey            = PawnForWork.GetUniqueLoadID();
             YouDoYou_MapComponent ydy = Find.CurrentMap.GetComponent <YouDoYou_MapComponent>();
             if (ydy.pawnFree == null)
             {
                 ydy.pawnFree = new Dictionary <string, bool>();
             }
             if (!ydy.pawnFree.ContainsKey(pawnKey))
             {
                 ydy.pawnFree[pawnKey] = true;
             }
             foreach (KeyValuePair <WorkTypeDef, Priority> pair in (
                          from x in ydy.GetPriorities(PawnForWork)
                          orderby x.Value descending, x.Key.naturalPriority descending
                          select x
                          ))
             {
                 DrawPawnWorkPriority(ref curY, width, pair.Key, pair.Value);
             }
         }
     }
     catch
     {
         Logger.Message("could not draw pawn priorities");
     }
 }
Exemple #2
0
 public Priority(Pawn pawn, WorkTypeDef workTypeDef, YouDoYou_Settings settings, bool freePawn)
 {
     this.pawn              = pawn;
     this.workTypeDef       = workTypeDef;
     this.adjustmentStrings = new List <string> {
     };
     this.mapComp           = pawn.Map.GetComponent <YouDoYou_MapComponent>();
     this.worldComp         = Find.World.GetComponent <YouDoYou_WorldComponent>();
     if (freePawn)
     {
         this.set(0.2f, "YouDoYouPriorityGlobalDefault".Translate()).compute();
     }
     else
     {
         int p = pawn.workSettings.GetPriority(workTypeDef);
         if (p == 0)
         {
             this.set(0.0f, "YouDoYouPriorityNoFreeWill".Translate());
         }
         else
         {
             this.set((100f - onePriorityWidth * (p - 1)) / 100f, "YouDoYouPriorityNoFreeWill".Translate());
         }
     }
 }
        static void Postfix(PawnTableDef def, ref Func <IEnumerable <Pawn> > ___pawnsGetter)
        {
            if (def != PawnTableDefOf.Work)
            {
                return;
            }
            Func <IEnumerable <Pawn> > oldPawns = ___pawnsGetter;

            try
            {
                ___pawnsGetter = () =>
                {
                    try
                    {
                        List <Pawn> newPawns = new List <Pawn>();
                        foreach (Pawn pawn in oldPawns())
                        {
                            YouDoYou_MapComponent ydy = pawn.Map.GetComponent <YouDoYou_MapComponent>();
                            string pawnKey            = pawn.GetUniqueLoadID();
                            if (ydy != null && ydy.pawnFree != null && ydy.pawnFree.ContainsKey(pawnKey) && ydy.pawnFree[pawnKey])
                            {
                                continue;
                            }
                            newPawns.Add(pawn);
                        }
                        return(newPawns);
                    }
                    catch
                    {
                        Logger.Message("You Do You could not remove free pawns from work tab - likely due to a mod conflict");
                        return(oldPawns());
                    }
                };
                Logger.Message("You Do You sucessfully patched the work tab");
            }
            catch
            {
                Logger.Message("You Do You failed to patch the work tab");
                ___pawnsGetter = oldPawns;
            }
        }
Exemple #4
0
 private void DrawPawnFreewillCheckbox(Pawn pawn, ref float curY)
 {
     try
     {
         if (pawn == null)
         {
             return;
         }
         string pawnKey            = pawn.GetUniqueLoadID();
         YouDoYou_MapComponent ydy = Find.CurrentMap.GetComponent <YouDoYou_MapComponent>();
         if (ydy.pawnFree == null)
         {
             ydy.pawnFree = new Dictionary <string, bool>();
         }
         if (!ydy.pawnFree.ContainsKey(pawnKey))
         {
             ydy.pawnFree[pawnKey] = true;
         }
         bool isFree = ydy.pawnFree[pawnKey];
         bool flag   = isFree;
         Rect rect   = new Rect(0f, curY, 90f, 24f);
         Text.Font = GameFont.Small;
         GUI.color = Color.white;
         Widgets.CheckboxLabeled(rect, "YouDoYouCheckboxFreewill".Translate(), ref isFree, false, null, null, false);
         if (Mouse.IsOver(rect))
         {
             TooltipHandler.TipRegion(rect, "YouDoYouFreePawnTip".Translate(Faction.OfPlayer.def.pawnsPlural).CapitalizeFirst());
         }
         if (flag != isFree)
         {
             ydy.pawnFree[pawnKey] = isFree;
         }
     }
     catch
     {
         Logger.Message("could not draw pawn free will checkbox");
     }
     curY += 28f;
 }