/// <summary> /// Produces a secondary explosion on impact using the explosion values from the projectile's projectile def. Requires the projectile's launcher to be passed on due to protection level, /// only works when parent can be cast as ProjectileCR. Intended use is for HEAT and similar weapons that spawn secondary explosions while also penetrating, NOT explosive ammo of /// anti-materiel rifles as the explosion just spawns on top of the pawn, not inside the hit body part. /// /// Additionally handles fragmentation effects if defined. /// </summary> /// <param name="instigator">Launcher of the projectile calling the method</param> public virtual void Explode(Thing instigator, Verse.IntVec3 pos) { // Regular explosion stuff if (this.Props.explosionRadius > 0 && this.Props.explosionDamage > 0) { Explosion explosion = new Explosion(); explosion.position = pos; explosion.radius = Props.explosionRadius; explosion.damType = Props.explosionDamageDef; explosion.instigator = instigator; explosion.damAmount = GenMath.RoundRandom(Props.explosionDamage); explosion.source = parent.def; explosion.preExplosionSpawnThingDef = Props.preExplosionSpawnThingDef; explosion.preExplosionSpawnChance = Props.explosionSpawnChance; explosion.postExplosionSpawnThingDef = Props.postExplosionSpawnThingDef; explosion.postExplosionSpawnChance = Props.explosionSpawnChance; explosion.applyDamageToExplosionCellsNeighbors = Props.damageAdjacentTiles; Find.Map.GetComponent <ExplosionManager>().StartExplosion(explosion, Props.soundExplode == null ? Props.explosionDamageDef.soundExplosion : Props.soundExplode); } // Fragmentation stuff if (!Props.fragments.NullOrEmpty()) { if (Props.fragRange <= 0) { Log.Error(this.parent.LabelCap + " has fragments but no fragRange"); } else { Vector3 exactOrigin = new Vector3(0, 0, 0); exactOrigin.x = this.parent.DrawPos.x; exactOrigin.z = this.parent.DrawPos.z; foreach (ThingCount fragment in Props.fragments) { for (int i = 0; i < fragment.count; i++) { ProjectileCR projectile = (ProjectileCR)ThingMaker.MakeThing(fragment.thingDef, null); projectile.canFreeIntercept = true; Vector3 exactTarget = exactOrigin + (new Vector3(1, 0, 1) * UnityEngine.Random.Range(0, Props.fragRange)).RotatedBy(UnityEngine.Random.Range(0, 360)); TargetInfo targetCell = exactTarget.ToIntVec3(); GenSpawn.Spawn(projectile, this.parent.Position); projectile.Launch(instigator, exactOrigin, targetCell, exactTarget, null); } } } } }
public void Set(IntVec3 prioritizedCell, WorkTypeDef prioritizedWorkType) { this.prioritizedCell = prioritizedCell; this.prioritizedWorkType = prioritizedWorkType; this.prioritizeTick = Find.TickManager.TicksGame; }
public static FloodUnfogResult FloodUnfog(IntVec3 root, Map map) { FloodFillerFog.cellsToUnfog.Clear(); FloodUnfogResult result = default(FloodUnfogResult); bool[] fogGridDirect = map.fogGrid.fogGrid; FogGrid fogGrid = map.fogGrid; List <IntVec3> newlyUnfoggedCells = new List <IntVec3>(); int numUnfogged = 0; bool expanding = false; CellRect viewRect = CellRect.ViewRect(map); result.allOnScreen = true; Predicate <IntVec3> predicate = delegate(IntVec3 c) { if (!fogGridDirect[map.cellIndices.CellToIndex(c)]) { return(false); } Thing edifice = c.GetEdifice(map); return((edifice == null || !edifice.def.MakeFog) && (!FloodFillerFog.testMode || expanding || numUnfogged <= 500)); }; Action <IntVec3> processor = delegate(IntVec3 c) { fogGrid.Unfog(c); newlyUnfoggedCells.Add(c); List <Thing> thingList = c.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Pawn pawn = thingList[l] as Pawn; if (pawn != null) { pawn.mindState.Active = true; if (pawn.def.race.IsMechanoid) { result.mechanoidFound = true; } } } if (!viewRect.Contains(c)) { result.allOnScreen = false; } result.cellsUnfogged++; if (FloodFillerFog.testMode) { numUnfogged++; map.debugDrawer.FlashCell(c, (float)numUnfogged / 200f, numUnfogged.ToStringCached(), 50); } }; map.floodFiller.FloodFill(root, predicate, processor, 2147483647, false, null); expanding = true; for (int i = 0; i < newlyUnfoggedCells.Count; i++) { IntVec3 a = newlyUnfoggedCells[i]; for (int j = 0; j < 8; j++) { IntVec3 intVec = a + GenAdj.AdjacentCells[j]; if (intVec.InBounds(map) && fogGrid.IsFogged(intVec)) { if (!predicate(intVec)) { FloodFillerFog.cellsToUnfog.Add(intVec); } } } } for (int k = 0; k < FloodFillerFog.cellsToUnfog.Count; k++) { fogGrid.Unfog(FloodFillerFog.cellsToUnfog[k]); if (FloodFillerFog.testMode) { map.debugDrawer.FlashCell(FloodFillerFog.cellsToUnfog[k], 0.3f, "x", 50); } } FloodFillerFog.cellsToUnfog.Clear(); return(result); }
public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine) { if (targ.HasThing && targ.Thing.Map != this.caster.Map) { resultingLine = default(ShootLine); return(false); } if (this.verbProps.IsMeleeAttack || this.verbProps.range <= 1.42f) { resultingLine = new ShootLine(root, targ.Cell); return(ReachabilityImmediate.CanReachImmediate(root, targ, this.caster.Map, PathEndMode.Touch, null)); } CellRect cellRect = (!targ.HasThing) ? CellRect.SingleCell(targ.Cell) : targ.Thing.OccupiedRect(); float num = this.verbProps.EffectiveMinRange(targ, this.caster); float num2 = cellRect.ClosestDistSquaredTo(root); if (num2 > this.verbProps.range * this.verbProps.range || num2 < num * num) { resultingLine = new ShootLine(root, targ.Cell); return(false); } if (!this.verbProps.requireLineOfSight) { resultingLine = new ShootLine(root, targ.Cell); return(true); } if (this.CasterIsPawn) { IntVec3 dest; if (this.CanHitFromCellIgnoringRange(root, targ, out dest)) { resultingLine = new ShootLine(root, dest); return(true); } ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), this.caster.Map, Verb.tempLeanShootSources); for (int i = 0; i < Verb.tempLeanShootSources.Count; i++) { IntVec3 intVec = Verb.tempLeanShootSources[i]; if (this.CanHitFromCellIgnoringRange(intVec, targ, out dest)) { resultingLine = new ShootLine(intVec, dest); return(true); } } } else { CellRect.CellRectIterator iterator = this.caster.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; IntVec3 dest; if (this.CanHitFromCellIgnoringRange(current, targ, out dest)) { resultingLine = new ShootLine(current, dest); return(true); } iterator.MoveNext(); } } resultingLine = new ShootLine(root, targ.Cell); return(false); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { if (lastExactPos == newExactPos) { return(false); } List <Thing> list = base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor); for (int i = 0; i < list.Count; i++) { if (list[i].TryGetComp <CompProjectileInterceptor>().CheckIntercept(this, lastExactPos, newExactPos)) { Destroy(); return(true); } } IntVec3 intVec = lastExactPos.ToIntVec3(); IntVec3 intVec2 = newExactPos.ToIntVec3(); if (intVec2 == intVec) { return(false); } if (!intVec.InBounds(base.Map) || !intVec2.InBounds(base.Map)) { return(false); } if (intVec2.AdjacentToCardinal(intVec)) { return(CheckForFreeIntercept(intVec2)); } if (VerbUtility.InterceptChanceFactorFromDistance(origin, intVec2) <= 0f) { return(false); } Vector3 vect = lastExactPos; Vector3 v = newExactPos - lastExactPos; Vector3 vector = v.normalized * 0.2f; int num = (int)(v.MagnitudeHorizontal() / 0.2f); checkedCells.Clear(); int num2 = 0; IntVec3 intVec3; do { vect += vector; intVec3 = vect.ToIntVec3(); if (!checkedCells.Contains(intVec3)) { if (CheckForFreeIntercept(intVec3)) { return(true); } checkedCells.Add(intVec3); } num2++; if (num2 > num) { return(false); } }while (!(intVec3 == intVec2)); return(false); }
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(); } 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); }
public SnowCategory GetCategory(IntVec3 c) { return(SnowUtility.GetSnowCategory(this.GetDepth(c))); }
public static int ManhattanDistanceFlat(IntVec3 a, IntVec3 b) { return(Math.Abs(a.x - b.x) + Math.Abs(a.z - b.z)); }
public static void DrawTargetingHightlight_Explosion(IntVec3 c, float Radius) { GenDraw.DrawRadiusRing(c, Radius); }
private static void DrawTargetingHighlight_Cell(IntVec3 c) { Vector3 position = c.ToVector3ShiftedWithAltitude(AltitudeLayer.Building); Graphics.DrawMesh(MeshPool.plane10, position, Quaternion.identity, GenDraw.CurTargetingMat, 0); }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef != null) { if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable) { for (int i = 0; i < 2; i++) { List <Thing> thingList = c.GetThingList(map); for (int num = thingList.Count - 1; num >= 0; num--) { Thing thing = thingList[num]; map.roofCollapseBuffer.Notify_Crushed(thing); Pawn pawn = thing as Pawn; DamageInfo dinfo = default(DamageInfo); if (pawn != null) { DamageDef crush = DamageDefOf.Crush; int amount = 99999; BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); dinfo = new DamageInfo(crush, amount, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999, -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken = null; if (i == 0 && pawn != null) { battleLogEntry_DamageTaken = new BattleLogEntry_DamageTaken(pawn, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken); } thing.TakeDamage(dinfo).InsertIntoLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Destroy(DestroyMode.Vanish); } } } } else { List <Thing> thingList2 = c.GetThingList(map); for (int num2 = thingList2.Count - 1; num2 >= 0; num2--) { Thing thing2 = thingList2[num2]; if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn) { map.roofCollapseBuffer.Notify_Crushed(thing2); float num3 = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange; if (thing2.def.building != null) { num3 *= thing2.def.building.roofCollapseDamageMultiplier; } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null; if (thing2 is Pawn) { battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken(thing2 as Pawn, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).InsertIntoLog(battleLogEntry_DamageTaken2); } } } if (roofDef.collapseLeavingThingDef != null) { Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map); if (thing3.def.rotatable) { thing3.Rotation = Rot4.Random; } } for (int j = 0; j < 1; j++) { Vector3 a = c.ToVector3Shifted(); a += Gen.RandomHorizontalVector(0.6f); MoteMaker.ThrowDustPuff(a, map, 2f); } } }
public void SetRegionAt(IntVec3 c, Region reg) { this.regionGrid[this.map.cellIndices.CellToIndex(c)] = reg; }
public Region GetRegionAt_NoRebuild_InvalidAllowed(IntVec3 c) { return(this.regionGrid[this.map.cellIndices.CellToIndex(c)]); }
public static bool CanReachImmediate(IntVec3 start, CellRect rect, Map map, PathEndMode peMode, Pawn pawn) { IntVec3 c = rect.ClosestCellTo(start); return(ReachabilityImmediate.CanReachImmediate(start, c, map, peMode, pawn)); }
public void Clear() { this.prioritizedCell = IntVec3.Invalid; this.prioritizedWorkType = null; this.prioritizeTick = 0; }
public static float DistanceTo(this IntVec3 a, IntVec3 b) { return((a - b).LengthHorizontal); }
public static int DistanceToSquared(this IntVec3 a, IntVec3 b) { return((a - b).LengthHorizontalSquared); }
public static void EqualizeTemperaturesThroughBuilding(Building b, float rate, bool twoWay) { int num = 0; float num2 = 0f; if (twoWay) { for (int i = 0; i < 2; i++) { IntVec3 intVec = (i != 0) ? (b.Position - b.Rotation.FacingCell) : (b.Position + b.Rotation.FacingCell); if (intVec.InBounds(b.Map)) { RoomGroup roomGroup = intVec.GetRoomGroup(b.Map); if (roomGroup != null) { num2 += roomGroup.Temperature; beqRoomGroups[num] = roomGroup; num++; } } } } else { for (int j = 0; j < 4; j++) { IntVec3 intVec2 = b.Position + GenAdj.CardinalDirections[j]; if (intVec2.InBounds(b.Map)) { RoomGroup roomGroup2 = intVec2.GetRoomGroup(b.Map); if (roomGroup2 != null) { num2 += roomGroup2.Temperature; beqRoomGroups[num] = roomGroup2; num++; } } } } if (num != 0) { float num3 = num2 / (float)num; RoomGroup roomGroup3 = b.GetRoomGroup(); if (roomGroup3 != null) { roomGroup3.Temperature = num3; } if (num != 1) { float num4 = 1f; for (int k = 0; k < num; k++) { if (!beqRoomGroups[k].UsesOutdoorTemperature) { float temperature = beqRoomGroups[k].Temperature; float num5 = num3 - temperature; float num6 = num5 * rate; float num7 = num6 / (float)beqRoomGroups[k].CellCount; float num8 = beqRoomGroups[k].Temperature + num7; if (num6 > 0f && num8 > num3) { num8 = num3; } else if (num6 < 0f && num8 < num3) { num8 = num3; } float num9 = Mathf.Abs((num8 - temperature) * (float)beqRoomGroups[k].CellCount / num6); if (num9 < num4) { num4 = num9; } } } for (int l = 0; l < num; l++) { if (!beqRoomGroups[l].UsesOutdoorTemperature) { float temperature2 = beqRoomGroups[l].Temperature; float num10 = num3 - temperature2; float num11 = num10 * rate * num4; float num12 = num11 / (float)beqRoomGroups[l].CellCount; beqRoomGroups[l].Temperature += num12; } } for (int m = 0; m < beqRoomGroups.Length; m++) { beqRoomGroups[m] = null; } } } }
public void Notify_WarmingCastAlongLine(ShootLine newShootLine, IntVec3 ShootPosition) { this.shootSourceOffset = newShootLine.Source - this.pawn.Position; }
public static float GetTemperatureForCell(IntVec3 c, Map map) { TryGetTemperatureForCell(c, map, out float tempResult); return(tempResult); }
public static List <Thing> ThingsUnderMouse(Vector3 clickPos, float pawnWideClickRadius, TargetingParameters clickParams) { IntVec3 c = IntVec3.FromVector3(clickPos); List <Thing> list = new List <Thing>(); GenUI.clickedPawns.Clear(); List <Pawn> allPawnsSpawned = Find.CurrentMap.mapPawns.AllPawnsSpawned; for (int i = 0; i < allPawnsSpawned.Count; i++) { Pawn pawn = allPawnsSpawned[i]; if ((pawn.DrawPos - clickPos).MagnitudeHorizontal() < 0.4f && clickParams.CanTarget(pawn)) { GenUI.clickedPawns.Add(pawn); } } List <Pawn> list2 = GenUI.clickedPawns; if (GenUI.< > f__mg$cache0 == null) { GenUI.< > f__mg$cache0 = new Comparison <Pawn>(GenUI.CompareThingsByDistanceToMousePointer); } list2.Sort(GenUI.< > f__mg$cache0); for (int j = 0; j < GenUI.clickedPawns.Count; j++) { list.Add(GenUI.clickedPawns[j]); } List <Thing> list3 = new List <Thing>(); foreach (Thing thing in Find.CurrentMap.thingGrid.ThingsAt(c)) { if (!list.Contains(thing) && clickParams.CanTarget(thing)) { list3.Add(thing); } } List <Thing> list4 = list3; if (GenUI.< > f__mg$cache1 == null) { GenUI.< > f__mg$cache1 = new Comparison <Thing>(GenUI.CompareThingsByDrawAltitude); } list4.Sort(GenUI.< > f__mg$cache1); list.AddRange(list3); GenUI.clickedPawns.Clear(); List <Pawn> allPawnsSpawned2 = Find.CurrentMap.mapPawns.AllPawnsSpawned; for (int k = 0; k < allPawnsSpawned2.Count; k++) { Pawn pawn2 = allPawnsSpawned2[k]; if ((pawn2.DrawPos - clickPos).MagnitudeHorizontal() < pawnWideClickRadius && clickParams.CanTarget(pawn2)) { GenUI.clickedPawns.Add(pawn2); } } List <Pawn> list5 = GenUI.clickedPawns; if (GenUI.< > f__mg$cache2 == null) { GenUI.< > f__mg$cache2 = new Comparison <Pawn>(GenUI.CompareThingsByDistanceToMousePointer); } list5.Sort(GenUI.< > f__mg$cache2); for (int l = 0; l < GenUI.clickedPawns.Count; l++) { if (!list.Contains(GenUI.clickedPawns[l])) { list.Add(GenUI.clickedPawns[l]); } } list.RemoveAll((Thing t) => !t.Spawned); GenUI.clickedPawns.Clear(); return(list); }
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); }
public ShootLine(IntVec3 source, IntVec3 dest) { this.source = source; this.dest = dest; }
public static List <DamageOverlay> GetAvailableOverlays(Building b) { availableOverlays.Clear(); if (GetScratchMats(b).Any()) { int num = 3; Rect damageRect = GetDamageRect(b); float num2 = damageRect.width * damageRect.height; if (num2 > 4f) { num += Mathf.RoundToInt((num2 - 4f) * 0.54f); } for (int i = 0; i < num; i++) { availableOverlays.Add(DamageOverlay.Scratch); } } if (UsesLinkableCornersAndEdges(b)) { if (b.def.graphicData != null && b.def.graphicData.damageData != null) { IntVec3 position = b.Position; DamageGraphicData damageData = b.def.graphicData.damageData; if (damageData.edgeTopMat != null && DifferentAt(b, position.x, position.z + 1) && SameAndDamagedAt(b, position.x + 1, position.z) && DifferentAt(b, position.x + 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopEdge); } if (damageData.edgeRightMat != null && DifferentAt(b, position.x + 1, position.z) && SameAndDamagedAt(b, position.x, position.z + 1) && DifferentAt(b, position.x + 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.RightEdge); } if (damageData.edgeBotMat != null && DifferentAt(b, position.x, position.z - 1) && SameAndDamagedAt(b, position.x + 1, position.z) && DifferentAt(b, position.x + 1, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotEdge); } if (damageData.edgeLeftMat != null && DifferentAt(b, position.x - 1, position.z) && SameAndDamagedAt(b, position.x, position.z + 1) && DifferentAt(b, position.x - 1, position.z + 1)) { availableOverlays.Add(DamageOverlay.LeftEdge); } if (damageData.cornerTLMat != null && DifferentAt(b, position.x - 1, position.z) && DifferentAt(b, position.x, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (damageData.cornerTRMat != null && DifferentAt(b, position.x + 1, position.z) && DifferentAt(b, position.x, position.z + 1)) { availableOverlays.Add(DamageOverlay.TopRightCorner); } if (damageData.cornerBRMat != null && DifferentAt(b, position.x + 1, position.z) && DifferentAt(b, position.x, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotRightCorner); } if (damageData.cornerBLMat != null && DifferentAt(b, position.x - 1, position.z) && DifferentAt(b, position.x, position.z - 1)) { availableOverlays.Add(DamageOverlay.BotLeftCorner); } } } else { GetCornerMats(out Material topLeft, out Material topRight, out Material botRight, out Material botLeft, b); if (topLeft != null) { availableOverlays.Add(DamageOverlay.TopLeftCorner); } if (topRight != null) { availableOverlays.Add(DamageOverlay.TopRightCorner); } if (botLeft != null) { availableOverlays.Add(DamageOverlay.BotLeftCorner); } if (botRight != null) { availableOverlays.Add(DamageOverlay.BotRightCorner); } } return(availableOverlays); }
private bool CheckForFreeIntercept(IntVec3 c) { if (destination.ToIntVec3() == c) { return(false); } float num = VerbUtility.InterceptChanceFactorFromDistance(origin, c); if (num <= 0f) { return(false); } bool flag = false; List <Thing> thingList = c.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (!CanHit(thing)) { continue; } bool flag2 = false; if (thing.def.Fillage == FillCategory.Full) { Building_Door building_Door = thing as Building_Door; if (building_Door == null || !building_Door.Open) { ThrowDebugText("int-wall", c); Impact(thing); return(true); } flag2 = true; } float num2 = 0f; Pawn pawn = thing as Pawn; if (pawn != null) { num2 = 0.4f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != 0) { num2 *= 0.1f; } if (launcher != null && pawn.Faction != null && launcher.Faction != null && !pawn.Faction.HostileTo(launcher.Faction)) { num2 *= 0.4f; } } else if (thing.def.fillPercent > 0.2f) { num2 = (flag2 ? 0.05f : ((!DestinationCell.AdjacentTo8Way(c)) ? (thing.def.fillPercent * 0.15f) : (thing.def.fillPercent * 1f))); } num2 *= num; if (num2 > 1E-05f) { if (Rand.Chance(num2)) { ThrowDebugText("int-" + num2.ToStringPercent(), c); Impact(thing); return(true); } flag = true; ThrowDebugText(num2.ToStringPercent(), c); } } if (!flag) { ThrowDebugText("o", c); } return(false); }
private static bool <Erode> m__0(IntVec3 x) { return(GenMorphology.cellsSet.Contains(x)); }
private bool CanHitFromCellIgnoringRange(IntVec3 sourceCell, LocalTargetInfo targ, out IntVec3 goodDest) { if (targ.Thing != null) { if (targ.Thing.Map != this.caster.Map) { goodDest = IntVec3.Invalid; return(false); } ShootLeanUtility.CalcShootableCellsOf(Verb.tempDestList, targ.Thing); for (int i = 0; i < Verb.tempDestList.Count; i++) { if (this.CanHitCellFromCellIgnoringRange(sourceCell, Verb.tempDestList[i], targ.Thing.def.Fillage == FillCategory.Full)) { goodDest = Verb.tempDestList[i]; return(true); } } } else if (this.CanHitCellFromCellIgnoringRange(sourceCell, targ.Cell, false)) { goodDest = targ.Cell; return(true); } goodDest = IntVec3.Invalid; return(false); }
private static bool <Dilate> m__1(IntVec3 x) { return(true); }
internal bool <> m__0(IntVec3 x) { return(GenMorphology.cellsSet.Contains(x) && this.extraPredicate(x)); }
public void StartDrag() { this.dragging = true; this.startDragCell = UI.MouseCell(); }