protected override bool CheckMatch(ThingDef ingestible) { return(ingestible.ingestible.JoyKind == JoyKindDefOf.Gluttonous && (nutrimentRange?.Includes(ingestible.ingestible.CachedNutrition) ?? true) && ((shouldMatchBothPreferabilityAndJoy || preferabilityRange == null || joyRange == null) ? preferabilityRange?.Includes((float)ingestible.ingestible.preferability) ?? true && base.CheckMatch(ingestible) : preferabilityRange?.Includes((float)ingestible.ingestible.preferability) ?? true || base.CheckMatch(ingestible))); }
private static Region ClosestRegionWithinTemperatureRange(IntVec3 root, Map map, FloatRange tempRange, TraverseParms traverseParms, RegionType traversableRegionTypes = RegionType.Set_Passable) { Region region = root.GetRegion(map, traversableRegionTypes); if (region == null) { return(null); } RegionEntryPredicate entryCondition = (Region from, Region r) => r.Allows(traverseParms, false); Region foundReg = null; RegionProcessor regionProcessor = delegate(Region r) { if (r.IsDoorway) { return(false); } if (tempRange.Includes(r.Room.Temperature)) { foundReg = r; return(true); } return(false); }; RegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, 9999, traversableRegionTypes); return(foundReg); }
protected override Job TryGiveJob(Pawn pawn) { Job result; if (!pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious)) { result = null; } else { FloatRange tempRange = pawn.ComfortableTemperatureRange(); if (tempRange.Includes(pawn.AmbientTemperature)) { result = new Job(JobDefOf.Wait_SafeTemperature, 500, true); } else { Region region = JobGiver_SeekSafeTemperature.ClosestRegionWithinTemperatureRange(pawn.Position, pawn.Map, tempRange, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), RegionType.Set_Passable); if (region != null) { result = new Job(JobDefOf.GotoSafeTemperature, region.RandomCell); } else { result = null; } } } return(result); }
// Token: 0x06000072 RID: 114 RVA: 0x000044A4 File Offset: 0x000026A4 internal bool RPGVentCheckTemps(Building b, FloatRange tempRange) { for (var i = 0; i < 2; i++) { var intVec = i != 0 ? b.Position - b.Rotation.FacingCell : b.Position + b.Rotation.FacingCell; if (!intVec.InBounds(b.Map)) { continue; } var roomGroup = intVec.GetRoomOrAdjacent(b.Map); if (roomGroup == null) { continue; } var tempChk = roomGroup.Temperature; if (!tempRange.Includes(tempChk)) { return(false); } } return(true); }
protected override void SpringSub(Pawn p) { if (rearmableComp.armed) { SoundDefOf.TrapSpring.PlayOneShot(new TargetInfo(Position, Map)); rearmableComp.armed = false; Map.mapDrawer.SectionAt(Position).RegenerateAllLayers(); if (!def.building.trapDestroyOnSpring && (bool)NonPublicFields.Building_Trap_autoRearm.GetValue(this)) { Map.designationManager.AddDesignation(new Designation(this, DesignationDefOf.VFES_RearmTrap)); } if (p == null || !AffectableBodySizeRange.Includes(p.BodySize)) { return; } float damage = this.GetStatValue(RimWorld.StatDefOf.TrapMeleeDamage, true) * DamageRandomFactorRange.RandomInRange; float armourPen = damage * VerbProperties.DefaultArmorPenetrationPerDamage; var partHeight = p.BodySize >= LowerHeightBodySizeThreshold ? BodyPartHeight.Bottom : BodyPartHeight.Undefined; BodyPartRecord hitPart = p.health.hediffSet.GetRandomNotMissingPart(DamageDefOf.Stab, partHeight); var dinfo = new DamageInfo(DamageDefOf.Stab, damage, armourPen, instigator: this, hitPart: hitPart); var damResult = p.TakeDamage(dinfo); var logEntry = new BattleLogEntry_DamageTaken(p, RulePackDefOf.DamageEvent_TrapSpike); Find.BattleLog.Add(logEntry); damResult.AssociateWithLog(logEntry); } }
protected override float GetWeightForDef(ThingDef def) { if (!baseMoney.Includes(def.BaseMarketValue)) { return(0); } return(1); }
protected override bool FastSearchMatch(ThingDef thing) { return(base.FastSearchMatch(thing) && thing.race != null && thing.race.Animal && (!shouldBePredator || thing.race.predator) && (!shouldBePack || thing.race.packAnimal) && (!shouldBeNuzzler || thing.race.nuzzleMtbHours > 0) && (leathers == null || leathers.Contains(thing.race.leatherDef)) && (petnessRange?.Includes(thing.race.petness) ?? true) && (wildnessRange?.Includes(thing.race.wildness) ?? true) && (baseBodySizeRange?.Includes(thing.race.baseBodySize) ?? true) && (trainabilityRange?.Includes(thing.race.trainability.index) ?? true) && (lifeExpectancyRange?.Includes(thing.race.lifeExpectancy) ?? true) && (baseMarketValueRange?.Includes(thing.BaseMarketValue) ?? true)); }
private Placement DeterminePlacementFor(Pawn rep, EventDef eventDef, out double mean, out double variance, out double stdDev, out double max, out double min) { var difficultyModifier = 1.05f + (0.01f * Find.World.GetComponent <WorldComponent_MFI_AnnualExpo>().timesHeld); difficultyModifier = Mathf.Clamp(difficultyModifier, 1.05f, 1.1f); var leaders = Find.FactionManager.AllFactionsVisible .Select(faction => faction.leader) .Where(leader => leader != null && !eventDef.relevantStat.Worker.IsDisabledFor(leader)) .Concat(new[] { rep }) .Concat(Find.WorldPawns.AllPawnsAlive .Where(x => x.Faction == host && !eventDef.relevantStat.Worker.IsDisabledFor(x)).Take(25)) .Select(pawn => new { pawn, score = pawn.Faction.leader == pawn ? pawn.GetStatValue(eventDef.relevantStat) * difficultyModifier : pawn.GetStatValue(eventDef.relevantStat) }) .OrderBy(x => x.score) .ToArray(); var repSkill = rep.GetStatValue(eventDef.relevantStat); max = leaders.Max(x => x.score); min = leaders.Min(x => x.score); mean = leaders.Average(x => x.score); variance = (((max - min + 1) * (max - min + 1)) - 1.0) / 12; stdDev = Math.Sqrt(variance); var averageSkillRange = new FloatRange((float)(mean - (stdDev * 0.3)), (float)(mean + (stdDev * 0.3))); if (leaders[0].pawn == rep) { return(Placement.First); } if (averageSkillRange.Includes(repSkill)) { return(Placement.Second); } return(repSkill > mean ? Placement.First : Placement.Third); }
public static bool Prefix(Pawn pawn, ref Job __result) { if (!pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious)) { return(false); } FloatRange tempRange = pawn.ComfortableTemperatureRange(); if (!tempRange.Includes(pawn.AmbientTemperature)) { var job = SeekSafeTemperature(JobDefOf.GotoSafeTemperature, pawn, tempRange); if (job != null) { __result = job; return(false); } } return(true); }
protected override Job TryGiveJob(Pawn pawn) { if (!pawn.health.hediffSet.HasTemperatureInjury(TemperatureInjuryStage.Serious)) { return(null); } FloatRange tempRange = pawn.ComfortableTemperatureRange(); if (tempRange.Includes(pawn.AmbientTemperature)) { return(new Job(JobDefOf.Wait_SafeTemperature, 500, checkOverrideOnExpiry: true)); } Region region = ClosestRegionWithinTemperatureRange(pawn.Position, pawn.Map, tempRange, TraverseParms.For(pawn)); if (region != null) { return(new Job(JobDefOf.GotoSafeTemperature, region.RandomCell)); } return(null); }
public static Region BrrrClosestRegionWithinTemperatureRange(IntVec3 root, Map map, FloatRange tempRange, TraverseParms traverseParms, RegionType traversableRegionTypes = RegionType.Set_Passable) { var region = root.GetRegion(map, traversableRegionTypes); if (region == null) { return(null); } bool entryCondition(Region from, Region r) { return(r.Allows(traverseParms, false)); } Region foundReg = null; bool regionProcessor(Region r) { if (r.IsDoorway) { return(false); } if (!tempRange.Includes(r.Room.Temperature)) { return(false); } if (!Settings.AllowUnsafeAreas && !r.Cells.Any(vec3 => vec3.InAllowedArea(traverseParms.pawn))) { return(false); } foundReg = r; return(true); } RegionTraverser.BreadthFirstTraverse(region, entryCondition, regionProcessor, 9999, traversableRegionTypes); return(foundReg); }
public static Job SeekSafeTemperature(JobDef def, Pawn pawn, FloatRange tempRange) { var map = pawn.Map; if (pawn.Position.UsesOutdoorTemperature(map) && proxyHeatManagers.TryGetValue(map, out ProxyHeatManager proxyHeatManager)) { var candidates = new List <IntVec3>(); foreach (var tempSource in proxyHeatManager.temperatureSources) { var result = proxyHeatManager.GetTemperatureOutcomeFor(tempSource.Key, GenTemperature.GetTemperatureForCell(tempSource.Key, map)); if (tempRange.Includes(result)) { candidates.Add(tempSource.Key); } } candidates = candidates.OrderBy(x => pawn.Position.DistanceTo(x)).ToList(); foreach (var cell in candidates) { if (cell.GetFirstPawn(map) is null && pawn.Map.pawnDestinationReservationManager.FirstReserverOf(cell, pawn.Faction) is null && pawn.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.Deadly)) { var job = JobMaker.MakeJob(def, cell); pawn.Reserve(cell, job); return(job); } } foreach (var cell in candidates) { if (pawn.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.Deadly)) { var job = JobMaker.MakeJob(def, cell); pawn.Reserve(cell, job); return(job); } } } return(null); }
public static IntVec3 GetNearestSafeRoofedCell(Pawn pawn, IntVec3 root, Map map, FloatRange tempRange) { bool baseValidator(IntVec3 chkcell) { if (!chkcell.Standable(map)) { return(false); } if (chkcell.GetDangerFor(pawn, map) != Danger.None) { return(false); } if (!chkcell.Roofed(map)) { return(false); } if (!tempRange.Includes(chkcell.GetRoom(map).Temperature)) { return(false); } if (!Settings.AllowUnsafeAreas && !chkcell.InAllowedArea(pawn)) { return(false); } if (!pawn.CanReserveAndReach(chkcell, PathEndMode.OnCell, Danger.None)) { return(false); } var room = chkcell.GetRoom(map); return(pawn.IsPrisoner == room is { IsPrisonCell : true }); }
protected int RandomCountOf(ThingDef def) { IntRange intRange = countRange; if (customCountRanges != null) { for (int i = 0; i < customCountRanges.Count; i++) { if (customCountRanges[i].thingDef == def) { intRange = customCountRanges[i].countRange; break; } } } if (intRange.max <= 0 && totalPriceRange.max <= 0f) { return(0); } if (intRange.max > 0 && totalPriceRange.max <= 0f) { return(intRange.RandomInRange); } if (intRange.max <= 0 && totalPriceRange.max > 0f) { return(Mathf.RoundToInt(totalPriceRange.RandomInRange / def.BaseMarketValue)); } int num = 0; int randomInRange; do { randomInRange = intRange.RandomInRange; num++; }while (num <= 100 && !totalPriceRange.Includes((float)randomInRange * def.BaseMarketValue)); return(randomInRange); }
public override bool AllowPawn(Pawn pawn, bool tryingToRedress, PawnGenerationRequest req) { return(allowedMelaninRange.Includes(pawn.story.melanin)); }
protected virtual bool CheckMatch(ThingDef ingestible) { return(joyRange?.Includes(ingestible.ingestible.joy) ?? true); }