public override void Cleanup() { base.Cleanup(); if (!keepAfterQuestEnds) { TradeRequestComp component = settlement.GetComponent <TradeRequestComp>(); if (component != null && component.ActiveRequest) { component.Disable(); } } }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (signal.tag == inSignal) { TradeRequestComp component = settlement.GetComponent <TradeRequestComp>(); if (component != null && component.ActiveRequest) { component.Disable(); } } }
public void Notify_RelationKindChanged(Faction other, FactionRelationKind previousKind, bool canSendLetter, string reason, GlobalTargetInfo lookTarget, out bool sentLetter) { if (Current.ProgramState != ProgramState.Playing || other != Faction.OfPlayer) { canSendLetter = false; } sentLetter = false; FactionRelationKind factionRelationKind = this.RelationKindWith(other); if (factionRelationKind == FactionRelationKind.Hostile && Current.ProgramState == ProgramState.Playing) { foreach (Pawn current in PawnsFinder.AllMapsWorldAndTemporary_Alive.ToList <Pawn>()) { if ((current.Faction == this && current.HostFaction == other) || (current.Faction == other && current.HostFaction == this)) { current.guest.SetGuestStatus(current.HostFaction, true); } } } if (other == Faction.OfPlayer && !this.HostileTo(Faction.OfPlayer)) { List <Site> list = new List <Site>(); List <Site> sites = Find.WorldObjects.Sites; for (int i = 0; i < sites.Count; i++) { if (sites[i].factionMustRemainHostile && sites[i].Faction == this && !sites[i].HasMap) { list.Add(sites[i]); } } if (list.Any <Site>()) { string label; string text; if (list.Count == 1) { label = "LetterLabelSiteNoLongerHostile".Translate(); text = "LetterSiteNoLongerHostile".Translate(new object[] { this.Name, list[0].Label }); } else { StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < list.Count; j++) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.Append(" - " + list[j].LabelCap); ImportantPawnComp component = list[j].GetComponent <ImportantPawnComp>(); if (component != null && component.pawn.Any) { stringBuilder.Append(" (" + component.pawn[0].LabelCap + ")"); } } label = "LetterLabelSiteNoLongerHostileMulti".Translate(); text = "LetterSiteNoLongerHostileMulti".Translate(new object[] { this.Name }) + ":\n\n" + stringBuilder; } Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new LookTargets(from x in list select new GlobalTargetInfo(x.Tile)), null, null); for (int k = 0; k < list.Count; k++) { Find.WorldObjects.Remove(list[k]); } } } if (other == Faction.OfPlayer && this.HostileTo(Faction.OfPlayer)) { List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects; for (int l = 0; l < allWorldObjects.Count; l++) { if (allWorldObjects[l].Faction == this) { TradeRequestComp component2 = allWorldObjects[l].GetComponent <TradeRequestComp>(); if (component2 != null && component2.ActiveRequest) { component2.Disable(); } } } } if (canSendLetter) { string empty = string.Empty; this.TryAppendRelationKindChangedInfo(ref empty, previousKind, factionRelationKind, reason); if (factionRelationKind == FactionRelationKind.Hostile) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_Hostile".Translate(new object[] { this.name }), empty, LetterDefOf.NegativeEvent, lookTarget, this, null); sentLetter = true; } else if (factionRelationKind == FactionRelationKind.Ally) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_Ally".Translate(new object[] { this.name }), empty, LetterDefOf.PositiveEvent, lookTarget, this, null); sentLetter = true; } else if (factionRelationKind == FactionRelationKind.Neutral) { if (previousKind == FactionRelationKind.Hostile) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_NeutralFromHostile".Translate(new object[] { this.name }), empty, LetterDefOf.PositiveEvent, lookTarget, this, null); sentLetter = true; } else { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_NeutralFromAlly".Translate(new object[] { this.name }), empty, LetterDefOf.NeutralEvent, lookTarget, this, null); sentLetter = true; } } } if (Current.ProgramState == ProgramState.Playing) { List <Map> maps = Find.Maps; for (int m = 0; m < maps.Count; m++) { maps[m].attackTargetsCache.Notify_FactionHostilityChanged(this, other); LordManager lordManager = maps[m].lordManager; for (int n = 0; n < lordManager.lords.Count; n++) { Lord lord = lordManager.lords[n]; if (lord.faction == other) { lord.Notify_FactionRelationsChanged(this, previousKind); } else if (lord.faction == this) { lord.Notify_FactionRelationsChanged(other, previousKind); } } } } }
public void Notify_RelationKindChanged(Faction other, FactionRelationKind previousKind, bool canSendLetter, string reason, GlobalTargetInfo lookTarget, out bool sentLetter) { if (Current.ProgramState != ProgramState.Playing || other != OfPlayer) { canSendLetter = false; } sentLetter = false; ColoredText.ClearCache(); FactionRelationKind factionRelationKind = RelationKindWith(other); if (factionRelationKind == FactionRelationKind.Hostile) { if (Current.ProgramState == ProgramState.Playing) { foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_Alive.ToList()) { if ((item.Faction == this && item.HostFaction == other) || (item.Faction == other && item.HostFaction == this)) { item.guest.SetGuestStatus(item.HostFaction, prisoner: true); } } } if (other == OfPlayer) { QuestUtility.SendQuestTargetSignals(questTags, "BecameHostileToPlayer", this.Named("SUBJECT")); } } if (other == OfPlayer && !this.HostileTo(OfPlayer)) { List <Site> list = new List <Site>(); List <Site> sites = Find.WorldObjects.Sites; for (int i = 0; i < sites.Count; i++) { if (sites[i].factionMustRemainHostile && sites[i].Faction == this && !sites[i].HasMap) { list.Add(sites[i]); } } if (list.Any()) { string str; string str2; if (list.Count == 1) { str = "LetterLabelSiteNoLongerHostile".Translate(); str2 = "LetterSiteNoLongerHostile".Translate(NameColored, list[0].Label); } else { StringBuilder stringBuilder = new StringBuilder(); for (int j = 0; j < list.Count; j++) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.Append(" - " + list[j].LabelCap); ImportantPawnComp component = list[j].GetComponent <ImportantPawnComp>(); if (component != null && component.pawn.Any) { stringBuilder.Append(" (" + component.pawn[0].LabelCap + ")"); } } str = "LetterLabelSiteNoLongerHostileMulti".Translate(); str2 = (string)("LetterSiteNoLongerHostileMulti".Translate(NameColored) + ":\n\n") + stringBuilder; } Find.LetterStack.ReceiveLetter(str, str2, LetterDefOf.NeutralEvent, new LookTargets(list.Select((Site x) => new GlobalTargetInfo(x.Tile)))); for (int k = 0; k < list.Count; k++) { list[k].Destroy(); } } } if (other == OfPlayer && this.HostileTo(OfPlayer)) { List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects; for (int l = 0; l < allWorldObjects.Count; l++) { if (allWorldObjects[l].Faction == this) { TradeRequestComp component2 = allWorldObjects[l].GetComponent <TradeRequestComp>(); if (component2 != null && component2.ActiveRequest) { component2.Disable(); } } } foreach (Map map in Find.Maps) { map.passingShipManager.RemoveAllShipsOfFaction(this); } } if (canSendLetter) { TaggedString text = ""; TryAppendRelationKindChangedInfo(ref text, previousKind, factionRelationKind, reason); switch (factionRelationKind) { case FactionRelationKind.Hostile: Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_Hostile".Translate(Name), text, LetterDefOf.NegativeEvent, lookTarget, this); sentLetter = true; break; case FactionRelationKind.Ally: Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_Ally".Translate(Name), text, LetterDefOf.PositiveEvent, lookTarget, this); sentLetter = true; break; case FactionRelationKind.Neutral: if (previousKind == FactionRelationKind.Hostile) { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_NeutralFromHostile".Translate(Name), text, LetterDefOf.PositiveEvent, lookTarget, this); sentLetter = true; } else { Find.LetterStack.ReceiveLetter("LetterLabelRelationsChange_NeutralFromAlly".Translate(Name), text, LetterDefOf.NeutralEvent, lookTarget, this); sentLetter = true; } break; } } if (Current.ProgramState != ProgramState.Playing) { return; } List <Map> maps = Find.Maps; for (int m = 0; m < maps.Count; m++) { maps[m].attackTargetsCache.Notify_FactionHostilityChanged(this, other); LordManager lordManager = maps[m].lordManager; for (int n = 0; n < lordManager.lords.Count; n++) { Lord lord = lordManager.lords[n]; if (lord.faction == other) { lord.Notify_FactionRelationsChanged(this, previousKind); } else if (lord.faction == this) { lord.Notify_FactionRelationsChanged(other, previousKind); } } } }