public static void AlliedBooom(int destinationTile, IntVec3 targetCell) { if (!Find.WorldObjects.AnyMapParentAt(destinationTile)) { Messages.Message("SWeaponDestoryBase".Translate(), MessageTypeDefOf.NeutralEvent, true); SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(null); WorldObject worldObject = Find.WorldObjects.WorldObjectAt <WorldObject>(destinationTile); if (worldObject != null && worldObject.Faction != null && !worldObject.Faction.IsPlayer) { worldObject.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null); } PeaceTalks peaceTalks = Find.WorldObjects.WorldObjectAt <PeaceTalks>(destinationTile); if (peaceTalks != null) { try { peaceTalks.GetType().GetMethod("Outcome_Disaster", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(peaceTalks, null); } catch (Exception) { } Find.WorldObjects.Remove(peaceTalks); } return; } MapParent mapParent = Find.WorldObjects.MapParentAt(destinationTile); if (mapParent.Faction != null && !mapParent.Faction.IsPlayer) { mapParent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null); } if (mapParent.HasMap) { AlliedStormCondition asc = (AlliedStormCondition)ThingMaker.MakeThing(ThingDef.Named("AlliedStorm"), null); asc.centerLocation = targetCell.ToIntVec2; asc.SingleMap = mapParent.Map; SoundInfo info = SoundInfo.InMap(new TargetInfo(asc.centerLocation.ToIntVec3, asc.SingleMap, false), MaintenanceType.None); SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(mapParent.Map);//.PlayOneShot(info); // SovietNuclearFallen bomb = (SovietNuclearFallen)ThingMaker.MakeThing(ThingDef.Named("SovietNuclearFallen")); // bomb.targetCell = targetCell; // bomb.ExactPosition = new Vector3(targetCell.x, 10, mapParent.Map.Size.z - 10); GenSpawn.Spawn(asc, asc.centerLocation.ToIntVec3, mapParent.Map); return; } Messages.Message("SWeaponDestoryBase".Translate(), mapParent, MessageTypeDefOf.NegativeEvent, true); SoundDef.Named("ra2_StormAppear").PlayOneShotOnCamera(null); SettlementBase settlementBase; if ((settlementBase = (mapParent as SettlementBase)) != null) { if (settlementBase.Faction == Faction.OfPlayer) { return; } foreach (Faction faction in Find.FactionManager.AllFactionsListForReading) { if (faction != Faction.OfPlayer) { faction.TryAffectGoodwillWith(Faction.OfPlayer, -10, true, true, null, null); } } try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("LetterFactionBaseDefeated".Translate(new object[] { settlementBase.Label, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000) })); Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(settlementBase.Tile), null, null); DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement); destroyedSettlement.Tile = settlementBase.Tile; Find.WorldObjects.Add(destroyedSettlement); } catch (Exception) { Log.Warning("Failed to end settlement", false); } } Find.WorldObjects.Remove(mapParent); }
// Token: 0x04001627 RID: 5671 public void Booom() { if (!Find.WorldObjects.AnyMapParentAt(this.destinationTile)) { Messages.Message("SWeaponDestoryBase".Translate(), MessageTypeDefOf.NeutralEvent, true); // DubDef.hugeExplosionDistantDef.PlayOneShotOnCamera(null); WorldObject worldObject = Find.WorldObjects.WorldObjectAt <WorldObject>(this.destinationTile); if (worldObject != null && worldObject.Faction != null && !worldObject.Faction.IsPlayer) { worldObject.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null); } PeaceTalks peaceTalks = Find.WorldObjects.WorldObjectAt <PeaceTalks>(this.destinationTile); if (peaceTalks != null) { try { peaceTalks.GetType().GetMethod("Outcome_Disaster", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(peaceTalks, null); } catch (Exception) { } Find.WorldObjects.Remove(peaceTalks); } return; } this.mapParent = Find.WorldObjects.MapParentAt(this.destinationTile); if (this.mapParent.Faction != null && !this.mapParent.Faction.IsPlayer) { this.mapParent.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -999, true, true, null, null); } /* * if (this.mapParent is DestroyedSettlement) * { * Messages.Message("critBombDet".Translate(), MessageTypeDefOf.NeutralEvent, true); * // DubDef.hugeExplosionDistantDef.PlayOneShotOnCamera(null); * return; * } */ if (this.mapParent.HasMap) { //IntVec3 destinationCell = CellFinderLoose.TryFindCentralCell(this.mapParent.Map, 25, 1000, null); // SkyfallerMaker.SpawnSkyfaller(ThingDef.Named("NuclearIncoming"), ThingDef.Named("SovietNuclearStrike"), destinationCell, this.mapParent.Map); SovietNuclearFallen bomb = (SovietNuclearFallen)ThingMaker.MakeThing(ThingDef.Named("SovietNuclearFallen")); bomb.targetCell = this.targetCell; bomb.ExactPosition = new Vector3(this.targetCell.x, 10, this.mapParent.Map.Size.z - 10); GenSpawn.Spawn(bomb, bomb.ExactPosition.ToIntVec3(), this.mapParent.Map); return; } Messages.Message("SWeaponDestoryBase".Translate(), this.mapParent, MessageTypeDefOf.NegativeEvent, true); SoundDef.Named("ra2_NuclearExplode").PlayOneShotOnCamera(null); SettlementBase settlementBase; if ((settlementBase = (this.mapParent as SettlementBase)) != null) { if (settlementBase.Faction == Faction.OfPlayer) { return; } foreach (Faction faction in Find.FactionManager.AllFactionsListForReading) { if (faction != Faction.OfPlayer) { faction.TryAffectGoodwillWith(Faction.OfPlayer, -10, true, true, null, null); } } try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("LetterFactionBaseDefeated".Translate(new object[] { settlementBase.Label, TimedForcedExit.GetForceExitAndRemoveMapCountdownTimeLeftString(60000) })); Find.LetterStack.ReceiveLetter("LetterLabelFactionBaseDefeated".Translate(), stringBuilder.ToString(), LetterDefOf.PositiveEvent, new GlobalTargetInfo(settlementBase.Tile), null, null); DestroyedSettlement destroyedSettlement = (DestroyedSettlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.DestroyedSettlement); destroyedSettlement.Tile = settlementBase.Tile; Find.WorldObjects.Add(destroyedSettlement); } catch (Exception) { Log.Warning("Failed to end settlement", false); } } Find.WorldObjects.Remove(this.mapParent); }