Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 private static void DoTrainableTooltip(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport canTrain)
 {
     TooltipHandler.TipRegion(rect, delegate
     {
         string text = td.LabelCap + "\n\n" + td.description;
         if (!canTrain.Accepted)
         {
             text = text + "\n\n" + canTrain.Reason;
         }
         else if (!td.prerequisites.NullOrEmpty <TrainableDef>())
         {
             text += "\n";
             for (int i = 0; i < td.prerequisites.Count; i++)
             {
                 if (!pawn.training.HasLearned(td.prerequisites[i]))
                 {
                     text = text + "\n" + "TrainingNeedsPrerequisite".Translate(new object[]
                     {
                         td.prerequisites[i].LabelCap
                     });
                 }
             }
         }
         return(text);
     }, (int)(rect.y * 612f + rect.x));
 }
        public bool CanBeTrained(TrainableDef td)
        {
            bool result;

            if (this.steps[td] >= td.steps)
            {
                result = false;
            }
            else
            {
                List <TrainableDef> prerequisites = td.prerequisites;
                if (!prerequisites.NullOrEmpty <TrainableDef>())
                {
                    for (int i = 0; i < prerequisites.Count; i++)
                    {
                        if (!this.HasLearned(prerequisites[i]) || this.CanBeTrained(prerequisites[i]))
                        {
                            return(false);
                        }
                    }
                }
                result = true;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static void DoTrainableCheckbox(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport canTrain, bool drawLabel, bool doTooltip)
        {
            bool      flag         = pawn.training.HasLearned(td);
            bool      checkOn      = pawn.training.GetWanted(td);
            bool      flag2        = checkOn;
            Texture2D texChecked   = (!flag) ? null : LearnedTrainingTex;
            Texture2D texUnchecked = (!flag) ? null : LearnedNotTrainingTex;

            if (drawLabel)
            {
                Widgets.CheckboxLabeled(rect, td.LabelCap, ref checkOn, !canTrain.Accepted, texChecked, texUnchecked);
            }
            else
            {
                Widgets.Checkbox(rect.position, ref checkOn, rect.width, !canTrain.Accepted, paintable: true, texChecked, texUnchecked);
            }
            if (checkOn != flag2)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.AnimalTraining, KnowledgeAmount.Total);
                pawn.training.SetWantedRecursive(td, checkOn);
            }
            if (doTooltip)
            {
                DoTrainableTooltip(rect, pawn, td, canTrain);
            }
        }
