Пример #1
0
 public static void DoTrainableCheckbox(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport canTrain, bool drawLabel, bool doTooltip)
 {
     if (pawn.training.IsCompleted(td))
     {
         if (!drawLabel)
         {
             GUI.DrawTexture(rect, TrainingCardUtility.TrainedTrainableTex);
         }
     }
     else
     {
         bool wanted = pawn.training.GetWanted(td);
         bool flag   = wanted;
         if (drawLabel)
         {
             Widgets.CheckboxLabeled(rect, td.LabelCap, ref wanted, !canTrain.Accepted);
         }
         else
         {
             Widgets.Checkbox(rect.position, ref wanted, rect.width, !canTrain.Accepted);
         }
         if (wanted != flag)
         {
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.AnimalTraining, KnowledgeAmount.Total);
             pawn.training.SetWantedRecursive(td, wanted);
         }
     }
     if (doTooltip)
     {
         TrainingCardUtility.DoTrainableTooltip(rect, pawn, td, canTrain);
     }
 }
Пример #2
0
        public static void DoTrainableCheckbox(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport canTrain, bool drawLabel, bool doTooltip)
        {
            bool      flag         = pawn.training.HasLearned(td);
            bool      wanted       = pawn.training.GetWanted(td);
            bool      flag2        = wanted;
            Texture2D texChecked   = (!flag) ? null : TrainingCardUtility.LearnedTrainingTex;
            Texture2D texUnchecked = (!flag) ? null : TrainingCardUtility.LearnedNotTrainingTex;

            if (drawLabel)
            {
                Widgets.CheckboxLabeled(rect, td.LabelCap, ref wanted, !canTrain.Accepted, texChecked, texUnchecked, false);
            }
            else
            {
                Widgets.Checkbox(rect.position, ref wanted, rect.width, !canTrain.Accepted, true, texChecked, texUnchecked);
            }
            if (wanted != flag2)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.AnimalTraining, KnowledgeAmount.Total);
                pawn.training.SetWantedRecursive(td, wanted);
            }
            if (doTooltip)
            {
                TrainingCardUtility.DoTrainableTooltip(rect, pawn, td, canTrain);
            }
        }
Пример #3
0
        private static bool TryDrawTrainableRow(Rect rect, Pawn pawn, TrainableDef td)
        {
            bool             flag     = pawn.training.IsCompleted(td);
            bool             flag2    = default(bool);
            AcceptanceReport canTrain = pawn.training.CanAssignToTrain(td, out flag2);

            if (!flag2)
            {
                return(false);
            }
            Widgets.DrawHighlightIfMouseover(rect);
            Rect rect2 = rect;

            rect2.width -= 50f;
            rect2.xMin  += (float)((float)td.indent * 10.0);
            Rect rect3 = rect;

            rect3.xMin = (float)(rect3.xMax - 50.0 + 17.0);
            if (!flag)
            {
                TrainingCardUtility.DoTrainableCheckbox(rect2, pawn, td, canTrain, true, false);
            }
            else
            {
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(rect2, td.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            if (flag)
            {
                GUI.color = Color.green;
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect3, pawn.training.GetSteps(td) + " / " + td.steps);
            Text.Anchor = TextAnchor.UpperLeft;
            if (DebugSettings.godMode && !pawn.training.IsCompleted(td))
            {
                Rect rect4 = rect3;
                rect4.yMin = (float)(rect4.yMax - 10.0);
                rect4.xMin = (float)(rect4.xMax - 10.0);
                if (Widgets.ButtonText(rect4, "+", true, false, true))
                {
                    pawn.training.Train(td, pawn.Map.mapPawns.FreeColonistsSpawned.RandomElement());
                }
            }
            TrainingCardUtility.DoTrainableTooltip(rect, pawn, td, canTrain);
            GUI.color = Color.white;
            return(true);
        }