public static IEnumerable <Thing> RadialDistinctThingsAround(IntVec3 center, Map map, float radius, bool useCenter) { int numCells = GenRadial.NumCellsInRadius(radius); HashSet <Thing> returnedThings = null; for (int i = (!useCenter) ? 1 : 0; i < numCells; i++) { IntVec3 cell = GenRadial.RadialPattern[i] + center; if (cell.InBounds(map)) { List <Thing> thingList = cell.GetThingList(map); int j = 0; while (j < thingList.Count) { Thing t = thingList[j]; if (t.def.size.x <= 1 || t.def.size.z <= 1) { goto IL_14F; } if (returnedThings == null) { returnedThings = new HashSet <Thing>(); } if (!returnedThings.Contains(t)) { returnedThings.Add(t); goto IL_14F; } IL_170: j++; continue; IL_14F: yield return(t); goto IL_170; } } } yield break; }
public static IEnumerable <Thing> RadialDistinctThingsAround(IntVec3 center, Map map, float radius, bool useCenter) { int numCells = GenRadial.NumCellsInRadius(radius); HashSet <Thing> returnedThings = null; for (int j = (!useCenter) ? 1 : 0; j < numCells; j++) { IntVec3 cell = GenRadial.RadialPattern[j] + center; if (cell.InBounds(map)) { List <Thing> thingList = cell.GetThingList(map); int i = 0; while (i < thingList.Count) { Thing t = thingList[i]; if (t.def.size.x > 1 && t.def.size.z > 1) { if (returnedThings == null) { returnedThings = new HashSet <Thing>(); } if (!returnedThings.Contains(t)) { returnedThings.Add(t); goto IL_014a; } i++; continue; } goto IL_014a; IL_014a: yield return(t); /*Error: Unable to find new state assignment for yield return*/; } } } }
private bool IsGoodExitCell(IntVec3 cell) { bool result; if (!cell.CanBeSeenOver(this.map)) { result = false; } else { int num = GenRadial.NumCellsInRadius(2f); for (int i = 0; i < num; i++) { IntVec3 intVec = cell + GenRadial.RadialPattern[i]; if (intVec.InBounds(this.map) && intVec.OnEdge(this.map) && intVec.CanBeSeenOverFast(this.map) && GenSight.LineOfSight(cell, intVec, this.map, false, null, 0, 0)) { return(true); } } result = false; } return(result); }
public static void DrawRadiusRing(IntVec3 center, float radius, Color color, Func <IntVec3, bool> predicate = null) { if (radius > GenRadial.MaxRadialPatternRadius) { if (!maxRadiusMessaged) { Log.Error("Cannot draw radius ring of radius " + radius + ": not enough squares in the precalculated list."); maxRadiusMessaged = true; } return; } ringDrawCells.Clear(); int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num; i++) { IntVec3 intVec = center + GenRadial.RadialPattern[i]; if (predicate == null || predicate(intVec)) { ringDrawCells.Add(intVec); } } DrawFieldEdges(ringDrawCells, color); }
protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (this.ownerEquipment != null) { CompChangeableProjectile comp = this.ownerEquipment.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = this.ownerEquipment; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); projectile2.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); if (this.verbProps.forcedMissRadius > 0.5f) { float num = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; float num2; if (num < 9f) { num2 = 0f; } else if (num < 25f) { num2 = this.verbProps.forcedMissRadius * 0.5f; } else if (num < 49f) { num2 = this.verbProps.forcedMissRadius * 0.8f; } else { num2 = this.verbProps.forcedMissRadius * 1f; } if (num2 > 0.5f) { int max = GenRadial.NumCellsInRadius(this.verbProps.forcedMissRadius); int num3 = Rand.Range(0, max); if (num3 > 0) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num3]; if (this.currentTarget.HasThing) { projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); if (Rand.Value > shotReport.ChanceToNotGoWild_IgnoringPosture) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } shootLine.ChangeDestToMissWild(); if (this.currentTarget.HasThing) { projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, shootLine.Dest, equipment, this.currentTarget.Thing); return(true); } if (Rand.Value > shotReport.ChanceToNotHitCover) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = true; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); return(true); } } if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } if (!projectile2.def.projectile.flyOverhead) { projectile2.InterceptWalls = (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full); } if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, equipment, this.currentTarget.Thing); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, equipment, this.currentTarget.Thing); } return(true); }
public static IntVec3 FindNoWipeSpawnLocNear(IntVec3 near, Map map, ThingDef thingToSpawn, Rot4 rot, int maxDist = 2, Predicate <IntVec3> extraValidator = null) { int num = GenRadial.NumCellsInRadius(maxDist); IntVec3 result = IntVec3.Invalid; float num2 = 0f; for (int i = 0; i < num; i++) { IntVec3 intVec = near + GenRadial.RadialPattern[i]; if (!intVec.InBounds(map)) { continue; } CellRect cellRect = GenAdj.OccupiedRect(intVec, rot, thingToSpawn.size); if (!cellRect.InBounds(map) || !GenSight.LineOfSight(near, intVec, map, skipFirstCell: true) || (extraValidator != null && !extraValidator(intVec)) || (thingToSpawn.category == ThingCategory.Building && !GenConstruct.CanBuildOnTerrain(thingToSpawn, intVec, map, rot))) { continue; } bool flag = false; bool flag2 = false; tmpUniqueWipedThings.Clear(); foreach (IntVec3 item in cellRect) { if (item.Impassable(map)) { flag2 = true; } List <Thing> thingList = item.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { if (thingList[j] is Pawn) { flag = true; } else if (GenSpawn.SpawningWipes(thingToSpawn, thingList[j].def) && !tmpUniqueWipedThings.Contains(thingList[j])) { tmpUniqueWipedThings.Add(thingList[j]); } } } if (flag && thingToSpawn.passability == Traversability.Impassable) { tmpUniqueWipedThings.Clear(); continue; } if (flag2 && thingToSpawn.category == ThingCategory.Item) { tmpUniqueWipedThings.Clear(); continue; } float num3 = 0f; for (int k = 0; k < tmpUniqueWipedThings.Count; k++) { if (tmpUniqueWipedThings[k].def.category == ThingCategory.Building && !tmpUniqueWipedThings[k].def.costList.NullOrEmpty() && tmpUniqueWipedThings[k].def.costStuffCount == 0) { List <ThingDefCountClass> list = tmpUniqueWipedThings[k].CostListAdjusted(); for (int l = 0; l < list.Count; l++) { num3 += list[l].thingDef.GetStatValueAbstract(StatDefOf.MarketValue) * (float)list[l].count * (float)tmpUniqueWipedThings[k].stackCount; } } else { num3 += tmpUniqueWipedThings[k].MarketValue * (float)tmpUniqueWipedThings[k].stackCount; } if (tmpUniqueWipedThings[k].def.category == ThingCategory.Building || tmpUniqueWipedThings[k].def.category == ThingCategory.Item) { num3 = Mathf.Max(num3, 0.001f); } } tmpUniqueWipedThings.Clear(); if (!result.IsValid || num3 < num2) { if (num3 == 0f) { return(intVec); } result = intVec; num2 = num3; } } if (!result.IsValid) { return(near); } return(result); }
protected override bool TryCastShot() { if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map) { return(false); } ThingDef projectile = Projectile; if (projectile == null) { return(false); } ShootLine resultingLine; bool flag = TryFindShootLineFromTo(caster.Position, currentTarget, out resultingLine); if (verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { base.EquipmentSource.GetComp <CompChangeableProjectile>()?.Notify_ProjectileLaunched(); base.EquipmentSource.GetComp <CompReloadable>()?.UsedOnce(); } Thing launcher = caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = caster; } Vector3 drawPos = caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, resultingLine.Source, caster.Map); if (verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(verbProps.forcedMissRadius, currentTarget.Cell - caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); if (num2 > 0) { IntVec3 c = currentTarget.Cell + GenRadial.RadialPattern[num2]; ThrowDebugText("ToRadius"); ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, currentTarget, projectileHitFlags, equipment); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(caster, this, currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = randomCoverToMissInto?.def; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { resultingLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); ThrowDebugText("ToWild" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); ThrowDebugText("Wild\nDest", resultingLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, resultingLine.Dest, currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } if (currentTarget.Thing != null && currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { ThrowDebugText("ToCover" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true); } ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!currentTarget.HasThing || currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } ThrowDebugText("ToHit" + (canHitNonTargetPawnsNow ? "\nchntp" : "")); if (currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, currentTarget, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, resultingLine.Dest, currentTarget, projectileHitFlags4, equipment, targetCoverDef); ThrowDebugText("Hit\nDest", resultingLine.Dest); } return(true); }
// Token: 0x060064F4 RID: 25844 RVA: 0x001B8C14 File Offset: 0x001B7014 protected override bool TryCastShot() { // Log.Message(string.Format("{0}, {1}, {2}, {3}", CasterPawn.equipment.Primary != null , CasterPawn.equipment.Primary.def.IsRangedWeapon , CasterPawn.equipment.PrimaryEq.PrimaryVerb.HarmsHealth() , !CasterPawn.equipment.PrimaryEq.PrimaryVerb.UsesExplosiveProjectiles())); if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } ThingDef projectile = this.Projectile; if (projectile == null) { return(false); } bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out ShootLine shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (base.EquipmentSource != null) { CompChangeableProjectile comp = base.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = base.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Stuffable_Projectile projectile2 = (Stuffable_Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map, WipeMode.Vanish); if (this.verbProps.forcedMissRadius > 0.5f) { float num = VerbUtility.CalculateAdjustedForcedMiss(this.verbProps.forcedMissRadius, this.currentTarget.Cell - this.caster.Position); if (num > 0.5f) { int max = GenRadial.NumCellsInRadius(num); int num2 = Rand.Range(0, max); if (num2 > 0) { IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num2]; this.ThrowDebugText("ToRadius"); this.ThrowDebugText("Rad\nDest", c); ProjectileHitFlags projectileHitFlags = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f)) { projectileHitFlags = ProjectileHitFlags.All; } if (!this.canHitNonTargetPawnsNow) { projectileHitFlags &= ~ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, c, this.currentTarget, projectileHitFlags, equipment, null); return(true); } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); ThingDef targetCoverDef = randomCoverToMissInto?.def; if (!Rand.Chance(shotReport.AimOnTargetChance_IgnoringPosture)) { shootLine.ChangeDestToMissWild(shotReport.AimOnTargetChance_StandardTarget); this.ThrowDebugText("ToWild" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); this.ThrowDebugText("Wild\nDest", shootLine.Dest); ProjectileHitFlags projectileHitFlags2 = ProjectileHitFlags.NonTargetWorld; if (Rand.Chance(0.5f) && this.canHitNonTargetPawnsNow) { projectileHitFlags2 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags2, equipment, targetCoverDef); return(true); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn && !Rand.Chance(shotReport.PassCoverChance)) { this.ThrowDebugText("ToCover" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); this.ThrowDebugText("Cover\nDest", randomCoverToMissInto.Position); ProjectileHitFlags projectileHitFlags3 = ProjectileHitFlags.NonTargetWorld; if (this.canHitNonTargetPawnsNow) { projectileHitFlags3 |= ProjectileHitFlags.NonTargetPawns; } projectile2.Launch(launcher, drawPos, randomCoverToMissInto, this.currentTarget, projectileHitFlags3, equipment, targetCoverDef); return(true); } ProjectileHitFlags projectileHitFlags4 = ProjectileHitFlags.IntendedTarget; if (this.canHitNonTargetPawnsNow) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetPawns; } if (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full) { projectileHitFlags4 |= ProjectileHitFlags.NonTargetWorld; } this.ThrowDebugText("ToHit" + ((!this.canHitNonTargetPawnsNow) ? string.Empty : "\nchntp")); if (this.currentTarget.Thing != null) { projectile2.Launch(launcher, drawPos, this.currentTarget, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", this.currentTarget.Cell); } else { projectile2.Launch(launcher, drawPos, shootLine.Dest, this.currentTarget, projectileHitFlags4, equipment, targetCoverDef); this.ThrowDebugText("Hit\nDest", shootLine.Dest); } return(true); }
public string GetTextReadout() { StringBuilder stringBuilder = new StringBuilder(); if (forcedMissRadius > 0.5f) { stringBuilder.AppendLine(); stringBuilder.AppendLine("WeaponMissRadius".Translate() + " " + forcedMissRadius.ToString("F1")); stringBuilder.AppendLine("DirectHitChance".Translate() + " " + (1f / (float)GenRadial.NumCellsInRadius(forcedMissRadius)).ToStringPercent()); } else { stringBuilder.AppendLine(" " + TotalEstimatedHitChance.ToStringPercent()); stringBuilder.AppendLine(" " + "ShootReportShooterAbility".Translate() + " " + factorFromShooterAndDist.ToStringPercent()); stringBuilder.AppendLine(" " + "ShootReportWeapon".Translate() + " " + factorFromEquipment.ToStringPercent()); if (target.HasThing && factorFromTargetSize != 1f) { stringBuilder.AppendLine(" " + "TargetSize".Translate() + " " + factorFromTargetSize.ToStringPercent()); } if (factorFromWeather < 0.99f) { stringBuilder.AppendLine(" " + "Weather".Translate() + " " + factorFromWeather.ToStringPercent()); } if (FactorFromCoveringGas < 0.99f) { stringBuilder.AppendLine(" " + coveringGas.label.CapitalizeFirst() + " " + FactorFromCoveringGas.ToStringPercent()); } if (FactorFromPosture < 0.9999f) { stringBuilder.AppendLine(" " + "TargetProne".Translate() + " " + FactorFromPosture.ToStringPercent()); } if (FactorFromExecution != 1f) { stringBuilder.AppendLine(" " + "Execution".Translate() + " " + FactorFromExecution.ToStringPercent()); } if (PassCoverChance < 1f) { stringBuilder.AppendLine(" " + "ShootingCover".Translate() + " " + PassCoverChance.ToStringPercent()); for (int i = 0; i < covers.Count; i++) { CoverInfo coverInfo = covers[i]; if (coverInfo.BlockChance > 0f) { stringBuilder.AppendLine(" " + "CoverThingBlocksPercentOfShots".Translate(coverInfo.Thing.LabelCap, coverInfo.BlockChance.ToStringPercent(), new NamedArgument(coverInfo.Thing.def, "COVER"))); } } } else { stringBuilder.AppendLine(" (" + "NoCoverLower".Translate() + ")"); } } return(stringBuilder.ToString()); }
public static IntVec3 FindNoWipeSpawnLocNear(IntVec3 near, Map map, ThingDef thingToSpawn, Rot4 rot, int maxDist = 2, Predicate <IntVec3> extraValidator = null) { int num = GenRadial.NumCellsInRadius((float)maxDist); IntVec3 intVec = IntVec3.Invalid; float num2 = 0f; for (int i = 0; i < num; i++) { IntVec3 intVec2 = near + GenRadial.RadialPattern[i]; if (intVec2.InBounds(map)) { CellRect cellRect = GenAdj.OccupiedRect(intVec2, rot, thingToSpawn.size); if (cellRect.InBounds(map)) { if (GenSight.LineOfSight(near, intVec2, map, true, null, 0, 0)) { if (extraValidator == null || extraValidator(intVec2)) { if (thingToSpawn.category != ThingCategory.Building || GenConstruct.CanBuildOnTerrain(thingToSpawn, intVec2, map, rot, null)) { bool flag = false; bool flag2 = false; CellFinder.tmpUniqueWipedThings.Clear(); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { if (iterator.Current.Impassable(map)) { flag2 = true; } List <Thing> thingList = iterator.Current.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { if (thingList[j] is Pawn) { flag = true; } else if (GenSpawn.SpawningWipes(thingToSpawn, thingList[j].def) && !CellFinder.tmpUniqueWipedThings.Contains(thingList[j])) { CellFinder.tmpUniqueWipedThings.Add(thingList[j]); } } iterator.MoveNext(); } if (flag && thingToSpawn.passability == Traversability.Impassable) { CellFinder.tmpUniqueWipedThings.Clear(); } else if (flag2 && thingToSpawn.category == ThingCategory.Item) { CellFinder.tmpUniqueWipedThings.Clear(); } else { float num3 = 0f; for (int k = 0; k < CellFinder.tmpUniqueWipedThings.Count; k++) { if (CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Building && !CellFinder.tmpUniqueWipedThings[k].def.costList.NullOrEmpty <ThingDefCountClass>() && CellFinder.tmpUniqueWipedThings[k].def.costStuffCount == 0) { List <ThingDefCountClass> list = CellFinder.tmpUniqueWipedThings[k].CostListAdjusted(); for (int l = 0; l < list.Count; l++) { num3 += list[l].thingDef.GetStatValueAbstract(StatDefOf.MarketValue, null) * (float)list[l].count * (float)CellFinder.tmpUniqueWipedThings[k].stackCount; } } else { num3 += CellFinder.tmpUniqueWipedThings[k].MarketValue * (float)CellFinder.tmpUniqueWipedThings[k].stackCount; } if (CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Building || CellFinder.tmpUniqueWipedThings[k].def.category == ThingCategory.Item) { num3 = Mathf.Max(num3, 0.001f); } } CellFinder.tmpUniqueWipedThings.Clear(); if (!intVec.IsValid || num3 < num2) { if (num3 == 0f) { return(intVec2); } intVec = intVec2; num2 = num3; } } } } } } } } return((!intVec.IsValid) ? near : intVec); }
// Token: 0x06000006 RID: 6 RVA: 0x0000225C File Offset: 0x0000045C protected override bool TryCastShot() { bool flag = this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map; bool result; if (flag) { result = false; } else { ThingDef projectile = this.Projectile; bool flag2 = projectile == null; if (flag2) { result = false; } else { ShootLine shootLine; bool flag3 = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); bool flag4 = this.verbProps.stopBurstWithoutLos && !flag3; if (flag4) { result = false; } else { bool flag5 = this.EquipmentSource != null; if (flag5) { CompChangeableProjectile comp = this.EquipmentSource.GetComp <CompChangeableProjectile>(); bool flag6 = comp != null; if (flag6) { comp.Notify_ProjectileLaunched(); } } Thing thing = this.caster; Thing thing2 = this.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); bool flag7 = compMannable != null && compMannable.ManningPawn != null; if (flag7) { thing = compMannable.ManningPawn; thing2 = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); int num = this.PelletsPerShot(projectile); bool flag8 = num < 1; if (flag8) { num = 1; } Projectile[] array = new Projectile[num]; ShootLine[] array2 = new ShootLine[num]; for (int i = 0; i < num; i++) { base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out array2[i]); array[i] = (Projectile)GenSpawn.Spawn(projectile, array2[i].Source, this.caster.Map); //array[i].FreeIntercept = (this.canFreeInterceptNow && !array[i].def.projectile.flyOverhead); } float num2 = (this.currentTarget.Cell - this.caster.Position).LengthHorizontal; float num3 = this.ScatterRadiusAt10tilesAway(projectile) * num2 / 10f; float num4 = this.verbProps.forcedMissRadius + this.ForsedScatterRadius(projectile) + num3; int j = 0; while (j < num) { bool flag9 = num4 > 0.5f; if (!flag9) { goto IL_41E; } float num5 = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; bool flag10 = num5 < 9f; float num6; if (flag10) { num6 = 0f; } else { bool flag11 = num5 < 25f; if (flag11) { num6 = num4 * 0.5f; } else { bool flag12 = num5 < 49f; if (flag12) { num6 = num4 * 0.8f; } else { num6 = num4 * 1f; } } } bool flag13 = num6 > 0.5f; if (!flag13) { goto IL_41E; } int max = GenRadial.NumCellsInRadius(num4); int num7 = Rand.Range(0, max); bool flag14 = num7 > 0; if (flag14) { bool drawShooting = DebugViewSettings.drawShooting; if (drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } bool hasThing = this.currentTarget.HasThing; if (hasThing) { array[j].HitFlags = ProjectileHitFlags.All; //array[j].ThingToNeverIntercept = this.currentTarget.Thing; } bool flag15 = !array[j].def.projectile.flyOverhead; if (flag15) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num7]; array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(c), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); } else { array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(this.currentTarget.Cell), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, this.currentTarget.Cell, thing2, this.currentTarget.Thing); } IL_6D8: j++; continue; IL_41E: ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); bool flag16 = Rand.Value > shotReport.AimOnTargetChance_IgnoringPosture; if (flag16) { bool drawShooting2 = DebugViewSettings.drawShooting; if (drawShooting2) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } array2[j].ChangeDestToMissWild(shotReport.AimOnTargetChance); bool hasThing2 = this.currentTarget.HasThing; if (hasThing2) { array[j].HitFlags = ProjectileHitFlags.All; //array[j].ThingToNeverIntercept = this.currentTarget.Thing; } bool flag17 = !array[j].def.projectile.flyOverhead; if (flag17) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; //array[j].InterceptWalls = true; } array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(array2[j].Dest), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, array2[j].Dest, thing2, this.currentTarget.Thing); goto IL_6D8; } bool flag18 = Rand.Value > shotReport.PassCoverChance; if (flag18) { bool drawShooting3 = DebugViewSettings.drawShooting; if (drawShooting3) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } bool flag19 = this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn; if (flag19) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); bool flag20 = !array[j].def.projectile.flyOverhead; if (flag20) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(randomCoverToMissInto), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, randomCoverToMissInto, thing2, this.currentTarget.Thing); goto IL_6D8; } } bool drawShooting4 = DebugViewSettings.drawShooting; if (drawShooting4) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } bool flag21 = !array[j].def.projectile.flyOverhead && (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full); if (flag21) { array[j].HitFlags = ProjectileHitFlags.IntendedTarget; } bool flag22 = this.currentTarget.Thing != null; if (flag22) { array[j].Launch(thing, origin: drawPos, usedTarget: currentTarget, intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, this.currentTarget, thing2, this.currentTarget.Thing); } else { array[j].Launch(thing, origin: drawPos, usedTarget: new LocalTargetInfo(array2[j].Dest), intendedTarget: currentTarget, equipment: thing2, hitFlags: array[j].HitFlags); //array[j].Launch(thing, drawPos, array2[j].Dest, thing2, this.currentTarget.Thing); } goto IL_6D8; } result = true; } } } return(result); }
protected override bool TryCastShot() { if (this.currentTarget.HasThing && this.currentTarget.Thing.Map != this.caster.Map) { return(false); } // ThingDef projectile = this.Projectile; ThingDef projectile = this.Projectile; // projectile.projectileWhenLoaded. if (projectile == null) { return(false); } ShootLine shootLine; bool flag = base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLine); if (this.verbProps.stopBurstWithoutLos && !flag) { return(false); } if (this.EquipmentSource != null) { CompChangeableProjectile comp = this.EquipmentSource.GetComp <CompChangeableProjectile>(); if (comp != null) { comp.Notify_ProjectileLaunched(); } } Thing launcher = this.caster; Thing equipment = this.EquipmentSource; CompMannable compMannable = this.caster.TryGetComp <CompMannable>(); if (compMannable != null && compMannable.ManningPawn != null) { launcher = compMannable.ManningPawn; equipment = this.caster; } Vector3 drawPos = this.caster.DrawPos; Projectile projectile2 = (Projectile)GenSpawn.Spawn(projectile, shootLine.Source, this.caster.Map); //--------------- int pellets = this.PelletsPerShot(projectile); if (pellets < 1) { pellets = 1; } Projectile[] projectiles = new Projectile[pellets]; ShootLine[] shootLines = new ShootLine[pellets]; for (int i = 0; i < pellets; i++) { base.TryFindShootLineFromTo(this.caster.Position, this.currentTarget, out shootLines[i]); projectiles[i] = (Projectile)GenSpawn.Spawn(projectile, shootLines[i].Source, this.caster.Map); //projectiles[i].FreeIntercept = (this.canFreeInterceptNow && !projectiles[i].def.projectile.flyOverhead); } //projectile2.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); //projectile3.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); //projectile4.FreeIntercept = (this.canFreeInterceptNow && !projectile2.def.projectile.flyOverhead); float distance = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontal; float scatter = ScatterRadiusAt10tilesAway(projectile) * distance / 10.0f; float missRadius = this.verbProps.forcedMissRadius + ForsedScatterRadius(projectile) + scatter; for (int i = 0; i < pellets; i++) { if (missRadius > 0.5f) { float num = (float)(this.currentTarget.Cell - this.caster.Position).LengthHorizontalSquared; float num2; if (num < 9f) { num2 = 0f; } else if (num < 25f) { num2 = missRadius * 0.5f; } else if (num < 49f) { num2 = missRadius * 0.8f; } else { num2 = missRadius * 1f; } if (num2 > 0.5f) { int max = GenRadial.NumCellsInRadius(missRadius); //int num3 = Rand.Range(0, max); int num3 = Rand.Range(0, max); if (num3 > 0) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToForRad", -1f); } //if (this.currentTarget.HasThing) //{ // // projectile2.ThingToNeverIntercept = this.currentTarget.Thing; // projectiles[i].ThingToNeverIntercept = this.currentTarget.Thing; //} //if (!projectiles[i].def.projectile.flyOverhead) //{ // projectiles[i].InterceptWalls = true; //} IntVec3 c = this.currentTarget.Cell + GenRadial.RadialPattern[num3]; projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(c), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectile2.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); //projectile3.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); //projectile4.Launch(launcher, drawPos, c, equipment, this.currentTarget.Thing); continue;// return true; } else { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(this.currentTarget.Cell), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, this.currentTarget.Cell, equipment, this.currentTarget.Thing); continue; } } } ShotReport shotReport = ShotReport.HitReportFor(this.caster, this, this.currentTarget); if (Rand.Value > shotReport.AimOnTargetChance_IgnoringPosture) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToWild", -1f); } shootLines[i].ChangeDestToMissWild(shotReport.AimOnTargetChance); // shootLine2.ChangeDestToMissWild(); if (this.currentTarget.HasThing) { projectiles[i].HitFlags = ProjectileHitFlags.All; // projectile2.ThingToNeverIntercept = this.currentTarget.Thing; } if (!projectiles[i].def.projectile.flyOverhead) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(shootLines[i].Dest), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, shootLines[i].Dest, equipment, this.currentTarget.Thing); //projectile2.Launch(launcher, drawPos, shootLine2.Dest, equipment, this.currentTarget.Thing); continue;//return true; } if (Rand.Value > shotReport.PassCoverChance) { if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToCover", -1f); } if (this.currentTarget.Thing != null && this.currentTarget.Thing.def.category == ThingCategory.Pawn) { Thing randomCoverToMissInto = shotReport.GetRandomCoverToMissInto(); if (!projectiles[i].def.projectile.flyOverhead) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(randomCoverToMissInto), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); //projectile2.Launch(launcher, drawPos, randomCoverToMissInto, equipment, this.currentTarget.Thing); continue;//return true; } } if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.caster.DrawPos, this.caster.Map, "ToHit", -1f); } if (!projectiles[i].def.projectile.flyOverhead && (!this.currentTarget.HasThing || this.currentTarget.Thing.def.Fillage == FillCategory.Full)) { projectiles[i].HitFlags = ProjectileHitFlags.IntendedTarget; } if (this.currentTarget.Thing != null) { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: currentTarget, intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, this.currentTarget, equipment, this.currentTarget.Thing); } else { projectiles[i].Launch(launcher, origin: drawPos, usedTarget: new LocalTargetInfo(shootLines[i].Dest), intendedTarget: currentTarget, hitFlags: projectiles[i].HitFlags, equipment: equipment); //projectiles[i].Launch(launcher, drawPos, shootLines[i].Dest, equipment, this.currentTarget.Thing); } } return(true); }