Ejemplo n.º 5
0
        public static void Reset()
        {
            defsInListOrder.Clear();
            defsInListOrder.AddRange(DefDatabase <TrainableDef> .AllDefsListForReading.OrderByDescending((TrainableDef td) => td.listPriority));
            bool flag;

            do
            {
                flag = false;
                for (int i = 0; i < defsInListOrder.Count; i++)
                {
                    TrainableDef trainableDef = defsInListOrder[i];
                    if (trainableDef.prerequisites != null)
                    {
                        for (int j = 0; j < trainableDef.prerequisites.Count; j++)
                        {
                            if (trainableDef.indent <= trainableDef.prerequisites[j].indent)
                            {
                                trainableDef.indent = trainableDef.prerequisites[j].indent + 1;
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }while (flag);
        }
Ejemplo n.º 6
0
        public static Toil TryTrain(TargetIndex traineeInd)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                Pawn pawn  = (Pawn)actor.jobs.curJob.GetTarget(traineeInd).Thing;
                if (pawn.Spawned && pawn.Awake() && actor.interactions.TryInteractWith(pawn, InteractionDefOf.TrainAttempt))
                {
                    float num = actor.GetStatValue(StatDefOf.TrainAnimalChance, true);
                    num *= GenMath.LerpDouble(0f, 1f, 1.5f, 0.5f, pawn.RaceProps.wildness);
                    if (actor.relations.DirectRelationExists(PawnRelationDefOf.Bond, pawn))
                    {
                        num *= 5f;
                    }
                    num = Mathf.Clamp01(num);
                    TrainableDef trainableDef = pawn.training.NextTrainableToTrain();
                    if (trainableDef == null)
                    {
                        Log.ErrorOnce("Attempted to train untrainable animal", 7842936, false);
                        return;
                    }
                    string text;
                    if (Rand.Value < num)
                    {
                        pawn.training.Train(trainableDef, actor, false);
                        if (pawn.caller != null)
                        {
                            pawn.caller.DoCall();
                        }
                        text = "TextMote_TrainSuccess".Translate(trainableDef.LabelCap, num.ToStringPercent());
                        RelationsUtility.TryDevelopBondRelation(actor, pawn, 0.007f);
                        TaleRecorder.RecordTale(TaleDefOf.TrainedAnimal, new object[]
                        {
                            actor,
                            pawn,
                            trainableDef
                        });
                    }
                    else
                    {
                        text = "TextMote_TrainFail".Translate(trainableDef.LabelCap, num.ToStringPercent());
                    }
                    string text2 = text;
                    text = string.Concat(new object[]
                    {
                        text2,
                        "\n",
                        pawn.training.GetSteps(trainableDef),
                        " / ",
                        trainableDef.steps
                    });
                    MoteMaker.ThrowText((actor.DrawPos + pawn.DrawPos) / 2f, actor.Map, text, 5f);
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = 100;
            return(toil);
        }
Ejemplo n.º 7
0
        public static void Reset()
        {
            TrainableUtility.defsInListOrder.Clear();
            TrainableUtility.defsInListOrder.AddRange(from td in DefDatabase <TrainableDef> .AllDefsListForReading
                                                      orderby td.listPriority descending
                                                      select td);
            bool flag;

            do
            {
                flag = false;
                for (int i = 0; i < TrainableUtility.defsInListOrder.Count; i++)
                {
                    TrainableDef trainableDef = TrainableUtility.defsInListOrder[i];
                    if (trainableDef.prerequisites != null)
                    {
                        for (int j = 0; j < trainableDef.prerequisites.Count; j++)
                        {
                            if (trainableDef.indent <= trainableDef.prerequisites[j].indent)
                            {
                                trainableDef.indent = trainableDef.prerequisites[j].indent + 1;
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
            }while (flag);
        }
Ejemplo n.º 8
0
        public static IEnumerable <PawnColumnDef> ImpliedPawnColumnDefs()
        {
            PawnTableDef animalsTable = PawnTableDefOf.Animals;

            using (IEnumerator <TrainableDef> enumerator = (from td in DefDatabase <TrainableDef> .AllDefsListForReading
                                                            orderby td.listPriority descending
                                                            select td).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    TrainableDef  sourceDef = enumerator.Current;
                    PawnColumnDef d3        = new PawnColumnDef
                    {
                        defName        = "Trainable_" + sourceDef.defName,
                        trainable      = sourceDef,
                        headerIcon     = sourceDef.icon,
                        workerClass    = typeof(PawnColumnWorker_Trainable),
                        sortable       = true,
                        headerTip      = sourceDef.LabelCap,
                        paintable      = true,
                        modContentPack = sourceDef.modContentPack
                    };
                    animalsTable.columns.Insert(animalsTable.columns.FindIndex((PawnColumnDef x) => x.Worker is PawnColumnWorker_Checkbox) - 1, d3);
                    yield return(d3);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            PawnTableDef workTable = PawnTableDefOf.Work;
            bool         moveWorkTypeLabelDown2 = false;

            using (IEnumerator <WorkTypeDef> enumerator2 = (from d in WorkTypeDefsUtility.WorkTypeDefsInPriorityOrder
                                                            where d.visible
                                                            select d).Reverse().GetEnumerator())
            {
                if (enumerator2.MoveNext())
                {
                    WorkTypeDef def = enumerator2.Current;
                    moveWorkTypeLabelDown2 = !moveWorkTypeLabelDown2;
                    PawnColumnDef d2 = new PawnColumnDef
                    {
                        defName  = "WorkPriority_" + def.defName,
                        workType = def,
                        moveWorkTypeLabelDown = moveWorkTypeLabelDown2,
                        workerClass           = typeof(PawnColumnWorker_WorkPriority),
                        sortable       = true,
                        modContentPack = def.modContentPack
                    };
                    workTable.columns.Insert(workTable.columns.FindIndex((PawnColumnDef x) => x.Worker is PawnColumnWorker_CopyPasteWorkPriorities) + 1, d2);
                    yield return(d2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_036c:
            /*Error near IL_036d: Unexpected return in MoveNext()*/;
        }
 public void TrainingTrackerTickRare()
 {
     if (this.pawn.Suspended)
     {
         this.countDecayFrom += 250;
     }
     else if (!this.pawn.Spawned)
     {
         this.countDecayFrom += 250;
     }
     else if (this.steps[TrainableDefOf.Tameness] == 0)
     {
         this.countDecayFrom = Find.TickManager.TicksGame;
     }
     else if (Find.TickManager.TicksGame >= this.countDecayFrom + TrainableUtility.DegradationPeriodTicks(this.pawn.def))
     {
         TrainableDef trainableDef = (from kvp in this.steps
                                      where kvp.Value > 0
                                      select kvp.Key).Except((from kvp in this.steps
                                                              where kvp.Value > 0 && kvp.Key.prerequisites != null
                                                              select kvp).SelectMany((KeyValuePair <TrainableDef, int> kvp) => kvp.Key.prerequisites)).RandomElement <TrainableDef>();
         if (trainableDef == TrainableDefOf.Tameness && !TrainableUtility.TamenessCanDecay(this.pawn.def))
         {
             this.countDecayFrom = Find.TickManager.TicksGame;
         }
         else
         {
             this.countDecayFrom = Find.TickManager.TicksGame;
             DefMap <TrainableDef, int> defMap;
             TrainableDef def;
             (defMap = this.steps)[def = trainableDef] = defMap[def] - 1;
             if (this.steps[trainableDef] <= 0 && this.learned[trainableDef])
             {
                 this.learned[trainableDef] = false;
                 if (this.pawn.Faction == Faction.OfPlayer)
                 {
                     if (trainableDef == TrainableDefOf.Tameness)
                     {
                         this.pawn.SetFaction(null, null);
                         Messages.Message("MessageAnimalReturnedWild".Translate(new object[]
                         {
                             this.pawn.LabelShort
                         }), this.pawn, MessageTypeDefOf.NegativeEvent, true);
                     }
                     else
                     {
                         Messages.Message("MessageAnimalLostSkill".Translate(new object[]
                         {
                             this.pawn.LabelShort,
                             trainableDef.LabelCap
                         }), this.pawn, MessageTypeDefOf.NegativeEvent, true);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
        public void Train(TrainableDef td, Pawn trainer)
        {
            DefMap <TrainableDef, int> defMap;

            (defMap = this.steps)[td] = defMap[td] + 1;
            if (this.IsCompleted(td) && td == TrainableDefOf.Obedience)
            {
                this.pawn.playerSettings.master = trainer;
            }
        }
Ejemplo n.º 11
0
 public AcceptanceReport CanAssignToTrain(TrainableDef td, out bool visible)
 {
     if (this.pawn.RaceProps.untrainableTags != null)
     {
         for (int i = 0; i < this.pawn.RaceProps.untrainableTags.Count; i++)
         {
             if (td.MatchesTag(this.pawn.RaceProps.untrainableTags[i]))
             {
                 visible = false;
                 return(false);
             }
         }
     }
     if (this.pawn.RaceProps.trainableTags != null)
     {
         int j = 0;
         while (j < this.pawn.RaceProps.trainableTags.Count)
         {
             if (td.MatchesTag(this.pawn.RaceProps.trainableTags[j]))
             {
                 if (this.pawn.BodySize < td.minBodySize)
                 {
                     visible = true;
                     return(new AcceptanceReport("CannotTrainTooSmall".Translate(this.pawn.LabelCapNoCount, this.pawn)));
                 }
                 visible = true;
                 return(true);
             }
             else
             {
                 j++;
             }
         }
     }
     if (!td.defaultTrainable)
     {
         visible = false;
         return(false);
     }
     if (this.pawn.BodySize < td.minBodySize)
     {
         visible = true;
         return(new AcceptanceReport("CannotTrainTooSmall".Translate(this.pawn.LabelCapNoCount, this.pawn)));
     }
     if (this.pawn.RaceProps.trainability.intelligenceOrder < td.requiredTrainability.intelligenceOrder)
     {
         visible = true;
         return(new AcceptanceReport("CannotTrainNotSmartEnough".Translate(td.requiredTrainability)));
     }
     visible = true;
     return(true);
 }
Ejemplo n.º 12
0
 public void TrainingTrackerTickRare()
 {
     if (pawn.Suspended)
     {
         countDecayFrom += 250;
     }
     else if (!pawn.Spawned)
     {
         countDecayFrom += 250;
     }
     else if (steps[TrainableDefOf.Tameness] == 0)
     {
         countDecayFrom = Find.TickManager.TicksGame;
     }
     else
     {
         if (Find.TickManager.TicksGame < countDecayFrom + TrainableUtility.DegradationPeriodTicks(pawn.def))
         {
             return;
         }
         TrainableDef trainableDef = (from kvp in steps
                                      where kvp.Value > 0
                                      select kvp.Key).Except(steps.Where((KeyValuePair <TrainableDef, int> kvp) => kvp.Value > 0 && kvp.Key.prerequisites != null).SelectMany((KeyValuePair <TrainableDef, int> kvp) => kvp.Key.prerequisites)).RandomElement();
         if (trainableDef == TrainableDefOf.Tameness && !TrainableUtility.TamenessCanDecay(pawn.def))
         {
             countDecayFrom = Find.TickManager.TicksGame;
             return;
         }
         countDecayFrom = Find.TickManager.TicksGame;
         steps[trainableDef]--;
         if (steps[trainableDef] > 0 || !learned[trainableDef])
         {
             return;
         }
         learned[trainableDef] = false;
         if (pawn.Faction == Faction.OfPlayer)
         {
             if (trainableDef == TrainableDefOf.Tameness)
             {
                 pawn.SetFaction(null);
                 Messages.Message("MessageAnimalReturnedWild".Translate(pawn.LabelShort, pawn), pawn, MessageTypeDefOf.NegativeEvent);
             }
             else
             {
                 Messages.Message("MessageAnimalLostSkill".Translate(pawn.LabelShort, trainableDef.LabelCap, pawn.Named("ANIMAL")), pawn, MessageTypeDefOf.NegativeEvent);
             }
         }
     }
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
 public void Train(TrainableDef td, Pawn trainer, bool complete = false)
 {
     if (complete)
     {
         steps[td] = td.steps;
     }
     else
     {
         steps[td]++;
     }
     if (steps[td] >= td.steps)
     {
         learned[td] = true;
         if (td == TrainableDefOf.Obedience && trainer != null && pawn.playerSettings != null && pawn.playerSettings.Master == null)
         {
             pawn.playerSettings.Master = trainer;
         }
     }
 }
        public static Toil TryTrain(TargetIndex traineeInd)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                Pawn pawn  = (Pawn)actor.jobs.curJob.GetTarget(traineeInd).Thing;
                if (pawn.Spawned && pawn.Awake() && actor.interactions.TryInteractWith(pawn, InteractionDefOf.TrainAttempt))
                {
                    float statValue = actor.GetStatValue(StatDefOf.TrainAnimalChance, true);
                    statValue *= Mathf.Max(0.05f, GenMath.LerpDouble(0f, 1f, 2f, 0f, pawn.RaceProps.wildness));
                    if (actor.relations.DirectRelationExists(PawnRelationDefOf.Bond, pawn))
                    {
                        statValue = (float)(statValue * 1.5);
                    }
                    statValue = Mathf.Clamp01(statValue);
                    TrainableDef trainableDef = pawn.training.NextTrainableToTrain();
                    string       text;
                    if (Rand.Value < statValue)
                    {
                        pawn.training.Train(trainableDef, actor);
                        if (pawn.caller != null)
                        {
                            pawn.caller.DoCall();
                        }
                        text = "TextMote_TrainSuccess".Translate(trainableDef.LabelCap, statValue.ToStringPercent());
                        RelationsUtility.TryDevelopBondRelation(actor, pawn, 0.007f);
                        TaleRecorder.RecordTale(TaleDefOf.TrainedAnimal, actor, pawn, trainableDef);
                    }
                    else
                    {
                        text = "TextMote_TrainFail".Translate(trainableDef.LabelCap, statValue.ToStringPercent());
                    }
                    string text2 = text;
                    text = text2 + "\n" + pawn.training.GetSteps(trainableDef) + " / " + trainableDef.steps;
                    MoteMaker.ThrowText((actor.DrawPos + pawn.DrawPos) / 2f, actor.Map, text, 5f);
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = 100;
            return(toil);
        }
Ejemplo n.º 16
0
 public void SetWantedRecursive(TrainableDef td, bool checkOn)
 {
     SetWanted(td, checkOn);
     if (checkOn)
     {
         if (td.prerequisites != null)
         {
             for (int i = 0; i < td.prerequisites.Count; i++)
             {
                 SetWantedRecursive(td.prerequisites[i], checkOn: true);
             }
         }
         return;
     }
     foreach (TrainableDef item in DefDatabase <TrainableDef> .AllDefsListForReading.Where((TrainableDef t) => t.prerequisites != null && t.prerequisites.Contains(td)))
     {
         SetWantedRecursive(item, checkOn: false);
     }
 }
Ejemplo n.º 17
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 == null || !pawn2.RaceProps.Animal)
            {
                return(null);
            }
            if (pawn2.Faction != pawn.Faction)
            {
                return(null);
            }
            if (TrainableUtility.TrainedTooRecently(pawn2))
            {
                JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans);
                return(null);
            }
            if (pawn2.training == null)
            {
                return(null);
            }
            TrainableDef trainableDef = pawn2.training.NextTrainableToTrain();

            if (trainableDef == null)
            {
                return(null);
            }
            if (!CanInteractWithAnimal(pawn, pawn2, forced))
            {
                return(null);
            }
            if (pawn2.RaceProps.EatsFood && !HasFoodToInteractAnimal(pawn, pawn2))
            {
                Job job = TakeFoodForAnimalInteractJob(pawn, pawn2);
                if (job == null)
                {
                    JobFailReason.Is(WorkGiver_InteractAnimal.NoUsableFoodTrans);
                }
                return(job);
            }
            return(new Job(JobDefOf.Train, t));
        }
 public void Train(TrainableDef td, Pawn trainer, bool complete = false)
 {
     if (complete)
     {
         this.steps[td] = td.steps;
     }
     else
     {
         DefMap <TrainableDef, int> defMap;
         (defMap = this.steps)[td] = defMap[td] + 1;
     }
     if (this.steps[td] >= td.steps)
     {
         this.learned[td] = true;
         if (td == TrainableDefOf.Obedience && trainer != null && this.pawn.playerSettings != null && this.pawn.playerSettings.Master == null)
         {
             this.pawn.playerSettings.Master = trainer;
         }
     }
 }
Ejemplo n.º 19
0
        public bool CanBeTrained(TrainableDef td)
        {
            if (steps[td] >= td.steps)
            {
                return(false);
            }
            List <TrainableDef> prerequisites = td.prerequisites;

            if (!prerequisites.NullOrEmpty())
            {
                for (int i = 0; i < prerequisites.Count; i++)
                {
                    if (!HasLearned(prerequisites[i]) || CanBeTrained(prerequisites[i]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 20
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Pawn pawn2 = t as Pawn;

            if (pawn2 != null && pawn2.RaceProps.Animal)
            {
                if (pawn2.Faction != pawn.Faction)
                {
                    return(null);
                }
                if (Find.TickManager.TicksGame < pawn2.mindState.lastAssignedInteractTime + 15000)
                {
                    JobFailReason.Is(WorkGiver_InteractAnimal.AnimalInteractedTooRecentlyTrans);
                    return(null);
                }
                if (pawn2.training == null)
                {
                    return(null);
                }
                TrainableDef trainableDef = pawn2.training.NextTrainableToTrain();
                if (trainableDef == null)
                {
                    return(null);
                }
                if (!this.CanInteractWithAnimal(pawn, pawn2))
                {
                    return(null);
                }
                if (pawn2.RaceProps.EatsFood && !base.HasFoodToInteractAnimal(pawn, pawn2))
                {
                    Job job = base.TakeFoodForAnimalInteractJob(pawn, pawn2);
                    if (job == null)
                    {
                        JobFailReason.Is(WorkGiver_InteractAnimal.NoUsableFoodTrans);
                    }
                    return(job);
                }
                return(new Job(JobDefOf.Train, t));
            }
            return(null);
        }
Ejemplo n.º 21
0
 public static void Reset()
 {
     TrainableUtility.defsInListOrder.Clear();
     TrainableUtility.defsInListOrder.AddRange(from td in DefDatabase <TrainableDef> .AllDefsListForReading
                                               orderby td.listPriority descending
                                               select td);
     while (true)
     {
         bool flag = false;
         int  num  = 0;
         while (num < TrainableUtility.defsInListOrder.Count)
         {
             TrainableDef trainableDef = TrainableUtility.defsInListOrder[num];
             if (trainableDef.prerequisites != null)
             {
                 int num2 = 0;
                 while (num2 < trainableDef.prerequisites.Count)
                 {
                     if (trainableDef.indent > trainableDef.prerequisites[num2].indent)
                     {
                         num2++;
                         continue;
                     }
                     trainableDef.indent = trainableDef.prerequisites[num2].indent + 1;
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 num++;
                 continue;
             }
             break;
         }
         if (!flag)
         {
             break;
         }
     }
 }
Ejemplo n.º 22
0
        private static bool TryDrawTrainableRow(Rect rect, Pawn pawn, TrainableDef td)
        {
            bool             flag = pawn.training.HasLearned(td);
            bool             visible;
            AcceptanceReport canTrain = pawn.training.CanAssignToTrain(td, out visible);

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

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

            rect3.xMin = rect3.xMax - 50f + 17f;
            DoTrainableCheckbox(rect2, pawn, td, canTrain, drawLabel: true, doTooltip: false);
            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.HasLearned(td))
            {
                Rect rect4 = rect3;
                rect4.yMin = rect4.yMax - 10f;
                rect4.xMin = rect4.xMax - 10f;
                if (Widgets.ButtonText(rect4, "+"))
                {
                    pawn.training.Train(td, pawn.Map.mapPawns.FreeColonistsSpawned.RandomElement());
                }
            }
            DoTrainableTooltip(rect, pawn, td, canTrain);
            GUI.color = Color.white;
            return(true);
        }
 public void SetWantedRecursive(TrainableDef td, bool checkOn)
 {
     this.SetWanted(td, checkOn);
     if (checkOn)
     {
         if (td.prerequisites != null)
         {
             for (int i = 0; i < td.prerequisites.Count; i++)
             {
                 this.SetWantedRecursive(td.prerequisites[i], true);
             }
         }
     }
     else
     {
         IEnumerable <TrainableDef> enumerable = from t in DefDatabase <TrainableDef> .AllDefsListForReading
                                                 where t.prerequisites != null && t.prerequisites.Contains(td)
                                                 select t;
         foreach (TrainableDef td2 in enumerable)
         {
             this.SetWantedRecursive(td2, false);
         }
     }
 }
        // Token: 0x0600000A RID: 10 RVA: 0x000023F8 File Offset: 0x000005F8
        protected override Job TryGiveJob(Pawn pawn)
        {
            pawn.training.SetWantedRecursive(TrainableDefOf.Obedience, true);
            bool flag = pawn.training.NextTrainableToTrain() != null;

            if (flag)
            {
                pawn.training.SetWantedRecursive(TrainableDefOf.Release, true);
                TrainableDef td = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td, null, false);
            }
            bool flag2 = pawn.training.NextTrainableToTrain() != null;

            if (flag2)
            {
                TrainableDef td2 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td2, null, false);
            }
            bool flag3 = pawn.training.NextTrainableToTrain() != null;

            if (flag3)
            {
                TrainableDef td3 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td3, null, false);
            }
            bool flag4 = pawn.training.NextTrainableToTrain() != null;

            if (flag4)
            {
                TrainableDef td4 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td4, null, false);
            }
            bool flag5 = pawn.training.NextTrainableToTrain() != null;

            if (flag5)
            {
                TrainableDef td5 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td5, null, false);
            }
            bool flag6 = pawn.training.NextTrainableToTrain() != null;

            if (flag6)
            {
                TrainableDef td6 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td6, null, false);
            }
            bool flag7 = pawn.training.NextTrainableToTrain() != null;

            if (flag7)
            {
                TrainableDef td7 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td7, null, false);
            }
            bool flag8 = pawn.training.NextTrainableToTrain() != null;

            if (flag8)
            {
                TrainableDef td8 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td8, null, false);
            }
            bool flag9 = pawn.training.NextTrainableToTrain() != null;

            if (flag9)
            {
                TrainableDef td9 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td9, null, false);
            }
            bool flag10 = pawn.training.NextTrainableToTrain() != null;

            if (flag10)
            {
                TrainableDef td10 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td10, null, false);
            }
            bool flag11 = pawn.training.NextTrainableToTrain() != null;

            if (flag11)
            {
                TrainableDef td11 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td11, null, false);
            }
            bool flag12 = pawn.training.NextTrainableToTrain() != null;

            if (flag12)
            {
                TrainableDef td12 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td12, null, false);
            }
            bool flag13 = pawn.training.NextTrainableToTrain() != null;

            if (flag13)
            {
                TrainableDef td13 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td13, null, false);
            }
            bool flag14 = pawn.training.NextTrainableToTrain() != null;

            if (flag14)
            {
                TrainableDef td14 = pawn.training.NextTrainableToTrain();
                pawn.training.Train(td14, null, false);
            }
            return(null);
        }
        public AcceptanceReport CanAssignToTrain(TrainableDef td)
        {
            bool flag;

            return(this.CanAssignToTrain(td, out flag));
        }
 public bool HasLearned(TrainableDef td)
 {
     return(this.learned[td]);
 }
 internal int GetSteps(TrainableDef td)
 {
     return(this.steps[td]);
 }
 private void SetWanted(TrainableDef td, bool wanted)
 {
     this.wantedTrainables[td] = wanted;
 }
 public bool GetWanted(TrainableDef td)
 {
     return(this.wantedTrainables[td]);
 }
 internal bool <> m__0(TrainableDef t)
 {
     return(t.prerequisites != null && t.prerequisites.Contains(this.td));
 }