protected override bool TryExecuteWorker(IncidentParms parms) { Faction faction = default(Faction); if (!this.TryFindFaction(out faction)) { return(false); } int tile = default(int); if (!this.TryFindTile(out tile)) { return(false); } PeaceTalks peaceTalks = (PeaceTalks)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.PeaceTalks); peaceTalks.Tile = tile; peaceTalks.SetFaction(faction); ((WorldObject)peaceTalks).GetComponent <TimeoutComp>().StartTimeout(900000); Find.WorldObjects.Add(peaceTalks); string text = string.Format(base.def.letterText.AdjustedFor(faction.leader), faction.def.leaderTitle, faction.Name, 15).CapitalizeFirst(); Find.LetterStack.ReceiveLetter(base.def.letterLabel, text, base.def.letterDef, peaceTalks, null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Faction faction; if (!this.TryFindFaction(out faction)) { return(false); } int tile; if (!this.TryFindTile(out tile)) { return(false); } PeaceTalks peaceTalks = (PeaceTalks)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.PeaceTalks); peaceTalks.Tile = tile; peaceTalks.SetFaction(faction); int randomInRange = SiteTuning.QuestSiteTimeoutDaysRange.RandomInRange; peaceTalks.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000); Find.WorldObjects.Add(peaceTalks); string text = this.def.letterText.Formatted(faction.def.leaderTitle, faction.Name, randomInRange, faction.leader.Named("PAWN")).AdjustedFor(faction.leader, "PAWN").CapitalizeFirst(); Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, this.def.letterDef, peaceTalks, faction, null); return(true); }
public static void DebugDrawSettlement(int from, int to) { PeaceTalks o = (PeaceTalks)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfVehicles.DebugSettlement); o.Tile = from; o.SetFaction(Faction.OfMechanoids); Find.WorldObjects.Add(o); if (VehicleHarmony.drawPaths) { VehicleHarmony.debugLines.Add(Find.WorldPathFinder.FindPath(from, to, null, null)); } }
private static bool TryStartPeaceTalks(Faction faction) { int tile; if (!JecsToolsFactionDialogMaker.TryFindTile(out tile)) { return(false); } PeaceTalks peaceTalks = (PeaceTalks)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.PeaceTalks); peaceTalks.Tile = tile; peaceTalks.SetFaction(faction); peaceTalks.GetComponent <TimeoutComp>().StartTimeout(900000); Find.WorldObjects.Add(peaceTalks); var def = IncidentDef.Named("QuestPeaceTalks"); string text = string.Format(def.letterText.AdjustedFor(faction.leader), faction.def.leaderTitle, faction.Name, 15).CapitalizeFirst(); Find.LetterStack.ReceiveLetter(def.letterLabel, text, def.letterDef, peaceTalks, null); return(true); }
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); }