public override void PostEnd() { if (!this.def.recoveryMessage.NullOrEmpty() && PawnUtility.ShouldSendNotificationAbout(this.pawn)) { TaggedString taggedString = this.def.recoveryMessage.Formatted(this.pawn.LabelShort, this.pawn.Named("PAWN")); if (!taggedString.NullOrEmpty()) { Messages.Message(taggedString.AdjustedFor(this.pawn, "PAWN", true).CapitalizeFirst(), this.pawn, MessageTypeDefOf.SituationResolved, true); } } this.pawn.jobs.StopAll(false, true); this.pawn.mindState.meleeThreat = null; if (this.IsOtherPawnSocialFightingWithMe) { this.otherPawn.MentalState.RecoverFromState(); } if ((PawnUtility.ShouldSendNotificationAbout(this.pawn) || PawnUtility.ShouldSendNotificationAbout(this.otherPawn)) && this.pawn.thingIDNumber < this.otherPawn.thingIDNumber) { Messages.Message("AdeptusMechanicus.Ork.MessageNoLongerSocialFighting".Translate(this.pawn.LabelShort, this.otherPawn.LabelShort, this.pawn.Named("PAWN1"), this.otherPawn.Named("PAWN2")), this.pawn, MessageTypeDefOf.SituationResolved, true); } if (!this.pawn.Dead && this.pawn.needs.mood != null && !this.otherPawn.Dead) { ThoughtDef def; if (pawn.isOrk()) { def = ThoughtDefOf.HadCatharticFight; } else { def = ThoughtDefOf.HadAngeringFight; } this.pawn.needs.mood.thoughts.memories.TryGainMemory(def, this.otherPawn); } }
public static bool Prefix(IncidentWorker_RaidEnemy __instance, IncidentParms parms) { var options = Find.Storyteller.def.GetModExtension <StorytellerDefExtension>(); if (options != null && options.storytellerThreat != null && options.storytellerThreat.raidWarningRange.HasValue) { var comp = Current.Game.GetComponent <StorytellerWatcher>(); if (comp != null && !comp.raidQueues.Where(x => x.parms == parms).Any() && parms.target is Map mapTarget) { var tickToFire = Find.TickManager.TicksAbs + options.storytellerThreat.raidWarningRange.Value.RandomInRange; if (__instance.TryResolveRaidFaction(parms)) { __instance.ResolveRaidStrategy(parms, PawnGroupKindDefOf.Combat); __instance.ResolveRaidArriveMode(parms); var raidQueue = new RaidQueue(__instance.def, parms, tickToFire); comp.raidQueues.Add(raidQueue); TaggedString letterLabel = "VFEMech.RaidWarningTitle".Translate(parms.faction.Named("FACTION")); TaggedString letterText = "VFEMech.RaidWarningText".Translate(parms.faction.Named("FACTION"), parms.raidStrategy.arrivalTextEnemy); Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig); return(false); } } } return(true); }
public static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { var options = thingList[i].def.GetModExtension <HeavyWeapon>(); if (options != null && options.isHeavy) { var equipment = (ThingWithComps)thingList[i]; TaggedString toCheck = "Equip".Translate(equipment.LabelShort); FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains(toCheck)); if (floatMenuOption != null && !CanEquip(pawn, options)) { opts.Remove(floatMenuOption); opts.Add(new FloatMenuOption("CannotEquip".Translate(equipment.LabelShort) + " (" + options.disableOptionLabelKey.Translate(pawn.LabelShort) + ")", null)); } break; } } } }
protected virtual void ApplyOutcome(float progress) { if (progress < 0.5f) { Find.LetterStack.ReceiveLetter("LetterLabelSpeechCancelled".Translate(), "LetterSpeechCancelled".Translate(organizer.Named("ORGANIZER")).CapitalizeFirst(), LetterDefOf.NegativeEvent, organizer); return; } ThoughtDef key = OutcomeThoughtChances.RandomElementByWeight((KeyValuePair <ThoughtDef, float> t) => (!PositiveOutcome(t.Key)) ? OutcomeThoughtChances[t.Key] : (OutcomeThoughtChances[t.Key] * organizer.GetStatValue(StatDefOf.SocialImpact) * progress)).Key; foreach (Pawn ownedPawn in lord.ownedPawns) { if (ownedPawn != organizer && organizer.Position.InHorDistOf(ownedPawn.Position, 18f)) { ownedPawn.needs.mood.thoughts.memories.TryGainMemory(key, organizer); } } TaggedString text = "LetterFinishedSpeech".Translate(organizer.Named("ORGANIZER")).CapitalizeFirst() + " " + ("Letter" + key.defName).Translate(); if (progress < 1f) { text += "\n\n" + "LetterSpeechInterrupted".Translate(progress.ToStringPercent(), organizer.Named("ORGANIZER")); } Find.LetterStack.ReceiveLetter(key.stages[0].LabelCap, text, PositiveOutcome(key) ? LetterDefOf.PositiveEvent : LetterDefOf.NegativeEvent, organizer); Ability ability = organizer.abilities.GetAbility(AbilityDefOf.Speech); RoyalTitle mostSeniorTitle = organizer.royalty.MostSeniorTitle; if (ability != null && mostSeniorTitle != null) { ability.StartCooldown(mostSeniorTitle.def.speechCooldown.RandomInRange); } }
private static void DrawOrders(Listing listing, TaggedString label, [NotNull] IReadOnlyCollection <Order> orders) { // Label var rect = CustomLabelDouble(listing, label, $"{orders.Count}: ", out var countSize); var grouped = orders.GroupBy(o => o.consumableDef); var rectImage = rect.RightHalf(); rectImage.xMin += countSize.x; rectImage.width = rectImage.height = countSize.y; // Icons for each type of order foreach (var group in grouped) { if (group.Key == null) { continue; } // A list of the patrons for the order DrawDefIcon(rectImage, group.Key, $"{group.Key.LabelCap}: {group.Select(o => o.patron.Name.ToStringShort).ToCommaList()}"); rectImage.x += 2 + rectImage.width; // Will the next one fit? if (rectImage.xMax > rect.xMax) { break; } } listing.Gap(listing.verticalSpacing); }
public void JustCreatedBy(Pawn pawn) { if (CanShowArt) { authorNameInt = pawn.NameFullColored; } }
public static void Message(TaggedString message) { if (ColonyGroupsHotkeys.Instance?.settings.beQuiet != true) { Messages.Message(message, MessageTypeDefOf.SilentInput); } }
public static void DrawCaravanInfo(CaravanInfo info, CaravanInfo?info2, int currentTile, int?ticksToArrive, float lastMassFlashTime, Rect rect, bool lerpMassColor = true, string extraDaysWorthOfFoodTipInfo = null, bool multiline = false) { tmpInfo.Clear(); TaggedString taggedString = info.massUsage.ToStringEnsureThreshold(info.massCapacity, 0) + " / " + info.massCapacity.ToString("F0") + " " + "kg".Translate(); TaggedString taggedString2 = info2.HasValue ? (info2.Value.massUsage.ToStringEnsureThreshold(info2.Value.massCapacity, 0) + " / " + info2.Value.massCapacity.ToString("F0") + " " + "kg".Translate()) : ((TaggedString)null); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Mass".Translate(), taggedString, GetMassColor(info.massUsage, info.massCapacity, lerpMassColor), GetMassTip(info.massUsage, info.massCapacity, info.massCapacityExplanation, info2.HasValue ? new float?(info2.Value.massUsage) : null, info2.HasValue ? new float?(info2.Value.massCapacity) : null, info2.HasValue ? info2.Value.massCapacityExplanation : null), taggedString2, info2.HasValue ? GetMassColor(info2.Value.massUsage, info2.Value.massCapacity, lerpMassColor) : Color.white, lastMassFlashTime)); if (info.extraMassUsage != -1f) { TaggedString taggedString3 = info.extraMassUsage.ToStringEnsureThreshold(info.extraMassCapacity, 0) + " / " + info.extraMassCapacity.ToString("F0") + " " + "kg".Translate(); TaggedString taggedString4 = info2.HasValue ? (info2.Value.extraMassUsage.ToStringEnsureThreshold(info2.Value.extraMassCapacity, 0) + " / " + info2.Value.extraMassCapacity.ToString("F0") + " " + "kg".Translate()) : ((TaggedString)null); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMass".Translate(), taggedString3, GetMassColor(info.extraMassUsage, info.extraMassCapacity, lerpMassColor: true), GetMassTip(info.extraMassUsage, info.extraMassCapacity, info.extraMassCapacityExplanation, info2.HasValue ? new float?(info2.Value.extraMassUsage) : null, info2.HasValue ? new float?(info2.Value.extraMassCapacity) : null, info2.HasValue ? info2.Value.extraMassCapacityExplanation : null), taggedString4, info2.HasValue ? GetMassColor(info2.Value.extraMassUsage, info2.Value.extraMassCapacity, lerpMassColor: true) : Color.white)); } string text = "CaravanMovementSpeedTip".Translate(); if (!info.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n" + info.tilesPerDayExplanation; } if (info2.HasValue && !info2.Value.tilesPerDayExplanation.NullOrEmpty()) { text = text + "\n\n-----\n\n" + info2.Value.tilesPerDayExplanation; } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("CaravanMovementSpeed".Translate(), info.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate(), GenUI.LerpColor(TilesPerDayColor, info.tilesPerDay), text, info2.HasValue ? (info2.Value.tilesPerDay.ToString("0.#") + " " + "TilesPerDay".Translate()) : ((TaggedString)null), info2.HasValue ? GenUI.LerpColor(TilesPerDayColor, info2.Value.tilesPerDay) : Color.white)); tmpInfo.Add(new TransferableUIUtility.ExtraInfo("DaysWorthOfFood".Translate(), GetDaysWorthOfFoodLabel(info.daysWorthOfFood, multiline), GetDaysWorthOfFoodColor(info.daysWorthOfFood, ticksToArrive), "DaysWorthOfFoodTooltip".Translate() + extraDaysWorthOfFoodTipInfo + "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(currentTile, Find.TickManager.TicksAbs), info2.HasValue ? GetDaysWorthOfFoodLabel(info2.Value.daysWorthOfFood, multiline) : null, info2.HasValue ? GetDaysWorthOfFoodColor(info2.Value.daysWorthOfFood, ticksToArrive) : Color.white)); string text2 = info.foragedFoodPerDay.Second.ToString("0.#"); string text3 = info2.HasValue ? info2.Value.foragedFoodPerDay.Second.ToString("0.#") : null; TaggedString taggedString5 = "ForagedFoodPerDayTip".Translate(); taggedString5 += "\n\n" + info.foragedFoodPerDayExplanation; if (info2.HasValue) { taggedString5 += "\n\n-----\n\n" + info2.Value.foragedFoodPerDayExplanation; } if (info.foragedFoodPerDay.Second > 0f || (info2.HasValue && info2.Value.foragedFoodPerDay.Second > 0f)) { string text4 = multiline ? "\n" : " "; if (!info2.HasValue) { text2 = text2 + text4 + "(" + info.foragedFoodPerDay.First.label + ")"; } else { text3 = text3 + text4 + "(" + info2.Value.foragedFoodPerDay.First.label.Truncate(50f) + ")"; } } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("ForagedFoodPerDay".Translate(), text2, Color.white, taggedString5, text3, Color.white)); string text5 = "CaravanVisibilityTip".Translate(); if (!info.visibilityExplanation.NullOrEmpty()) { text5 = text5 + "\n\n" + info.visibilityExplanation; } if (info2.HasValue && !info2.Value.visibilityExplanation.NullOrEmpty()) { text5 = text5 + "\n\n-----\n\n" + info2.Value.visibilityExplanation; } tmpInfo.Add(new TransferableUIUtility.ExtraInfo("Visibility".Translate(), info.visibility.ToStringPercent(), GenUI.LerpColor(VisibilityColor, info.visibility), text5, info2.HasValue ? info2.Value.visibility.ToStringPercent() : null, info2.HasValue ? GenUI.LerpColor(VisibilityColor, info2.Value.visibility) : Color.white)); TransferableUIUtility.DrawExtraInfo(tmpInfo, rect); }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { Pawn pawn2 = GridsUtility.GetThingList(IntVec3.FromVector3(clickPos), pawn.Map) .FirstOrDefault((Thing x) => x is Pawn) as Pawn; var mapComp = pawn.Map.GetComponent <MapComponentZLevel>(); var ZTracker = ZUtils.ZTracker; if (pawn2 != null && ZTracker.ZLevelsTracker[pawn.Map.Tile].ZLevels.Count > 1) { TaggedString toCheck = "Rescue".Translate(pawn2.LabelCap, pawn2); FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains (toCheck)); if (floatMenuOption != null) { opts.Remove(floatMenuOption); opts.Add(AddHumanlikeOrders_Patch.AddRescueOption(pawn, pawn2)); } TaggedString toCheck2 = "Capture".Translate(pawn2.LabelCap, pawn2); FloatMenuOption floatMenuOption2 = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains (toCheck2)); if (floatMenuOption2 != null) { opts.Remove(floatMenuOption2); opts.Add(AddHumanlikeOrders_Patch.AddCaptureOption(pawn, pawn2)); } } }
public static void DoSettings(IntegrationSettings settings, Rect rect) { float curY = 80; Rect rect2 = new Rect(0, curY, rect.width / 2 - 10, 250f); Listing_Standard listingStandard2 = new Listing_Standard(); listingStandard2.Begin(rect2); listingStandard2.Gap(30f); TaggedString warning = (settings.ColonyManagerIntegration == ColonyManager.WasPatched) ? new TaggedString("") : new TaggedString(" (") + "AnimalGenetics.NeedsRestart".Translate() + new TaggedString(")"); listingStandard2.CheckboxLabeled("AnimalGenetics.ColonyManager.Integrate".Translate() + warning, ref settings.ColonyManagerIntegration, "AnimalGenetics.ColonyManager.IntegrateTooltip".Translate()); listingStandard2.Gap(30f); listingStandard2.End(); Listing_Standard bottom = new Listing_Standard(); Rect bottomRect = new Rect(0, rect2.y + listingStandard2.CurHeight, rect.width, 100); bottom.Begin(bottomRect); if (bottom.ButtonText("AG.DefaultSettings".Translate())) { settings.Reset(); } bottom.End(); Assembly.AnimalGeneticsAssemblyLoader.PatchUI(); }
public static bool Do() { Map map = Current.Game.RandomPlayerHomeMap; IntVec3 loc; if (!TryFindEntryCell(map, out loc)) { return(false); } var pawn = GameComponent.GetRandomAllyForSpawning(); if (pawn == null) { return(false); } pawn.SetFactionDirect(Faction.OfPlayer); GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish); var def = IncidentDefs.Reunion_AllyJoin; TaggedString baseLetterLabel = def.letterLabel.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true); TaggedString baseLetterText = def.letterText.Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true); Find.LetterStack.ReceiveLetter(baseLetterLabel, baseLetterText, def.letterDef, new LookTargets(pawn)); GameComponent.TryScheduleNextEvent(ScheduleMode.Forced); return(true); }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn pawn) { if (pawn.Dead || pawn.Drafted) { yield break; } string text = "BeginLinkingRitualFloatMenu".Translate(); AcceptanceReport acceptanceReport = CanPsylink(pawn); if (!acceptanceReport.Accepted && !string.IsNullOrWhiteSpace(acceptanceReport.Reason)) { text = text + ": " + acceptanceReport.Reason; } FloatMenuOption floatMenuOption = new FloatMenuOption(text, delegate { TaggedString psylinkAffectedByTraitsNegativelyWarning = RoyalTitleUtility.GetPsylinkAffectedByTraitsNegativelyWarning(pawn); if ((string)psylinkAffectedByTraitsNegativelyWarning != null) { Find.WindowStack.Add(new Dialog_MessageBox(psylinkAffectedByTraitsNegativelyWarning, "Confirm".Translate(), delegate { BeginLinkingRitual(pawn); }, "GoBack".Translate())); } else { BeginLinkingRitual(pawn); } }); floatMenuOption.Disabled = !acceptanceReport.Accepted; yield return(floatMenuOption); }
protected override bool TryExecuteWorker(IncidentParms parms) { var map = (Map)parms.target; if (map.Biome != Util_CaveBiome.CaveBiomeDef) { return(TryExecute(parms)); } TryFindRefugeePodSpot(map, out IntVec3 intVec); if (intVec.IsValid == false) { return(false); } Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.OutlanderRefugee); var request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, false, 0, null, 1, null, null, null, null, null); Pawn pawn = PawnGenerator.GeneratePawn(request); HealthUtility.DamageUntilDowned(pawn); TaggedString label = "LetterLabelRefugeePodCrash".Translate(); TaggedString text = "RefugeePodCrash".Translate(); PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn); Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NegativeEvent, new GlobalTargetInfo(intVec, map, false), null); DropPodUtility.MakeDropPodAt(intVec, map, new ActiveDropPodInfo { SingleContainedThing = pawn, openDelay = 180, leaveSlag = true }); return(true); }
private static void EquipWeaponDialog(Pawn pawn, Thing equipment) { TaggedString equipWeaponConfirmationDialogText = ThingRequiringRoyalPermissionUtility.GetEquipWeaponConfirmationDialogText(equipment, pawn); CompBladelinkWeapon compBladelinkWeapon = equipment.TryGetComp <CompBladelinkWeapon>(); if (compBladelinkWeapon != null && compBladelinkWeapon.bondedPawn != pawn) { if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n"; } equipWeaponConfirmationDialogText += "BladelinkEquipWarning".Translate(); } if (!equipWeaponConfirmationDialogText.NullOrEmpty()) { equipWeaponConfirmationDialogText += "\n\n" + "RoyalWeaponEquipConfirmation".Translate(); Find.WindowStack.Add( new Dialog_MessageBox( equipWeaponConfirmationDialogText, "Yes".Translate(), () => { EquipWeapon(pawn, equipment); }, "No".Translate())); } else { EquipWeapon(pawn, equipment); } }
public virtual void TryStartUseJob(Pawn pawn, LocalTargetInfo extraTarget) { if (pawn.CanReserveAndReach(parent, PathEndMode.Touch, Danger.Deadly) && CanBeUsedBy(pawn, out string _)) { StringBuilder stringBuilder = new StringBuilder(); foreach (CompUseEffect comp in parent.GetComps <CompUseEffect>()) { TaggedString taggedString = comp.ConfirmMessage(pawn); if (!taggedString.NullOrEmpty()) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.AppendTagged(taggedString); } } string str = stringBuilder.ToString(); if (str.NullOrEmpty()) { StartJob(); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation(str, StartJob)); } } void StartJob() { Job job = extraTarget.IsValid ? JobMaker.MakeJob(Props.useJob, parent, extraTarget) : JobMaker.MakeJob(Props.useJob, parent); pawn.jobs.TryTakeOrderedJob(job); } }
private static void DrawCustomDifficultySlider(Listing_Standard listing, string optionName, ref float value, ToStringStyle style, ToStringNumberSense numberSense, float min, float max, float precision = 0.01f, bool reciprocate = false, float reciprocalCutoff = 1000f) { string str = (reciprocate ? "_Inverted" : ""); string str2 = optionName.CapitalizeFirst(); string key = "Difficulty_" + str2 + str + "_Label"; string key2 = "Difficulty_" + str2 + str + "_Info"; float num = value; if (reciprocate) { num = Reciprocal(num, reciprocalCutoff); } TaggedString label = key.Translate() + ": " + num.ToStringByStyle(style, numberSense); listing.Label(label, -1f, key2.Translate()); float num2 = listing.Slider(num, min, max); if (num2 != num) { num = GenMath.RoundTo(num2, precision); } if (reciprocate) { num = Reciprocal(num, reciprocalCutoff); } value = num; }
private void OnPreTitleChanged(Faction faction, RoyalTitleDef currentTitle, RoyalTitleDef newTitle, bool sendLetter = true) { AssignHeirIfNone(newTitle, faction); if (pawn.IsColonist && sendLetter) { TaggedString taggedString = null; TaggedString taggedString2 = null; if (currentTitle == null || faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(currentTitle) < faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle)) { taggedString = "LetterGainedRoyalTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), newTitle.GetLabelCapFor(pawn).Named("TITLE")); taggedString2 = "LetterLabelGainedRoyalTitle".Translate(pawn.Named("PAWN"), newTitle.GetLabelCapFor(pawn).Named("TITLE")); } else { taggedString = "LetterLostRoyalTitle".Translate(pawn.Named("PAWN"), faction.Named("FACTION"), currentTitle.GetLabelCapFor(pawn).Named("TITLE")); taggedString2 = "LetterLabelLostRoyalTitle".Translate(pawn.Named("PAWN"), currentTitle.GetLabelCapFor(pawn).Named("TITLE")); } string text = RoyalTitleUtility.BuildDifferenceExplanationText(currentTitle, newTitle, faction, pawn); if (text.Length > 0) { taggedString += "\n\n" + text; } taggedString = taggedString.Resolve().TrimEndNewlines(); Find.LetterStack.ReceiveLetter(taggedString2, taggedString, LetterDefOf.PositiveEvent, pawn); } if (currentTitle != null) { for (int i = 0; i < currentTitle.grantedAbilities.Count; i++) { pawn.abilities.RemoveAbility(currentTitle.grantedAbilities[i]); } } }
/// <summary> /// Does the find. /// </summary> /// <param name="worker">The worker.</param> /// <exception cref="System.NotImplementedException"></exception> protected override void DoFind(Pawn worker) { if (_chosenAnimalToScan == null) { Log.Error($"calling DoFind on {parent.ThingID} which does not have a chosen animal!"); return; } _scratchList.Clear(); _scratchList.AddRange(_chosenAnimalToScan.GetAllMutationsFrom().Where(m => !DB.StoredMutations.Contains(m))); if (_scratchList.Count == 0) { Log.Warning("unable to find mutation to give!"); _chosenAnimalToScan = null; return; } MutationDef mutation = _scratchList.RandomElement(); DB.AddToDatabase(mutation); TaggedString msg = MUTATION_GATHERED_LABEL.Translate(mutation.Named("mutation"), _chosenAnimalToScan.Named("animal") ); Messages.Message(msg, MessageTypeDefOf.PositiveEvent); if (_scratchList.Count - 1 == 0) { _chosenAnimalToScan = null; } }
private void InitializeArt(Thing relatedThing, ArtGenerationContext source) { if (taleRef != null) { taleRef.ReferenceDestroyed(); taleRef = null; } if (CanShowArt) { if (Current.ProgramState == ProgramState.Playing) { if (relatedThing != null) { taleRef = Find.TaleManager.GetRandomTaleReferenceForArtConcerning(relatedThing); } else { taleRef = Find.TaleManager.GetRandomTaleReferenceForArt(source); } } else { taleRef = TaleReference.Taleless; } titleInt = GenerateTitle(); } else { titleInt = null; taleRef = null; } }
private void Outcome_Disaster(Caravan caravan) { LongEventHandler.QueueLongEvent(delegate { FactionRelationKind playerRelationKind = base.Faction.PlayerRelationKind; int randomInRange = DiplomacyTuning.Goodwill_PeaceTalksDisasterRange.RandomInRange; base.Faction.TryAffectGoodwillWith(Faction.OfPlayer, randomInRange, canSendMessage: false, canSendHostilityLetter: false); base.Faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, canSendLetter: false); IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, caravan); incidentParms.faction = base.Faction; PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms, ensureCanGenerateAtLeastOnePawn: true); defaultPawnGroupMakerParms.generateFightersOnly = true; List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList(); Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, list, sendLetterIfRelatedPawns: false); if (list.Any()) { LordMaker.MakeNewLord(incidentParms.faction, new LordJob_AssaultColony(base.Faction), map, list); } Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); GlobalTargetInfo target = (list.Any() ? new GlobalTargetInfo(list[0].Position, map) : GlobalTargetInfo.Invalid); TaggedString letterLabel = "LetterLabelPeaceTalks_Disaster".Translate(); TaggedString letterText = GetLetterText("LetterPeaceTalks_Disaster".Translate(base.Faction.def.pawnsPlural.CapitalizeFirst(), base.Faction.NameColored, Mathf.RoundToInt(randomInRange)), caravan, playerRelationKind); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, "LetterRelatedPawnsGroupGeneric".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.ThreatBig, target, base.Faction); }, "GeneratingMapForNewEncounter", doAsynchronously: false, null); }
public static bool Formatted(ref TaggedString __result, string str, NamedArgument arg1, NamedArgument arg2, NamedArgument arg3, NamedArgument arg4, NamedArgument arg5, NamedArgument arg6, NamedArgument arg7, NamedArgument arg8) { List <string> argsLabels = getArgsLabels(); List <object> argsObjects = getArgsObjects(); argsLabels.Clear(); argsObjects.Clear(); argsLabels.Add(arg1.label); argsObjects.Add(arg1.arg); argsLabels.Add(arg2.label); argsObjects.Add(arg2.arg); argsLabels.Add(arg3.label); argsObjects.Add(arg3.arg); argsLabels.Add(arg4.label); argsObjects.Add(arg4.arg); argsLabels.Add(arg5.label); argsObjects.Add(arg5.arg); argsLabels.Add(arg6.label); argsObjects.Add(arg6.arg); argsLabels.Add(arg7.label); argsObjects.Add(arg7.arg); argsLabels.Add(arg8.label); argsObjects.Add(arg8.arg); __result = GrammarResolverSimple.Formatted(str, argsLabels, argsObjects); return(false); }
public bool TryDoRandomMoodCausedMentalBreak() { if (!CanDoRandomMentalBreaks || pawn.Downed || !pawn.Awake() || pawn.InMentalState) { return(false); } if (pawn.Faction != Faction.OfPlayer && CurrentDesiredMoodBreakIntensity != MentalBreakIntensity.Extreme) { return(false); } if (QuestUtility.AnyQuestDisablesRandomMoodCausedMentalBreaksFor(pawn)) { return(false); } if (!CurrentPossibleMoodBreaks.TryRandomElementByWeight((MentalBreakDef d) => d.Worker.CommonalityFor(pawn, moodCaused: true), out MentalBreakDef result)) { return(false); } Thought thought = RandomFinalStraw(); TaggedString taggedString = "MentalStateReason_Mood".Translate(); if (thought != null) { taggedString += "\n\n" + "FinalStraw".Translate(thought.LabelCap); } return(result.Worker.TryStart(pawn, taggedString, causedByMood: true)); }
public override void Notify_GeneratedByQuestGen(SitePart part, Slate slate, List <Rule> outExtraDescriptionRules, Dictionary <string, string> outExtraDescriptionConstants) { base.Notify_GeneratedByQuestGen(part, slate, outExtraDescriptionRules, outExtraDescriptionConstants); Pawn pawn = DownedRefugeeQuestUtility.GenerateRefugee(part.site.Tile); part.things = new ThingOwner <Pawn>(part, oneStackOnly: true); part.things.TryAdd(pawn); if (pawn.relations != null) { pawn.relations.everSeenByPlayer = true; } Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn); if (mostImportantColonyRelative != null) { PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn); TaggedString text = ""; if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0) { pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative; text = "\n\n" + "RelatedPawnInvolvedInQuest".Translate(mostImportantColonyRelative.LabelShort, mostImportantRelation.GetGenderSpecificLabel(pawn), mostImportantColonyRelative.Named("RELATIVE"), pawn.Named("PAWN")).AdjustedFor(pawn); } else { PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn); } outExtraDescriptionRules.Add(new Rule_String("pawnInvolvedInQuestInfo", text)); } slate.Set("refugee", pawn); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate(); IntVec3 intVec = DropCellFinder.RandomDropSpot(map); Pawn pawn = ThingUtility.FindPawn(things); pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true; TaggedString title = "LetterLabelRefugeePodCrash".Translate(); TaggedString text = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); text += "\n\n"; if (pawn.Faction == null) { text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } else if (pawn.Faction.HostileTo(Faction.OfPlayer)) { text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } else { text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn); } PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn); SendStandardLetter(title, text, LetterDefOf.NeutralEvent, parms, new TargetInfo(intVec, map)); ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things); activeDropPodInfo.openDelay = 180; activeDropPodInfo.leaveSlag = true; DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo); return(true); }
private bool DrawGrazeability(Rect rect, TransferableOneWay trad) { if (!trad.HasAnyThing) { return(false); } Pawn pawn = trad.AnyThing as Pawn; if (pawn == null || !VirtualPlantsUtility.CanEverEatVirtualPlants(pawn)) { return(false); } rect.width = 40f; Rect position = new Rect(rect.x + (float)(int)((rect.width - 28f) / 2f), rect.y + (float)(int)((rect.height - 28f) / 2f), 28f, 28f); Widgets.DrawHighlightIfMouseover(rect); GUI.DrawTexture(position, CanGrazeIcon); if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, delegate { TaggedString taggedString = "AnimalCanGrazeTip".Translate(); if (tile != -1) { taggedString += "\n\n" + VirtualPlantsUtility.GetVirtualPlantsStatusExplanationAt(tile, Find.TickManager.TicksAbs); } return(taggedString); }, trad.GetHashCode() ^ 0x7424D7F2); } return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; PawnKindDef bossKind = def.pawnKind; PawnKindDef animalKind = GetAnimalKind(parms.points, map.Tile); if (bossKind == null || animalKind == null || ManhunterPackIncidentUtility.GetAnimalsCount(animalKind, (parms.points * PointsFactor) - bossKind.combatPower) <= 0) { return(false); } IntVec3 result = parms.spawnCenter; if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal)) { return(false); } List <Pawn> list = ManhunterPackIncidentUtility.GenerateAnimals(bossKind, map.Tile, bossKind.combatPower, 1); list.AddRange(ManhunterPackIncidentUtility.GenerateAnimals(animalKind, map.Tile, (parms.points * PointsFactor) - bossKind.combatPower, parms.pawnCount)); Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; IntVec3 loc = CellFinder.RandomClosewalkCellNear(result, map, 10); QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag); pawn.health.AddHediff(HediffDefOf.Scaria); pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent); pawn.mindState.exitMapAfterTick = Find.TickManager.TicksGame + Rand.Range(AnimalsStayDurationMin, AnimalsStayDurationMax); } TaggedString labelString = null; if (def.letterLabel != null) { labelString = def.letterLabel; } else { labelString = "LetterLabelManhunterPackArrived".Translate(); } TaggedString textString = null; if (def.letterText != null) { textString = def.letterText; } else { textString = "ManhunterPackArrived".Translate(animalKind.GetLabelPlural()); } SendStandardLetter(labelString, textString, LetterDefOf.ThreatBig, parms, list[0]); Find.TickManager.slower.SignalForceNormalSpeedShort(); LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical); LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Important); return(true); }
private void SelectColonist() { var list = new List <FloatMenuOption>(); if (innerContainer.Count == 0) { return; } foreach (var pawn in innerContainer) { var postfix = new TaggedString(); if (pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsRangedWeapon) { postfix = $" ({pawn.equipment.Primary.def.label})"; } var textToAdd = $"{pawn.NameFullColored}{postfix}"; var pawnToEject = pawn; list.Add(new FloatMenuOption(textToAdd, delegate { innerContainer.TryDrop(pawnToEject, Toils_bunker.GetEnterOutLoc(this), Map, ThingPlaceMode.Near, out _); }, MenuOptionPriority.Default, null, null, 29f)); } var sortedList = list.OrderBy(option => option.Label).ToList(); sortedList.Add(new FloatMenuOption("Everyone".Translate(), EjectAllContents, MenuOptionPriority.Default, null, null, 29f)); Find.WindowStack.Add(new FloatMenu(sortedList)); }
public override void Arrived(List <ActiveDropPodInfo> pods, int tile) { Thing lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods); bool flag = !mapParent.HasMap; Map orGenerateMap = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null); Settlement settlement; if ((settlement = orGenerateMap.Parent as Settlement) != null && settlement.Faction != Faction.OfPlayer) { TaggedString letterLabel = "LetterLabelCaravanEnteredEnemyBase".Translate(); TaggedString letterText = "LetterShuttleLandedInEnemyBase".Translate(settlement.Label).CapitalizeFirst(); SettlementUtility.AffectRelationsOnAttacked_NewTmp(settlement, ref letterText); if (flag) { Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(orGenerateMap.mapPawns.AllPawns, ref letterLabel, ref letterText, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), informEvenIfSeenBefore: true); } Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NeutralEvent, lookTarget, settlement.Faction); } foreach (ActiveDropPodInfo pod in pods) { pod.missionShuttleHome = missionShuttleHome; pod.missionShuttleTarget = missionShuttleTarget; pod.sendAwayIfQuestFinished = sendAwayIfQuestFinished; pod.questTags = questTags; } PawnsArrivalModeDefOf.Shuttle.Worker.TravelingTransportPodsArrived(pods, orGenerateMap); Messages.Message("MessageShuttleArrived".Translate(), lookTarget, MessageTypeDefOf.TaskCompletion); }
public override void Arrived(int tile) { LongEventHandler.QueueLongEvent(delegate() { Map map = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null); //MAP INDEX BUG TaggedString label = "LetterLabelCaravanEnteredEnemyBase".Translate(); TaggedString text = "LetterTransportPodsLandedInEnemyBase".Translate(parent.Label).CapitalizeFirst(); if (parent is Settlement settlement) { SettlementUtility.AffectRelationsOnAttacked(settlement, ref text); } if (!parent.HasMap) { Find.TickManager.Notify_GeneratedPotentiallyHostileMap(); PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(map.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true); } AerialVehicleInFlight aerialVehicle = vehicle.GetAerialVehicle(); CameraJumper.TryJump(map.Center, map); StrafeTargeter.Instance.BeginTargeting(vehicle, vehicle.CompVehicleLauncher.launchProtocol, delegate(IntVec3 start, IntVec3 end) { VehicleSkyfaller_FlyOver skyfaller = VehicleSkyfallerMaker.MakeSkyfallerFlyOver(vehicle.CompVehicleLauncher.Props.skyfallerStrafing, vehicle, start, end); skyfaller.aerialVehicle = aerialVehicle; Thing thing = GenSpawn.Spawn(skyfaller, start, parent.Map, Rot8.North); //REDO - Other rotations? }, null, null, null, true); aerialVehicle.Destroy(); }, "GeneratingMap", false, null, true); }
public void SendRimWarLetter(TaggedString baseLetterLabel, TaggedString baseLetterText, LetterDef baseLetterDef, IncidentParms parms, LookTargets lookTargets, params NamedArgument[] textArgs) { if (baseLetterLabel.NullOrEmpty() || baseLetterText.NullOrEmpty()) { Log.Error("Sending standard incident letter with no label or text."); } TaggedString taggedString = baseLetterText.Formatted(textArgs); TaggedString text; if (parms.customLetterText.NullOrEmpty()) { text = taggedString; } else { List <NamedArgument> list = new List <NamedArgument>(); if (textArgs != null) { list.AddRange(textArgs); } list.Add(taggedString.Named("BASETEXT")); text = parms.customLetterText.Formatted(list.ToArray()); } TaggedString taggedString2 = baseLetterLabel.Formatted(textArgs); TaggedString label; if (parms.customLetterLabel.NullOrEmpty()) { label = taggedString2; } else { List <NamedArgument> list2 = new List <NamedArgument>(); if (textArgs != null) { list2.AddRange(textArgs); } list2.Add(taggedString2.Named("BASELABEL")); label = parms.customLetterLabel.Formatted(list2.ToArray()); } ChoiceLetter choiceLetter = LetterMaker.MakeLetter(label, text, parms.customLetterDef ?? baseLetterDef, lookTargets, parms.faction, parms.quest, parms.letterHyperlinkThingDefs); //List<HediffDef> list3 = new List<HediffDef>(); //if (!parms.letterHyperlinkHediffDefs.NullOrEmpty()) //{ // list3.AddRange(parms.letterHyperlinkHediffDefs); //} //Log.Message("5"); //if (!def.letterHyperlinkHediffDefs.NullOrEmpty()) //{ // if (list3 == null) // { // list3 = new List<HediffDef>(); // } // list3.AddRange(def.letterHyperlinkHediffDefs); //} //Log.Message("6"); //choiceLetter.hyperlinkHediffDefs = list3; Find.LetterStack.ReceiveLetter(choiceLetter); }