public static bool TwelfthWithin(this Pawn p, List <IntRange> parameters) { if (p.Map == null) { return(false); } int val = (int)GenLocalDate.Twelfth(p); return(parameters.Any(ir => ir.min >= val && ir.max <= val)); }
private float HighestTemperatureComing([NotNull] Map map) { var twelfth = GenLocalDate.Twelfth(map); var a = GetTemperature(twelfth, map); for (var i = 0; i < 3; i++) { twelfth = twelfth.NextTwelfth(); a = Mathf.Max(a, GetTemperature(twelfth, map)); } return(Mathf.Max(a, map.mapTemperature.OutdoorTemp)); }
private static float AlertNeedWarmClothes_LowestTemperatureComing(Map map) { Twelfth twelfth = GenLocalDate.Twelfth(map); float a = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth); for (int i = 0; i < 3; i++) { twelfth = twelfth.NextTwelfth(); a = Mathf.Min(a, GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth)); } return(Mathf.Min(a, map.mapTemperature.OutdoorTemp)); }
private float LowestTemperatureComing([NotNull] Map map) { Twelfth twelfth = GenLocalDate.Twelfth(map); float a = this.GetTemperature(twelfth, map); for (int i = 0; i < 3; i++) { twelfth = twelfth.NextTwelfth(); a = Mathf.Min(a, this.GetTemperature(twelfth, map)); } return(Mathf.Min(a, map.mapTemperature.OutdoorTemp)); }
protected override Job TryGiveJob(Pawn pawn) { //if (pawn.outfits == null) //{ // Log.ErrorOnce(pawn + " tried to run JobGiver_TakeFromLocker without an OutfitTracker", 5643897); // return null; //} if (!pawn.IsPrisoner) { Log.ErrorOnce("Non-prisoner " + pawn + " tried to take from locker.", 764323); return(null); } if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick) { return(null); } //Outfit currentOutfit = pawn.outfits.CurrentOutfit; List <Apparel> wornApparel = pawn.apparel.WornApparel; Thing thing = null; float num = 0f; List <Thing> list = FindItemToWear(pawn); if (list.Count == 0) { SetNextOptimizeTick(pawn); return(null); } var neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); for (int j = 0; j < list.Count; j++) { Apparel apparel = (Apparel)list[j]; if (apparel.Map.slotGroupManager.SlotGroupAt(apparel.Position) != null) { float num2 = JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel); if (num2 >= 0.05f && num2 >= num) { if (ApparelUtility.HasPartsToWear(pawn, apparel.def)) { if (pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger(), 1, -1, null, false)) { thing = apparel; num = num2; } } } } } if (thing == null) { SetNextOptimizeTick(pawn); return(null); } return(new Job(JobDefOf.Wear, thing)); }
public static Thing PickBestArmorFor(Pawn pawn) { if (pawn.outfits == null) { return(null); } if (pawn.Faction != Faction.OfPlayer) { return(null); } if (pawn.IsQuestLodger()) { return(null); } Outfit currentOutfit = pawn.outfits.CurrentOutfit; Thing thing = null; float num2 = 0f; List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel); if (list.Count == 0) { return(null); } neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); wornApparelScores = new List <float>(); List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int i = 0; i < wornApparel.Count; i++) { wornApparelScores.Add(ApparelScoreRaw(pawn, wornApparel[i])); } for (int j = 0; j < list.Count; j++) { Apparel apparel = (Apparel)list[j]; // && apparel.IsInAnyStorage() if (!apparel.IsBurning() && currentOutfit.filter.Allows(apparel) && !apparel.IsForbidden(pawn) && (apparel.def.apparel.gender == Gender.None || apparel.def.apparel.gender == pawn.gender)) { float num3 = ApparelScoreGain_NewTmp(pawn, apparel, wornApparelScores); if (!(num3 < 0.05f) && !(num3 < num2) && (!CompBiocodable.IsBiocoded(apparel) || CompBiocodable.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def) && pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger())) { thing = apparel; num2 = num3; } } } return(thing); }
public static bool TryGiveJob(JobGiver_OptimizeApparel __instance, ref Job __result, Pawn pawn) { if (pawn.outfits == null) { Log.ErrorOnce(string.Concat(pawn, " tried to run JobGiver_OptimizeApparel without an OutfitTracker"), 5643897); __result = null; return(false); } if (pawn.Faction != Faction.OfPlayer) { Log.ErrorOnce(string.Concat("Non-colonist ", pawn, " tried to optimize apparel."), 764323); __result = null; return(false); } if (pawn.IsQuestLodger()) { __result = null; return(false); } if (!DebugViewSettings.debugApparelOptimize) { if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick) { __result = null; return(false); } } else { debugSb = new StringBuilder(); debugSb.AppendLine(string.Concat("Scanning for ", pawn, " at ", pawn.Position)); } Outfit currentOutfit = pawn.outfits.CurrentOutfit; List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int num = wornApparel.Count - 1; num >= 0; num--) { if (!currentOutfit.filter.Allows(wornApparel[num]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[num]) && !pawn.apparel.IsLocked(wornApparel[num])) { Job job = JobMaker.MakeJob(JobDefOf.RemoveApparel, wornApparel[num]); job.haulDroppedApparel = true; __result = job; return(false); } } Thing thing = null; float num2 = 0f; List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel); if (list.Count == 0) { SetNextOptimizeTick2(pawn); __result = null; return(false); } neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); //wornApparelScores.Clear(); List <float> wornApparelScores = new List <float>(); for (int i = 0; i < wornApparel.Count; i++) { wornApparelScores.Add(JobGiver_OptimizeApparel.ApparelScoreRaw(pawn, wornApparel[i])); } for (int j = 0; j < list.Count; j++) { Apparel apparel = (Apparel)list[j]; if (currentOutfit.filter.Allows(apparel) && apparel.IsInAnyStorage() && !apparel.IsForbidden(pawn) && !apparel.IsBurning() && (apparel.def.apparel.gender == Gender.None || apparel.def.apparel.gender == pawn.gender)) { float num3 = JobGiver_OptimizeApparel.ApparelScoreGain_NewTmp(pawn, apparel, wornApparelScores); if (DebugViewSettings.debugApparelOptimize) { debugSb.AppendLine(apparel.LabelCap + ": " + num3.ToString("F2")); } if (!(num3 < 0.05f) && !(num3 < num2) && (!EquipmentUtility.IsBiocoded(apparel) || EquipmentUtility.IsBiocodedFor(apparel, pawn)) && ApparelUtility.HasPartsToWear(pawn, apparel.def) && pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger())) { thing = apparel; num2 = num3; } } } if (DebugViewSettings.debugApparelOptimize) { debugSb.AppendLine("BEST: " + thing); Log.Message(debugSb.ToString()); debugSb = null; } if (thing == null) { SetNextOptimizeTick2(pawn); __result = null; return(false); } __result = JobMaker.MakeJob(JobDefOf.Wear, thing); return(false); }
public static void ApparelScoreRaw_Postfix(Pawn pawn, Apparel ap, ref float __result) { //NeededWarmth neededCold = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); float num = GenTemperature.AverageTemperatureAtTileForTwelfth(pawn.Map.Tile, GenLocalDate.Twelfth(pawn)); SimpleCurve InsulationHeatScoreFactorCurve_NeedCold = new SimpleCurve { { new CurvePoint(0f, 1f), true }, { new CurvePoint(30f, 8f), true } }; // This version uses ComfyTemperatureMax to find if needCool, not comfyTemperatureMin if (num < pawn.def.GetStatValueAbstract(StatDefOf.ComfyTemperatureMax, null) - 4f) { float statValue = ap.GetStatValue(StatDefOf.Insulation_Heat, true); float coldFactor = 1f; coldFactor *= InsulationHeatScoreFactorCurve_NeedCold.Evaluate(statValue); __result *= coldFactor; } //if (neededCold == NeededWarmth.Cool) //{ // float statValue = ap.GetStatValue(StatDefOf.Insulation_Heat, true); // float coldFactor = 1f; // coldFactor *= InsulationHeatScoreFactorCurve_NeedCold.Evaluate(statValue); // __result *= coldFactor; //} }