protected virtual float SpringChance(Pawn p) { float num; if (this.KnowsOfTrap(p)) { num = 0.004f; if (!BetaTrapsSettings.getFriendlyFireSettingValue()) { num = 0f; } } else { num = this.GetStatValue(StatDefOf.TrapSpringChance, true); } if (!BetaTrapsSettings.getUseBodySizeValue()) { num *= GenMath.LerpDouble(0.4f, 0.8f, 0f, 1f, 1f); } else { num *= GenMath.LerpDouble(0.4f, 0.8f, 0f, 1f, p.BodySize); } if (BetaTrapsSettings.getAnimalSpringSettingValue()) { if (p.RaceProps.Animal) { num *= 0.1f; } } return(Mathf.Clamp01(num)); }
private void DrawDustDevilPart(float distanceFromCenter, float initialAngle, float speedMultiplier, float colorMultiplier) { int ticksGame = Find.TickManager.TicksGame; float num = 1f / distanceFromCenter; float num2 = 25f * speedMultiplier * num; float num3 = (initialAngle + (float)ticksGame * num2) % 360f; Vector2 vector = this.realPosition.Moved(num3, this.AdjustedDistanceFromCenter(distanceFromCenter)); vector.y += distanceFromCenter * 4f; vector.y += DustDevil.ZOffsetBias; Vector3 vector2 = new Vector3(vector.x, Altitudes.AltitudeFor(AltitudeLayer.Weather) + 0.046875f * Rand.Range(0f, 1f), vector.y); float num4 = distanceFromCenter * 3f; float num5 = 1f; if (num3 > 270f) { num5 = GenMath.LerpDouble(270f, 360f, 0f, 1f, num3); } else if (num3 > 180f) { num5 = GenMath.LerpDouble(180f, 270f, 1f, 0f, num3); } float num6 = Mathf.Min(distanceFromCenter / (DustDevil.PartsDistanceFromCenter.max + 2f), 1f); float d = Mathf.InverseLerp(0.18f, 0.4f, num6); Vector3 a = new Vector3(Mathf.Sin((float)ticksGame / 1000f + (float)(this.thingIDNumber * 10)) * 2f, 0f, 0f); vector2 += a * d; float a2 = Mathf.Max(1f - num6, 0f) * num5 * this.FadeInOutFactor; Color value = new Color(colorMultiplier, colorMultiplier, colorMultiplier, a2); DustDevil.matPropertyBlock.SetColor(ShaderPropertyIDs.Color, value); Matrix4x4 matrix = Matrix4x4.TRS(vector2, Quaternion.Euler(0f, num3, 0f), new Vector3(num4, 1f, num4)); Graphics.DrawMesh(MeshPool.plane10, matrix, DustDevil.DustDevilMaterial, 0, null, 0, DustDevil.matPropertyBlock); }
public override IEnumerable Regenerate() { foreach (object result in base.Regenerate()) { yield return(result); } Rand.PushState(); Rand.Seed = Find.World.info.Seed; for (int i = 0; i < 1500; i++) { Vector3 unitVector = Rand.UnitVector3; Vector3 pos = unitVector * 10f; LayerSubMesh subMesh = base.GetSubMesh(WorldMaterials.Stars); float num = WorldLayer_Stars.StarsDrawSize.RandomInRange; Vector3 rhs = (!this.UseStaticRotation) ? Vector3.forward : GenCelestial.CurSunPositionInWorldSpace().normalized; float num2 = Vector3.Dot(unitVector, rhs); if (num2 > 0.8f) { num *= GenMath.LerpDouble(0.8f, 1f, 1f, 0.35f, num2); } WorldRendererUtility.PrintQuadTangentialToPlanet(pos, num, 0f, subMesh, true, true, true); } this.calculatedForStartingTile = ((Find.GameInitData == null) ? -1 : Find.GameInitData.startingTile); this.calculatedForStaticRotation = this.UseStaticRotation; Rand.PopState(); base.FinalizeMesh(MeshParts.All); }
public override double GetValue(double x, double y, double z) { float num = Vector3.Angle(this.viewCenter, new Vector3((float)x, (float)y, (float)z)); double value = this.modules[0].GetValue(x, y, z); float num2 = Mathf.Max(2.5f, this.viewAngle * 0.25f); float num3 = Mathf.Max(0.8f, this.viewAngle * 0.1f); double result; if (num < this.viewAngle - num2) { result = value; } else { float num4 = GenMath.LerpDouble(this.viewAngle - num2, this.viewAngle - num3, 0f, 0.62f, num); if (value > -0.11999999731779099) { result = (value - -0.11999999731779099) * (double)(1f - num4 * 0.7f) - (double)(num4 * 0.3f) + -0.11999999731779099; } else { result = value - (double)(num4 * 0.3f); } } return(result); }
public static void ExpandableWorldObjectsOnGUI() { if (TransitionPct != 0f) { tmpWorldObjects.Clear(); tmpWorldObjects.AddRange(Find.WorldObjects.AllWorldObjects); SortByExpandingIconPriority(tmpWorldObjects); WorldTargeter worldTargeter = Find.WorldTargeter; List <WorldObject> worldObjectsUnderMouse = null; if (worldTargeter.IsTargeting) { worldObjectsUnderMouse = GenWorldUI.WorldObjectsUnderMouse(UI.MousePositionOnUI); } for (int i = 0; i < tmpWorldObjects.Count; i++) { WorldObject worldObject = tmpWorldObjects[i]; if (worldObject.def.expandingIcon && !worldObject.HiddenBehindTerrainNow()) { Color expandingIconColor = worldObject.ExpandingIconColor; expandingIconColor.a = TransitionPct; if (worldTargeter.IsTargetedNow(worldObject, worldObjectsUnderMouse)) { float num = GenMath.LerpDouble(-1f, 1f, 0.7f, 1f, Mathf.Sin(Time.time * 8f)); expandingIconColor.r *= num; expandingIconColor.g *= num; expandingIconColor.b *= num; } GUI.color = expandingIconColor; GUI.DrawTexture(ExpandedIconScreenRect(worldObject), worldObject.ExpandingIcon); } } tmpWorldObjects.Clear(); GUI.color = Color.white; } }
public override float GetScore(Room room) { float stat = room.GetStat(RoomStatDefOf.Cleanliness); float value = (!(stat >= 0.0)) ? GenMath.LerpDouble(-5f, 0f, 1f, 0.5f, stat) : GenMath.LerpDouble(0f, 1f, 0.5f, 0.2f, stat); return(Mathf.Clamp(value, 0.2f, 1f)); }
public void CalculateNextHiveSpawnTick() { var room = parent.GetRoom(); var num = 0; var num2 = GenRadial.NumCellsInRadius(9f); for (var i = 0; i < num2; i++) { var intVec = parent.Position + GenRadial.RadialPattern[i]; if (!intVec.InBounds(parent.Map)) { continue; } if (intVec.GetRoom(parent.Map) != room) { continue; } if (intVec.GetThingList(parent.Map).Any(t => t is Hive)) { num++; } } var num3 = GenMath.LerpDouble(0f, 7f, 1f, 0.35f, Mathf.Clamp(num, 0, 7)); nextHiveSpawnTick = Find.TickManager.TicksGame + (int)(Props.HiveSpawnIntervalDays.RandomInRange * 60000f / (num3 * Find.Storyteller.difficulty .enemyReproductionRateFactor)); }
public override void MapComponentTick() { var watch = new Stopwatch(); watch.Start(); if (updateCounter-- < 0) { updateCounter = Constants.TICKMANAGER_RECALCULATE_DELAY.SecondsToTicks(); RecalculateVisibleMap(); } if (populationSpawnCounter-- < 0) { populationSpawnCounter = (int)GenMath.LerpDouble(0, 1000, 300, 20, Math.Max(100, Math.Min(1000, currentColonyPoints))); IncreaseZombiePopulation(); } if (dequeedSpawnCounter-- < 0) { dequeedSpawnCounter = Rand.Range(10, 51); DequeuAndSpawnZombies(); } ZombieTicking(watch); watch.Stop(); }
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); }
public override IEnumerable Regenerate() { foreach (object item in base.Regenerate()) { yield return(item); } Rand.PushState(); Rand.Seed = Find.World.info.Seed; for (int i = 0; i < 1500; i++) { Vector3 unitVector = Rand.UnitVector3; Vector3 pos = unitVector * 10f; LayerSubMesh subMesh = GetSubMesh(WorldMaterials.Stars); float num = StarsDrawSize.RandomInRange; Vector3 rhs = (UseStaticRotation ? GenCelestial.CurSunPositionInWorldSpace().normalized : Vector3.forward); float num2 = Vector3.Dot(unitVector, rhs); if (num2 > 0.8f) { num *= GenMath.LerpDouble(0.8f, 1f, 1f, 0.35f, num2); } WorldRendererUtility.PrintQuadTangentialToPlanet(pos, num, 0f, subMesh, counterClockwise: true, randomizeRotation: true); } calculatedForStartingTile = ((Find.GameInitData != null) ? Find.GameInitData.startingTile : (-1)); calculatedForStaticRotation = UseStaticRotation; Rand.PopState(); FinalizeMesh(MeshParts.All); }
private float FeeDemandChance(Faction faction) { FactionRelation factionRelation = faction.RelationWith(Faction.OfPlayer, false); float x = Mathf.Max(factionRelation.goodwill, 0f); return(GenMath.LerpDouble(0f, 100f, 0.5f, 0f, x)); }
private static float GetGenerationChanceAgeGapFactor(Pawn p1, Pawn p2, bool ex) { float num = Mathf.Abs(p1.ageTracker.AgeBiologicalYearsFloat - p2.ageTracker.AgeBiologicalYearsFloat); if (ex) { float num2 = LovePartnerRelationUtility.MinPossibleAgeGapAtMinAgeToGenerateAsLovers(p1, p2); if (num2 >= 0.0) { num = Mathf.Min(num, num2); } float num3 = LovePartnerRelationUtility.MinPossibleAgeGapAtMinAgeToGenerateAsLovers(p2, p1); if (num3 >= 0.0) { num = Mathf.Min(num, num3); } } if (num > 40.0) { return(0f); } float value = GenMath.LerpDouble(0f, 20f, 1f, 0.001f, num); return(Mathf.Clamp(value, 0.001f, 1f)); }
public static Mote ThrowCasingTurret(Thing caster, Map map, int weaponDamage, ThingDef moteDef) { if (!caster.Position.ShouldSpawnMotesAt(map) || map.moteCounter.Saturated) { return(null); } Building_TurretGun turret = caster as Building_TurretGun; TurretTop turrettop = Traverse.Create(turret).Field("top").GetValue <TurretTop>(); float angle = Traverse.Create(turrettop).Field("curRotationInt").GetValue <float>(); MoteThrownCasing moteThrown = (MoteThrownCasing)ThingMaker.MakeThing(moteDef, null); if (BulletCasingMoteSettings.uncapCasingSize) { moteThrown.Scale = GenMath.LerpDouble(5f, 50f, 0.2f, 0.5f, weaponDamage); } else { moteThrown.Scale = GenMath.LerpDoubleClamped(5f, 75f, 0.2f, 0.5f, weaponDamage); } moteThrown.exactPosition = caster.TrueCenter(); moteThrown.rotationRate = Rand.Range(-360f, 360f); moteThrown.speed = Rand.Range(BulletCasingMoteSettings.velocityFactor.min, BulletCasingMoteSettings.velocityFactor.max); moteThrown.rotation = angle; moteThrown.velocityRandom = new Vector3(Rand.Range(-4f, 4f), 0f, Rand.Range(-4f, 4f)); GenSpawn.Spawn(moteThrown, caster.Position, map, WipeMode.Vanish); return(moteThrown); }
public float AcceptanceChance(Pawn initiator, Pawn recipient) { float num = 0.9f; num *= Mathf.Clamp01(GenMath.LerpDouble(-20f, 60f, 0f, 1f, (float)recipient.relations.OpinionOf(initiator))); return(Mathf.Clamp01(num)); }
public override float GetScore(Room room) { float stat = room.GetStat(RoomStatDefOf.Cleanliness); float value = GenMath.LerpDouble(-5f, 5f, 0.6f, 1.5f, stat); return(Mathf.Clamp(value, 0.6f, 1.5f)); }
public static Mote ThrowCasing(Pawn caster, Map map, int weaponDamage, ThingDef moteDef) { if (!caster.Position.ShouldSpawnMotesAt(map) || map.moteCounter.Saturated) { return(null); } float angle = (caster.TargetCurrentlyAimingAt.CenterVector3 - caster.DrawPos).AngleFlat(); MoteThrownCasing moteThrown = (MoteThrownCasing)ThingMaker.MakeThing(moteDef, null); if (BulletCasingMoteSettings.uncapCasingSize) { moteThrown.Scale = GenMath.LerpDouble(5f, 30f, 0.2f, 0.4f, weaponDamage); } else { moteThrown.Scale = GenMath.LerpDoubleClamped(5f, 30f, 0.2f, 0.4f, weaponDamage); } moteThrown.exactPosition = caster.Position.ToVector3Shifted(); moteThrown.exactPosition += Quaternion.AngleAxis(angle, Vector3.up) * new Vector3(0f, 0f, 0.3f); //puts the casing slightly infront of the pawn moteThrown.rotationRate = Rand.Range(-360f, 360f); moteThrown.speed = Rand.Range(BulletCasingMoteSettings.velocityFactor.min, BulletCasingMoteSettings.velocityFactor.max); moteThrown.rotation = angle; moteThrown.velocityRandom = new Vector3(Rand.Range(-3f, 3f), 0f, Rand.Range(-3f, 3f)); GenSpawn.Spawn(moteThrown, caster.Position, map, WipeMode.Vanish); return(moteThrown); }
private static bool Prefix(Pawn_RelationsTracker __instance, Pawn ___pawn, Pawn otherPawn, ref float __result) { if (!___pawn.RaceProps.Humanlike || !otherPawn.RaceProps.Humanlike || ___pawn == otherPawn) { __result = 0f; return(false); } float num1 = Mathf.Abs(___pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat); float num2 = GenMath.LerpDouble(0f, 20f, 0.45f, -0.45f, num1); num2 = Mathf.Clamp(num2, -0.45f, 0.45f); float num3 = __instance.ConstantPerPawnsPairCompatibilityOffset(otherPawn.thingIDNumber); float num4 = 0f; if (___pawn.def is RaceAddonThingDef thingDef1) { if (thingDef1.raceAddonSettings.relationSetting.specialRaces.Find(x => x.raceDef == otherPawn.def) is var set && set != null) { num4 = set.compatibilityBonus; } else if (___pawn.def == otherPawn.def || thingDef1.raceAddonSettings.relationSetting.sameRaces.Contains(otherPawn.def)) { num4 = thingDef1.raceAddonSettings.relationSetting.sameRace.compatibilityBonus; } else { num4 = thingDef1.raceAddonSettings.relationSetting.otherRace.compatibilityBonus; } }
private void CalculateNextPawnSpawnTick() { float num = GenMath.LerpDouble(0f, 5f, 1f, 0.5f, (float)this.spawnedPawns.Count); this.nextPawnSpawnTick = Find.TickManager.TicksGame + (int)(Building_WombBetweenWorlds.PawnSpawnIntervalDays.RandomInRange * 60000f / (num * Find.Storyteller.difficulty.enemyReproductionRateFactor)); //this.nextPawnSpawnTick = Find.TickManager.TicksGame + (int)(Building_WombBetweenWorlds.PawnSpawnIntervalDays.RandomInRange * 60000f); }
public static void DebugDraw() { if (DebugViewSettings.drawInfestationChance) { if (InfestationCellFinder.tmpCachedInfestationChanceCellColors == null) { InfestationCellFinder.tmpCachedInfestationChanceCellColors = new List <Pair <IntVec3, float> >(); } if (Time.frameCount % 8 == 0) { InfestationCellFinder.tmpCachedInfestationChanceCellColors.Clear(); Map currentMap = Find.CurrentMap; CellRect cellRect = Find.CameraDriver.CurrentViewRect; cellRect.ClipInsideMap(currentMap); cellRect = cellRect.ExpandedBy(1); InfestationCellFinder.CalculateTraversalDistancesToUnroofed(currentMap); InfestationCellFinder.CalculateClosedAreaSizeGrid(currentMap); InfestationCellFinder.CalculateDistanceToColonyBuildingGrid(currentMap); float num = 0.001f; for (int i = 0; i < currentMap.Size.z; i++) { for (int j = 0; j < currentMap.Size.x; j++) { IntVec3 cell = new IntVec3(j, 0, i); float scoreAt = InfestationCellFinder.GetScoreAt(cell, currentMap); if (scoreAt > num) { num = scoreAt; } } } for (int k = 0; k < currentMap.Size.z; k++) { for (int l = 0; l < currentMap.Size.x; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (cellRect.Contains(intVec)) { float scoreAt2 = InfestationCellFinder.GetScoreAt(intVec, currentMap); if (scoreAt2 > 7.5f) { float second = GenMath.LerpDouble(7.5f, num, 0f, 1f, scoreAt2); InfestationCellFinder.tmpCachedInfestationChanceCellColors.Add(new Pair <IntVec3, float>(intVec, second)); } } } } } for (int m = 0; m < InfestationCellFinder.tmpCachedInfestationChanceCellColors.Count; m++) { IntVec3 first = InfestationCellFinder.tmpCachedInfestationChanceCellColors[m].First; float second2 = InfestationCellFinder.tmpCachedInfestationChanceCellColors[m].Second; CellRenderer.RenderCell(first, SolidColorMaterials.SimpleSolidColorMaterial(new Color(0f, 0f, 1f, second2), false)); } } else { InfestationCellFinder.tmpCachedInfestationChanceCellColors = null; } }
private void CalculateNextPawnSpawnTick() { var num = GenMath.LerpDouble(0f, 5f, 1f, 0.5f, spawnedPawns.Count); nextPawnSpawnTick = Find.TickManager.TicksGame + (int)(PawnSpawnIntervalDays.RandomInRange * 60000f / (num * Find.Storyteller.difficulty .enemyReproductionRateFactor)); }
private static float VisitChanceScore(Pawn pawn, Pawn sick) { float num = GenMath.LerpDouble(-100f, 100f, 0.05f, 2f, (float)pawn.relations.OpinionOf(sick)); float lengthHorizontal = (pawn.Position - sick.Position).LengthHorizontal; float num2 = Mathf.Clamp(GenMath.LerpDouble(0f, 150f, 1f, 0.2f, lengthHorizontal), 0.2f, 1f); return(num * num2); }
// Self healing //private int timerRepairDamage = 0; private void TryHealDamagedBodyPartOfRobot(X2_AIRobot robot) { //timerRepairDamage--; //if (timerRepairDamage > 0) // return; //timerRepairDamage = 300; if (robot == null || !Verse.Gen.IsHashIntervalTick(robot, 300)) { return; } IEnumerable <Hediff_Injury> hediff_injuries = (from x in robot.health.hediffSet.GetHediffs <Hediff_Injury>() where x.CanHealFromTending() || x.CanHealNaturally() select x); // Apply Treated, but not healing! if (robot.health.HasHediffsNeedingTend(false)) { float quality = (Rand.Value); int batchPosition = 0; foreach (Hediff_Injury injury in from x in robot.health.hediffSet.GetInjuriesTendable() orderby x.Severity descending select x) { injury.Tended(quality, batchPosition); batchPosition++; if (batchPosition >= 1) { break; } } } // Apply healing if (hediff_injuries != null && hediff_injuries.Count() > 0) { Hediff_Injury hediff_Injury2 = hediff_injuries.RandomElement(); float tendQuality = hediff_Injury2.TryGetComp <HediffComp_TendDuration>().tendQuality; float num2 = GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)); ////hediff_Injury2.Heal(22f * num2 * robot.HealthScale * 0.01f); -> At quality 0.5 --> 0.066 healed. //Log.Error("Calculation: " + (GenMath.LerpDouble(0f, 1f, 0.5f, 1.5f, Mathf.Clamp01(tendQuality)).ToString())); //Log.Error("Healing: " + (22f * num2 * robot.HealthScale * 0.1f).ToString()); //Log.Error("PRE:" + hediff_Injury2.Severity.ToString()); //hediff_Injury2.Heal(1f); hediff_Injury2.Heal(22f * num2 * robot.HealthScale * 0.1f * 0.5f); //Log.Error("POST:" + hediff_Injury2.Severity.ToString()); // Throw Healing Mote MoteMaker.ThrowMetaIcon(this.Position, this.Map, ThingDefOf.Mote_HealingCross); } }
// RimWorld.LovePartnerRelationUtility public static bool Vamp_LovinFoodFix(Pawn pawn, Pawn partner, ref float __result) { if (pawn.IsVampire() || partner.IsVampire()) { if (pawn.Dead || partner.Dead) { __result = -1f; return(false); } if (DebugSettings.alwaysDoLovin) { __result = 0.1f; return(false); } if (pawn?.needs?.food is Need_Food food && food.Starving || partner?.needs?.food is Need_Food foodPartner && foodPartner.Starving) { __result = -1f; return(false); } if (pawn?.health?.hediffSet?.BleedRateTotal > 0f || partner?.health?.hediffSet?.BleedRateTotal > 0f) { __result = -1f; return(false); } float num = LovinMtbSinglePawnFactor(pawn); if (num <= 0f) { __result = -1f; return(false); } float num2 = LovinMtbSinglePawnFactor(partner); if (num2 <= 0f) { __result = -1f; return(false); } float num3 = 12f; num3 *= num; num3 *= num2; num3 /= Mathf.Max(pawn.relations.SecondaryRomanceChanceFactor(partner), 0.1f); num3 /= Mathf.Max(partner.relations.SecondaryRomanceChanceFactor(pawn), 0.1f); num3 *= GenMath.LerpDouble(-100f, 100f, 1.3f, 0.7f, (float)pawn.relations.OpinionOf(partner)); __result = num3 * GenMath.LerpDouble(-100f, 100f, 1.3f, 0.7f, (float)partner.relations.OpinionOf(pawn)); return(false); } return(true); }
internal static float _CompatibilityWith(this Pawn_RelationsTracker _this, Pawn otherPawn) { var pawn = _this.GetPawn(); if (!PawnsAreValidMatches(pawn, otherPawn)) { return(0f); } return(Mathf.Clamp(GenMath.LerpDouble(0.0f, 20f, 0.45f, -0.45f, Mathf.Abs(pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat)), -0.45f, 0.45f) + _this.ConstantPerPawnsPairCompatibilityOffset(otherPawn.thingIDNumber)); }
public float InfectionProgress() { if (GetInfectionState() != InfectionState.Infecting) { return(0f); } var progress = GenMath.LerpDouble(ZombieInfector.infectionStartTime, ZombieInfector.infectionEndTime, 0f, 1f, GenTicks.TicksAbs); return(Mathf.Clamp01(progress)); }
// inspiration function, see below public virtual float MTBDays(InspirationHandler ih) { float curLevel = ih.pawn.needs.mood.CurLevel; if (curLevel < inspirationMoodThreshold) { return(-1f); } return(GenMath.LerpDouble(inspirationMoodThreshold, 1f, 210f, 10f, curLevel) / inspirationChanceMultiplier); }
public static List <Pawn> GetTrainers(this PawnKindDef pawnkind, Map map, MasterMode mode) { return(pawnkind.GetMasterOptions(map, mode).Where(p => // skill high enough to handle (copied from StatWorker_MinimumHandlingSkill) // NOTE: This does NOT apply postprocessing, so scenario and other offsets DO NOT apply. // we can't actually use StatRequests because they're hardcoded for either Things or BuildableDefs. p.skills.GetSkill(SkillDefOf.Animals).Level >= Mathf.Clamp(GenMath.LerpDouble(0.3f, 1f, 0f, 9f, pawnkind.RaceProps.wildness), 0f, 20f)) .ToList()); }
protected virtual float SpringChance(Pawn p) { float num = (float)((!this.KnowsOfTrap(p)) ? this.GetStatValue(StatDefOf.TrapSpringChance, true) : 0.0040000001899898052); num *= GenMath.LerpDouble(0.4f, 0.8f, 0f, 1f, p.BodySize); if (p.RaceProps.Animal) { num = (float)(num * 0.10000000149011612); } return(Mathf.Clamp01(num)); }
public float SocialFightChance(InteractionDef interaction, Pawn initiator) { if (!pawn.RaceProps.Humanlike || !initiator.RaceProps.Humanlike) { return(0f); } if (!InteractionUtility.HasAnyVerbForSocialFight(pawn) || !InteractionUtility.HasAnyVerbForSocialFight(initiator)) { return(0f); } if (pawn.WorkTagIsDisabled(WorkTags.Violent)) { return(0f); } if (initiator.Downed || pawn.Downed) { return(0f); } float socialFightBaseChance = interaction.socialFightBaseChance; socialFightBaseChance *= Mathf.InverseLerp(0.3f, 1f, pawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation)); socialFightBaseChance *= Mathf.InverseLerp(0.3f, 1f, pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving)); List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { if (hediffs[i].CurStage != null) { socialFightBaseChance *= hediffs[i].CurStage.socialFightChanceFactor; } } float num = pawn.relations.OpinionOf(initiator); socialFightBaseChance = ((!(num < 0f)) ? (socialFightBaseChance * GenMath.LerpDouble(0f, 100f, 1f, 0.6f, num)) : (socialFightBaseChance * GenMath.LerpDouble(-100f, 0f, 4f, 1f, num))); if (pawn.RaceProps.Humanlike) { List <Trait> allTraits = pawn.story.traits.allTraits; for (int j = 0; j < allTraits.Count; j++) { socialFightBaseChance *= allTraits[j].CurrentData.socialFightChanceFactor; } } int num2 = Mathf.Abs(pawn.ageTracker.AgeBiologicalYears - initiator.ageTracker.AgeBiologicalYears); if (num2 > 10) { if (num2 > 50) { num2 = 50; } socialFightBaseChance *= GenMath.LerpDouble(10f, 50f, 1f, 0.25f, num2); } return(Mathf.Clamp01(socialFightBaseChance)); }
public float CompatibilityWith(Pawn otherPawn) { if (this.pawn.def == otherPawn.def && this.pawn != otherPawn) { float x = Mathf.Abs(this.pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat); float value = GenMath.LerpDouble(0f, 20f, 0.45f, -0.45f, x); value = Mathf.Clamp(value, -0.45f, 0.45f); float num = this.ConstantPerPawnsPairCompatibilityOffset(otherPawn.thingIDNumber); return(value + num); } return(0f); }