private static void MakeFilthx100() { for (int i = 0; i < 100; i++) { IntVec3 c = UI.MouseCell() + GenRadial.RadialPattern[i]; if (c.InBounds(Find.CurrentMap) && c.Walkable(Find.CurrentMap)) { FilthMaker.TryMakeFilth(c, Find.CurrentMap, ThingDefOf.Filth_Dirt, 2); MoteMaker.ThrowMetaPuff(c.ToVector3Shifted(), Find.CurrentMap); } } }
public static float InterceptChanceFactorFromDistance(Vector3 origin, IntVec3 c) { float num = (c.ToVector3Shifted() - origin).MagnitudeHorizontalSquared(); if (num <= 25f) { return(0f); } if (num >= 144f) { return(1f); } return(Mathf.InverseLerp(25f, 144f, num)); }
public void ChangeDestToMissWild(float aimOnChance) { float num = ShootTuning.MissDistanceFromAimOnChanceCurves.Evaluate(aimOnChance, Rand.Value); if (num < 0f) { Log.ErrorOnce("Attempted to wild-miss less than zero tiles away", 94302089); } IntVec3 a; do { Vector2 unitVector = Rand.UnitVector2; Vector3 b = new Vector3(unitVector.x * num, 0f, unitVector.y * num); a = (dest.ToVector3Shifted() + b).ToIntVec3(); }while (Vector3.Dot((dest - source).ToVector3(), (a - source).ToVector3()) < 0f); dest = a; }
public static float DistanceInterceptChance(Vector3 origin, IntVec3 c, IntVec3 intendedTargetCell) { float num = (c.ToVector3Shifted() - origin).MagnitudeHorizontalSquared(); float num2 = (intendedTargetCell.ToVector3Shifted() - origin).MagnitudeHorizontalSquared(); float result; if (num < 16f && num < num2 && c != intendedTargetCell) { result = 0f; } else if (num < 49f) { result = 0.5f; } else if (num < 100f) { result = 0.75f; } else { result = 1f; } return(result); }
public void UpdateRotation() { if (!this.pawn.Destroyed && !this.pawn.jobs.HandlingFacing) { if (this.pawn.pather.Moving) { if (this.pawn.pather.curPath != null && this.pawn.pather.curPath.NodesLeftCount >= 1) { this.FaceAdjacentCell(this.pawn.pather.nextCell); } } else { Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { this.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { this.FaceCell(stance_Busy.focusTarg.Cell); } } else { if (this.pawn.jobs.curJob != null) { LocalTargetInfo target = this.pawn.CurJob.GetTarget(this.pawn.jobs.curDriver.rotateToFace); if (target.HasThing) { bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = target.Thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (this.pawn.Position == new IntVec3(j, 0, i)) { this.Face(target.Thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(this.pawn.Position)) { this.FaceAdjacentCell(intVec); return; } if (intVec.AdjacentTo8Way(this.pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.6f, "jbthing", 50); GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } this.FaceAdjacentCell(c); } else { this.Face(target.Thing.DrawPos); } return; } if (this.pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.2f, "jbloc", 50); GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } this.FaceAdjacentCell(target.Cell); return; } if (target.Cell.IsValid && target.Cell != this.pawn.Position) { this.Face(target.Cell.ToVector3()); return; } } if (this.pawn.Drafted) { this.pawn.Rotation = Rot4.South; } } } } }
public void FaceTarget(LocalTargetInfo target) { if (target.IsValid) { if (target.HasThing) { Thing thing = (!target.Thing.Spawned) ? ThingOwnerUtility.GetFirstSpawnedParentThing(target.Thing) : target.Thing; if (thing != null && thing.Spawned) { bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (pawn.Position == new IntVec3(j, 0, i)) { Face(thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(pawn.Position)) { FaceAdjacentCell(intVec); return; } if (intVec.AdjacentTo8Way(pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } FaceAdjacentCell(c); } else { Face(thing.DrawPos); } } } else if (pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } FaceAdjacentCell(target.Cell); } else if (target.Cell.IsValid && target.Cell != pawn.Position) { Face(target.Cell.ToVector3()); } } }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef == null) { return; } if (roofDef.collapseLeavingThingDef != null && roofDef.collapseLeavingThingDef.passability == Traversability.Impassable) { for (int i = 0; i < 2; i++) { List <Thing> thingList = c.GetThingList(map); for (int j = thingList.Count - 1; j >= 0; j--) { Thing thing = thingList[j]; RoofCollapserImmediate.TryAddToCrushedThingsList(thing, outCrushedThings); Pawn pawn = thing as Pawn; DamageInfo dinfo; if (pawn != null) { DamageDef crush = DamageDefOf.Crush; float amount = 99999f; float armorPenetration = 999f; BodyPartRecord brain = pawn.health.hediffSet.GetBrain(); dinfo = new DamageInfo(crush, amount, armorPenetration, -1f, null, brain, null, DamageInfo.SourceCategory.Collapse, null); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null); 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).AssociateWithLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Kill(new DamageInfo?(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null)), null); } } } } else { List <Thing> thingList2 = c.GetThingList(map); for (int k = thingList2.Count - 1; k >= 0; k--) { Thing thing2 = thingList2[k]; if (thing2.def.category == ThingCategory.Item || thing2.def.category == ThingCategory.Plant || thing2.def.category == ThingCategory.Building || thing2.def.category == ThingCategory.Pawn) { RoofCollapserImmediate.TryAddToCrushedThingsList(thing2, outCrushedThings); float num = (float)RoofCollapserImmediate.ThinRoofCrushDamageRange.RandomInRange; if (thing2.def.building != null) { num *= thing2.def.building.roofCollapseDamageMultiplier; } BattleLogEntry_DamageTaken battleLogEntry_DamageTaken2 = null; if (thing2 is Pawn) { battleLogEntry_DamageTaken2 = new BattleLogEntry_DamageTaken((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling, null); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, (float)GenMath.RoundRandom(num), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse, null); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_DamageTaken2); } } } if (roofDef.collapseLeavingThingDef != null) { Thing thing3 = GenSpawn.Spawn(roofDef.collapseLeavingThingDef, c, map, WipeMode.Vanish); if (thing3.def.rotatable) { thing3.Rotation = Rot4.Random; } } for (int l = 0; l < 1; l++) { Vector3 vector = c.ToVector3Shifted(); vector += Gen.RandomHorizontalVector(0.6f); MoteMaker.ThrowDustPuff(vector, map, 2f); } }
private bool CheckForFreeIntercept(IntVec3 c) { float num = (c.ToVector3Shifted() - this.origin).MagnitudeHorizontalSquared(); if (num < 16f) { return(false); } List <Thing> list = base.Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing != this.ThingToNeverIntercept) { if (thing != this.launcher) { if (thing.def.Fillage == FillCategory.Full && this.InterceptWalls) { this.Impact(thing); return(true); } if (this.FreeIntercept) { float num2 = 0f; Pawn pawn = thing as Pawn; if (pawn != null) { num2 = 0.4f; 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; } num2 *= Mathf.Clamp(pawn.BodySize, 0.1f, 2f); } else if (thing.def.fillPercent > 0.2f) { num2 = thing.def.fillPercent * 0.07f; } if (num2 > 1E-05f) { if (num < 49f) { num2 *= 0.5f; } else if (num < 100f) { num2 *= 0.75f; } if (DebugViewSettings.drawShooting) { MoteMaker.ThrowText(this.ExactPosition, base.Map, num2.ToStringPercent(), -1f); } if (Rand.Value < num2) { this.Impact(thing); return(true); } } } } } } return(false); }
private bool CheckForFreeInterceptBetween(Vector3 lastExactPos, Vector3 newExactPos) { 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)) { bool flag = this.CheckForFreeIntercept(intVec2); if (DebugViewSettings.drawInterceptChecks) { if (flag) { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), base.Map, "x", -1f); } else { MoteMaker.ThrowText(intVec2.ToVector3Shifted(), base.Map, "o", -1f); } } return(flag); } if ((float)this.origin.ToIntVec3().DistanceToSquared(intVec2) > 16f) { 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; while (true) { vector += b; IntVec3 intVec3 = vector.ToIntVec3(); if (!Projectile.checkedCells.Contains(intVec3)) { if (this.CheckForFreeIntercept(intVec3)) { break; } Projectile.checkedCells.Add(intVec3); } if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, base.Map, "o", -1f); } num2++; if (num2 > num) { return(false); } if (intVec3 == intVec2) { return(false); } } if (DebugViewSettings.drawInterceptChecks) { MoteMaker.ThrowText(vector, base.Map, "x", -1f); } return(true); } return(false); }
private static void DropRoofInCellPhaseOne(IntVec3 c, Map map, List <Thing> outCrushedThings) { RoofDef roofDef = map.roofGrid.RoofAt(c); if (roofDef == null) { return; } 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]; TryAddToCrushedThingsList(thing, outCrushedThings); Pawn pawn = thing as Pawn; DamageInfo dinfo; if (pawn != null) { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, pawn.health.hediffSet.GetBrain(), null, DamageInfo.SourceCategory.Collapse); } else { dinfo = new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -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); Find.BattleLog.Add(battleLogEntry_DamageTaken); } thing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_DamageTaken); if (!thing.Destroyed && thing.def.destroyable) { thing.Kill(new DamageInfo(DamageDefOf.Crush, 99999f, 999f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse)); } } } } 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) { TryAddToCrushedThingsList(thing2, outCrushedThings); float num3 = 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((Pawn)thing2, RulePackDefOf.DamageEvent_Ceiling); Find.BattleLog.Add(battleLogEntry_DamageTaken2); } DamageInfo dinfo2 = new DamageInfo(DamageDefOf.Crush, GenMath.RoundRandom(num3), 0f, -1f, null, null, null, DamageInfo.SourceCategory.Collapse); dinfo2.SetBodyRegion(BodyPartHeight.Top, BodyPartDepth.Outside); thing2.TakeDamage(dinfo2).AssociateWithLog(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++) { MoteMaker.ThrowDustPuff(c.ToVector3Shifted() + Gen.RandomHorizontalVector(0.6f), map, 2f); } }
public void JumpToCurrentMapLoc(IntVec3 cell) { this.JumpToCurrentMapLoc(cell.ToVector3Shifted()); }
public void JumpToVisibleMapLoc(IntVec3 cell) { this.JumpToVisibleMapLoc(cell.ToVector3Shifted()); }
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 FlashLine(IntVec3 a, IntVec3 b, int duration = 50, SimpleColor color = SimpleColor.White) { this.debugLines.Add(new DebugLine(a.ToVector3Shifted(), b.ToVector3Shifted(), duration, color)); }