private void ImpactSomething() { if (this.def.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef != null) { if (roofDef.isThickRoof) { this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); this.Destroy(DestroyMode.Vanish); return; } if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map); } } } if (this.assignedTarget == null) { Projectile.cellThingsFiltered.Clear(); List <Thing> thingList = base.Position.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) { Projectile.cellThingsFiltered.Add(thing); } } Projectile.cellThingsFiltered.Shuffle <Thing>(); for (int j = 0; j < Projectile.cellThingsFiltered.Count; j++) { Thing t = Projectile.cellThingsFiltered[j]; if (Rand.Value < Projectile.ImpactSomethingHitThingChance(t)) { this.Impact(Projectile.cellThingsFiltered.RandomElement <Thing>()); return; } } this.Impact(null); return; } Pawn pawn = this.assignedTarget as Pawn; if (pawn != null && pawn.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f && Rand.Value > 0.2f) { this.Impact(null); return; } this.Impact(this.assignedTarget); }
public void CollapseRoofsMarkedToCollapse() { RoofCollapseBuffer roofCollapseBuffer = map.roofCollapseBuffer; if (!roofCollapseBuffer.CellsMarkedToCollapse.Any()) { return; } tmpCrushedThings.Clear(); RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, map, tmpCrushedThings); if (tmpCrushedThings.Any()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RoofCollapsed".Translate()); stringBuilder.AppendLine(); stringBuilder.AppendLine("TheseThingsCrushed".Translate()); tmpCrushedNames.Clear(); for (int i = 0; i < tmpCrushedThings.Count; i++) { Thing thing = tmpCrushedThings[i]; Corpse corpse; if ((corpse = thing as Corpse) == null || !corpse.Bugged) { string item = thing.LabelShortCap; if (thing.def.category == ThingCategory.Pawn) { item = thing.LabelCap; } if (!tmpCrushedNames.Contains(item)) { tmpCrushedNames.Add(item); } } } foreach (string tmpCrushedName in tmpCrushedNames) { stringBuilder.AppendLine(" -" + tmpCrushedName); } Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], map)); } else { Messages.Message("RoofCollapsed".Translate(), new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], map), MessageTypeDefOf.SilentInput); } tmpCrushedThings.Clear(); roofCollapseBuffer.Clear(); }
public void CollapseRoofsMarkedToCollapse() { RoofCollapseBuffer roofCollapseBuffer = this.map.roofCollapseBuffer; if (roofCollapseBuffer.CellsMarkedToCollapse.Any <IntVec3>()) { this.tmpCrushedThings.Clear(); RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, this.map, this.tmpCrushedThings); if (this.tmpCrushedThings.Any <Thing>()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RoofCollapsed".Translate()); stringBuilder.AppendLine(); stringBuilder.AppendLine("TheseThingsCrushed".Translate()); this.tmpCrushedNames.Clear(); for (int i = 0; i < this.tmpCrushedThings.Count; i++) { Thing thing = this.tmpCrushedThings[i]; string item = thing.LabelShort.CapitalizeFirst(); if (thing.def.category == ThingCategory.Pawn) { item = thing.LabelCap; } if (!this.tmpCrushedNames.Contains(item)) { this.tmpCrushedNames.Add(item); } } foreach (string str in this.tmpCrushedNames) { stringBuilder.AppendLine(" -" + str); } Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString().TrimEndNewlines(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), null, null); } else { string text = "RoofCollapsed".Translate(); Messages.Message(text, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), MessageTypeDefOf.SilentInput, true); } this.tmpCrushedThings.Clear(); roofCollapseBuffer.Clear(); } }
public void CollapseRoofsMarkedToCollapse() { RoofCollapseBuffer roofCollapseBuffer = this.map.roofCollapseBuffer; if (roofCollapseBuffer.CellsMarkedToCollapse.Count > 0) { RoofCollapserImmediate.DropRoofInCells(roofCollapseBuffer.CellsMarkedToCollapse, this.map); if (roofCollapseBuffer.CrushedThingsForLetter.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("RoofCollapsed".Translate()); stringBuilder.AppendLine(); stringBuilder.AppendLine("TheseThingsCrushed".Translate()); HashSet <string> hashSet = new HashSet <string>(); foreach (Thing item2 in roofCollapseBuffer.CrushedThingsForLetter) { string item = item2.LabelShort.CapitalizeFirst(); if (item2.def.category == ThingCategory.Pawn) { item = item2.LabelCap; } if (!hashSet.Contains(item)) { hashSet.Add(item); } } foreach (string item3 in hashSet) { stringBuilder.AppendLine(" -" + item3); } Find.LetterStack.ReceiveLetter("LetterLabelRoofCollapsed".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), null); } else { string text = "RoofCollapsed".Translate(); Messages.Message(text, new TargetInfo(roofCollapseBuffer.CellsMarkedToCollapse[0], this.map, false), MessageTypeDefOf.NegativeHealthEvent); } roofCollapseBuffer.Clear(); } }
private void ImpactSomething() { if (this.def.projectile.flyOverhead) { RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position); if (roofDef != null) { if (roofDef.isThickRoof) { this.ThrowDebugText("hit-thick-roof", base.Position); this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false)); this.Destroy(DestroyMode.Vanish); return; } if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full) { RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null); } } } if (!this.usedTarget.HasThing || !this.CanHit(this.usedTarget.Thing)) { Projectile.cellThingsFiltered.Clear(); List <Thing> thingList = base.Position.GetThingList(base.Map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if ((thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && this.CanHit(thing)) { Projectile.cellThingsFiltered.Add(thing); } } Projectile.cellThingsFiltered.Shuffle <Thing>(); for (int j = 0; j < Projectile.cellThingsFiltered.Count; j++) { Thing thing2 = Projectile.cellThingsFiltered[j]; Pawn pawn = thing2 as Pawn; float num; if (pawn != null) { num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f); if (pawn.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f) { num *= 0.2f; } if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !pawn.Faction.HostileTo(this.launcher.Faction)) { num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position); } } else { num = 1.5f * thing2.def.fillPercent; } if (Rand.Chance(num)) { this.ThrowDebugText("hit-" + num.ToStringPercent(), base.Position); this.Impact(Projectile.cellThingsFiltered.RandomElement <Thing>()); return; } this.ThrowDebugText("miss-" + num.ToStringPercent(), base.Position); } this.Impact(null); return; } Pawn pawn2 = this.usedTarget.Thing as Pawn; if (pawn2 != null && pawn2.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f && !Rand.Chance(0.2f)) { this.ThrowDebugText("miss-laying", base.Position); this.Impact(null); return; } this.Impact(this.usedTarget.Thing); }