public static bool isMountable(Pawn pawn, out Reason reason) { reason = Reason.CanMount; if (!isAllowedInModOptions(pawn.def.defName)) { reason = Reason.NotInModOptions; return(false); } if (pawn.ageTracker.CurLifeStageIndex != pawn.RaceProps.lifeStageAges.Count - 1) { if (!pawn.def.HasModExtension <AllowedLifeStagesPatch>()) { reason = Reason.NotFullyGrown; return(false); } else //Use custom life stages instead of last life stage if a patch exists for that { AllowedLifeStagesPatch customLifeStages = pawn.def.GetModExtension <AllowedLifeStagesPatch>(); if (!customLifeStages.getAllowedLifeStagesAsList().Contains(pawn.ageTracker.CurLifeStageIndex)) { reason = Reason.NotFullyGrown; return(false); } } } if (pawn.training == null || (pawn.training != null && !pawn.training.HasLearned(TrainableDefOf.Obedience))) { reason = Reason.NeedsObedience; return(false); } return(true); }
public static bool isMountable(Pawn animal, out Reason reason) { reason = Reason.CanMount; if (!isAllowedInModOptions(animal.def.defName)) { reason = Reason.NotInModOptions; return(false); } if (animal.ageTracker.CurLifeStageIndex != animal.RaceProps.lifeStageAges.Count - 1) { if (!animal.def.HasModExtension <AllowedLifeStagesPatch>()) { reason = Reason.NotFullyGrown; return(false); } else //Use custom life stages instead of last life stage if a patch exists for that { AllowedLifeStagesPatch customLifeStages = animal.def.GetModExtension <AllowedLifeStagesPatch>(); if (!customLifeStages.getAllowedLifeStagesAsList().Contains(animal.ageTracker.CurLifeStageIndex)) { reason = Reason.NotFullyGrown; return(false); } } } if (animal.training == null || (animal.training != null && !animal.training.HasLearned(TrainableDefOf.Tameness))) { reason = Reason.NeedsTraining; return(false); } if (animal.roping != null && animal.roping.IsRoped) { reason = Reason.IsRoped; return(false); } return(true); }