private bool CheckForFreeIntercept(IntVec3 c) { bool result; if (this.destination.ToIntVec3() == c) { result = false; } else { float num = VerbUtility.DistanceInterceptChance(this.origin, c, this.intendedTarget.Cell); if (num <= 0f) { result = false; } else { bool flag = false; List <Thing> thingList = c.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (this.CanHit(thing)) { bool flag2 = false; if (thing.def.Fillage == FillCategory.Full) { Building_Door building_Door = thing as Building_Door; if (building_Door == null || !building_Door.Open) { this.ThrowDebugText("int-wall", c); this.Impact(thing); return(true); } flag2 = true; } float num2 = 0f; Pawn pawn = thing as Pawn; if (pawn != null) { num2 = 0.4f; num2 *= Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != PawnPosture.Standing) { num2 *= 0.1f; } if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !pawn.Faction.HostileTo(this.launcher.Faction)) { num2 *= 0.4f; } } else if (thing.def.fillPercent > 0.2f) { if (flag2) { num2 = 0.05f; } else if (this.DestinationCell.AdjacentTo8Way(c)) { num2 = thing.def.fillPercent * 1f; } else { num2 = thing.def.fillPercent * 0.15f; } } num2 *= num; if (num2 > 1E-05f) { if (Rand.Chance(num2)) { this.ThrowDebugText("int-" + num2.ToStringPercent(), c); this.Impact(thing); return(true); } flag = true; this.ThrowDebugText(num2.ToStringPercent(), c); } } } if (!flag) { this.ThrowDebugText("o", c); } result = false; } } return(result); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); bool result; if (intVec2 == intVec) { result = false; } else if (!intVec.InBounds(base.Map) || !intVec2.InBounds(base.Map)) { result = false; } else if (intVec2.AdjacentToCardinal(intVec)) { result = this.CheckForFreeIntercept(intVec2); } else if (VerbUtility.DistanceInterceptChance(this.origin, intVec2, this.intendedTarget.Cell) > 0f) { Vector3 vector = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 b = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); Projectile.checkedCells.Clear(); int num2 = 0; for (;;) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!Projectile.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } Projectile.checkedCells.Add(intVec3); } num2++; if (num2 > num) { goto Block_7; } if (intVec3 == intVec2) { goto Block_8; } } return(true); Block_7: return(false); Block_8: result = false; } else { result = false; } return(result); }