private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, IntVec3 targetLoc, IntVec3 adjCell, Map map, out CoverInfo result) { Thing cover = adjCell.GetCover(map); float num2; if (cover != null && !(shooterLoc == targetLoc)) { float angleFlat = (shooterLoc - targetLoc).AngleFlat; float angleFlat2 = (adjCell - targetLoc).AngleFlat; float num = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat); if (!targetLoc.AdjacentToCardinal(adjCell)) { num = (float)(num * 1.75); } num2 = cover.def.BaseBlockChance(); if (num < 15.0) { num2 = (float)(num2 * 1.0); goto IL_010b; } if (num < 27.0) { num2 = (float)(num2 * 0.800000011920929); goto IL_010b; } if (num < 40.0) { num2 = (float)(num2 * 0.60000002384185791); goto IL_010b; } if (num < 52.0) { num2 = (float)(num2 * 0.40000000596046448); goto IL_010b; } if (num < 65.0) { num2 = (float)(num2 * 0.20000000298023224); goto IL_010b; } result = CoverInfo.Invalid; return(false); } result = CoverInfo.Invalid; return(false); IL_010b: float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal; if (lengthHorizontal < 1.8999999761581421) { num2 = (float)(num2 * 0.33329999446868896); } else if (lengthHorizontal < 2.9000000953674316) { num2 = (float)(num2 * 0.66666001081466675); } result = new CoverInfo(cover, num2); return(true); }
private static bool TryFindAdjustedCoverInCell(IntVec3 shooterLoc, LocalTargetInfo target, IntVec3 adjCell, Map map, out CoverInfo result) { IntVec3 cell = target.Cell; Thing cover = adjCell.GetCover(map); bool result2; if (cover == null || cover == target.Thing || shooterLoc == cell) { result = CoverInfo.Invalid; result2 = false; } else { float angleFlat = (shooterLoc - cell).AngleFlat; float angleFlat2 = (adjCell - cell).AngleFlat; float num = GenGeo.AngleDifferenceBetween(angleFlat2, angleFlat); if (!cell.AdjacentToCardinal(adjCell)) { num *= 1.75f; } float num2 = cover.def.BaseBlockChance(); if (num < 15f) { num2 *= 1f; } else if (num < 27f) { num2 *= 0.8f; } else if (num < 40f) { num2 *= 0.6f; } else if (num < 52f) { num2 *= 0.4f; } else { if (num >= 65f) { result = CoverInfo.Invalid; return(false); } num2 *= 0.2f; } float lengthHorizontal = (shooterLoc - adjCell).LengthHorizontal; if (lengthHorizontal < 1.9f) { num2 *= 0.3333f; } else if (lengthHorizontal < 2.9f) { num2 *= 0.66666f; } result = new CoverInfo(cover, num2); result2 = true; } return(result2); }
public string GetTextReadout() { StringBuilder stringBuilder = new StringBuilder(); if (this.forcedMissRadius > 0.5f) { stringBuilder.AppendLine(); stringBuilder.AppendLine("WeaponMissRadius".Translate() + " " + this.forcedMissRadius.ToString("F1")); stringBuilder.AppendLine("DirectHitChance".Translate() + " " + (1f / (float)GenRadial.NumCellsInRadius(this.forcedMissRadius)).ToStringPercent()); } else { stringBuilder.AppendLine(" " + this.TotalEstimatedHitChance.ToStringPercent()); stringBuilder.AppendLine(" " + "ShootReportShooterAbility".Translate() + " " + this.factorFromShooterAndDist.ToStringPercent()); stringBuilder.AppendLine(" " + "ShootReportWeapon".Translate() + " " + this.factorFromEquipment.ToStringPercent()); if (this.target.HasThing && this.factorFromTargetSize != 1f) { stringBuilder.AppendLine(" " + "TargetSize".Translate() + " " + this.factorFromTargetSize.ToStringPercent()); } if (this.factorFromWeather < 0.99f) { stringBuilder.AppendLine(" " + "Weather".Translate() + " " + this.factorFromWeather.ToStringPercent()); } if (this.FactorFromCoveringGas < 0.99f) { stringBuilder.AppendLine(" " + this.coveringGas.label.CapitalizeFirst() + " " + this.FactorFromCoveringGas.ToStringPercent()); } if (this.FactorFromPosture < 0.9999f) { stringBuilder.AppendLine(" " + "TargetProne".Translate() + " " + this.FactorFromPosture.ToStringPercent()); } if (this.FactorFromExecution != 1f) { stringBuilder.AppendLine(" " + "Execution".Translate() + " " + this.FactorFromExecution.ToStringPercent()); } if (this.PassCoverChance < 1f) { stringBuilder.AppendLine(" " + "ShootingCover".Translate() + " " + this.PassCoverChance.ToStringPercent()); for (int i = 0; i < this.covers.Count; i++) { CoverInfo coverInfo = this.covers[i]; if (coverInfo.BlockChance > 0f) { stringBuilder.AppendLine(" " + "CoverThingBlocksPercentOfShots".Translate(new object[] { coverInfo.Thing.LabelCap, coverInfo.BlockChance.ToStringPercent() })); } } } else { stringBuilder.AppendLine(" (" + "NoCoverLower".Translate() + ")"); } } return(stringBuilder.ToString()); }
public string GetTextReadout() { StringBuilder stringBuilder = new StringBuilder(); if (this.forcedMissRadius > 0.5) { stringBuilder.AppendLine(); stringBuilder.AppendLine("WeaponMissRadius".Translate() + " " + this.forcedMissRadius.ToString("F1")); } else { stringBuilder.AppendLine(" " + this.TotalEstimatedHitChance.ToStringPercent()); stringBuilder.AppendLine(" " + "ShootReportShooterAbility".Translate() + " " + this.factorFromShooterAndDist.ToStringPercent()); if (this.factorFromEquipment < 0.99000000953674316) { stringBuilder.AppendLine(" " + "ShootReportWeapon".Translate() + " " + this.factorFromEquipment.ToStringPercent()); } if (this.target.HasThing && this.factorFromTargetSize != 1.0) { stringBuilder.AppendLine(" " + "TargetSize".Translate() + " " + this.factorFromTargetSize.ToStringPercent()); } if (this.factorFromWeather < 0.99000000953674316) { stringBuilder.AppendLine(" " + "Weather".Translate() + " " + this.factorFromWeather.ToStringPercent()); } if (this.FactorFromCoveringGas < 0.99000000953674316) { stringBuilder.AppendLine(" " + this.coveringGas.label.CapitalizeFirst() + " " + this.FactorFromCoveringGas.ToStringPercent()); } if (this.FactorFromPosture < 0.99989998340606689) { stringBuilder.AppendLine(" " + "TargetProne".Translate() + " " + this.FactorFromPosture.ToStringPercent()); } if (this.FactorFromExecution != 1.0) { stringBuilder.AppendLine(" " + "Execution".Translate() + " " + this.FactorFromExecution.ToStringPercent()); } if (this.ChanceToNotHitCover < 1.0) { stringBuilder.AppendLine(" " + "ShootingCover".Translate() + " " + this.ChanceToNotHitCover.ToStringPercent()); for (int i = 0; i < this.covers.Count; i++) { CoverInfo coverInfo = this.covers[i]; stringBuilder.AppendLine(" " + "CoverThingBlocksPercentOfShots".Translate(coverInfo.Thing.LabelCap, coverInfo.BlockChance.ToStringPercent())); } } else { stringBuilder.AppendLine(" (" + "NoCoverLower".Translate() + ")"); } } return(stringBuilder.ToString()); }
public static List <CoverInfo> CalculateCoverGiverSet(IntVec3 targetLoc, IntVec3 shooterLoc, Map map) { List <CoverInfo> list = new List <CoverInfo>(); for (int i = 0; i < 8; i++) { IntVec3 intVec = targetLoc + GenAdj.AdjacentCells[i]; CoverInfo item = default(CoverInfo); if (intVec.InBounds(map) && CoverUtility.TryFindAdjustedCoverInCell(shooterLoc, targetLoc, intVec, map, out item)) { list.Add(item); } } return(list); }
public static float CalculateOverallBlockChance(IntVec3 targetLoc, IntVec3 shooterLoc, Map map) { float num = 0f; for (int i = 0; i < 8; i++) { IntVec3 intVec = targetLoc + GenAdj.AdjacentCells[i]; CoverInfo coverInfo = default(CoverInfo); if (intVec.InBounds(map) && CoverUtility.TryFindAdjustedCoverInCell(shooterLoc, targetLoc, intVec, map, out coverInfo)) { num = (float)(num + (1.0 - num) * coverInfo.BlockChance); } } return(num); }
private static float <GetRandomCoverToMissInto> m__0(CoverInfo c) { return(c.BlockChance); }