Ejemplo n.º 1
0
        public static void GiveGift(List <Pawn> possibleGivers, Faction faction)
        {
            if (possibleGivers.NullOrEmpty <Pawn>())
            {
                return;
            }
            Pawn pawn = null;

            for (int i = 0; i < possibleGivers.Count; i++)
            {
                if (possibleGivers[i].RaceProps.Humanlike && possibleGivers[i].Faction == faction)
                {
                    pawn = possibleGivers[i];
                    break;
                }
            }
            if (pawn == null)
            {
                for (int j = 0; j < possibleGivers.Count; j++)
                {
                    if (possibleGivers[j].Faction == faction)
                    {
                        pawn = possibleGivers[j];
                        break;
                    }
                }
            }
            if (pawn == null)
            {
                pawn = possibleGivers[0];
            }
            List <Thing> list   = VisitorGiftForPlayerUtility.GenerateGifts(faction, pawn.Map);
            TargetInfo   target = TargetInfo.Invalid;

            for (int k = 0; k < list.Count; k++)
            {
                if (GenPlace.TryPlaceThing(list[k], pawn.Position, pawn.Map, ThingPlaceMode.Near, null, null))
                {
                    target = list[k];
                }
                else
                {
                    list[k].Destroy(DestroyMode.Vanish);
                }
            }
            if (target.IsValid)
            {
                LetterStack arg_1B1_0 = Find.LetterStack;
                string      arg_1B1_1 = "LetterLabelVisitorsGaveGift".Translate(new object[]
                {
                    pawn.Faction.Name
                });
                string   arg_193_0 = "LetterVisitorsGaveGift";
                object[] expr_150  = new object[2];
                expr_150[0] = pawn.Faction.def.pawnsPlural;
                expr_150[1] = (from g in list
                               select g.LabelCap).ToLineList("   -");
                arg_1B1_0.ReceiveLetter(arg_1B1_1, arg_193_0.Translate(expr_150).AdjustedFor(pawn, "PAWN"), LetterDefOf.PositiveEvent, target, faction, null);
            }
        }
 //public void ReceiveLetter(TaggedString label, TaggedString text, LetterDef textLetterDef, LookTargets lookTargets, Faction relatedFaction = null, Quest quest = null, List<ThingDef> hyperlinkThingDefs = null, string debugInfo = null)
 public static void ReceiveLetterAppend(LetterStack stack, TaggedString label, TaggedString text, LetterDef textLetterDef, LookTargets lookTargets, Faction relatedFaction = null, Quest quest = null, List <ThingDef> hyperlinkThingDefs = null, string debugInfo = null)
 {
     if (Mod.settings.dropPodWhatDropped)
     {
         text += "\n\n" + "TD.WhatDropped".Translate(thingLabel);
     }
     stack.ReceiveLetter(label, text, textLetterDef, lookTargets, relatedFaction, quest, hyperlinkThingDefs, debugInfo);
 }
Ejemplo n.º 3
0
        public static void ClearAll(this LetterStack stack, Predicate <Letter> shouldRemove)
        {
            var letters = stack.LettersListForReading.ListFullCopy();

            letters.ForEach(letter =>
            {
                if (shouldRemove(letter))
                {
                    stack.RemoveLetter(letter);
                }
            });
        }
Ejemplo n.º 4
0
 public static void ReceiveLetter(this LetterStack @this, Letter let, string debugInfo = null)
 {
     let.def.arriveSound.PlayOneShotOnCamera();
     if (Prefs.PauseOnUrgentLetter && !Find.TickManager.Paused)
     {
         if (let.def == LetterDefOf.BadUrgent || (let.def == LetterDefOf.BadNonUrgent && settings.DoNonUrgentPause))
         {
             Find.TickManager.TogglePaused();
         }
     }
     lettersGet(@this).Add(let);
     let.arrivalTime = Time.time;
     let.debugInfo   = debugInfo;
     let.Received();
 }
Ejemplo n.º 5
0
        // Close info letters during simulation and for the arbiter instance
        static void Postfix(LetterStack __instance)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }
            if (!TickPatch.Simulating && !Multiplayer.arbiterInstance)
            {
                return;
            }

            for (int i = __instance.letters.Count - 1; i >= 0; i--)
            {
                var letter = __instance.letters[i];
                if (letter is ChoiceLetter choice && choice.Choices.Any(c => c.action?.Method == choice.Option_Close.action.Method) && Time.time - letter.arrivalTime > 4)
                {
                    __instance.RemoveLetter(letter);
                }
            }
        }
        static FloatMenuUtil()
        {
            groups  = new Dictionary <string, List <string> >();
            items   = new Dictionary <string, Action>();
            devOnly = new Dictionary <string, bool>();

            string group;

            group = GroupFix;
            Add(group, "FloatDebugLog".Translate(), delegate {
                if (!Find.WindowStack.TryRemove(typeof(EditWindow_Log), true))
                {
                    Find.WindowStack.Add(new EditWindow_Log());
                }
            });
            Add(group, "FloatAGRegen".Translate(), delegate {
                foreach (Map map in Find.Maps)
                {
                    map.avoidGrid.Regenerate();
                }
                Message("MsgTextAGR".Translate(), MessageTypeDefOf.PositiveEvent);
            });
            Add(group, "FloatFactionFixItems1".Translate(), delegate {
                CleanserUtil.FixFactionRelationships();
                Message("MsgTextFFR".Translate(), MessageTypeDefOf.PositiveEvent);
            });
            Add(group, "FloatFactionFixItems2".Translate(), delegate {
                Message("MsgTextFFL".Translate(CleanserUtil.FixFactionLeader_Wrapped()), MessageTypeDefOf.PositiveEvent);
            });

            group = GroupTools;
            Add(group, "FloatToolsItems1".Translate(), delegate {
                int a = CleanserUtil.DeconstructAnimalFamily();
                Verse.Log.Message("CleanserUtil.DeconstructAnimalFamily():Round 1 completed.");
                CleanserUtil.DeconstructAnimalFamily();
                Verse.Log.Message("CleanserUtil.DeconstructAnimalFamily():Round 2 completed.");
                Message("MsgTextAFT".Translate(a), MessageTypeDefOf.PositiveEvent);
            });

            Add(group, "FloatToolsItems2".Translate(), delegate {
                Message("MsgTextRFH".Translate(CleanserUtil.RemoveFilth(Find.CurrentMap, true)), MessageTypeDefOf.PositiveEvent);
            });
            Add(group, "FloatToolsItems2Dev1".Translate(), delegate {
                Message("MsgTextRFM".Translate(CleanserUtil.RemoveFilth(Find.CurrentMap, false)), MessageTypeDefOf.PositiveEvent);
            }, true);
            Add(group, "FloatToolsItems2Dev2".Translate(), delegate {
                int i = 0;
                foreach (Map m in Find.Maps)
                {
                    i += CleanserUtil.RemoveFilth(m, false);
                }
                Message("MsgTextRFW".Translate(i), MessageTypeDefOf.PositiveEvent);
            }, true);

            Add(group, "FloatToolsItems2Snow".Translate(), delegate {
                CleanserUtil.RemoveSnow(Find.CurrentMap, true);
                Message("MsgTextRSH".Translate(), MessageTypeDefOf.PositiveEvent);
            });
            Add(group, "FloatToolsItems2SnowDev1".Translate(), delegate {
                CleanserUtil.RemoveSnow(Find.CurrentMap, false);
                Message("MsgTextRSM".Translate(), MessageTypeDefOf.PositiveEvent);
            }, true);
            Add(group, "FloatToolsItems2SnowDev2".Translate(), delegate {
                foreach (Map m in Find.Maps)
                {
                    CleanserUtil.RemoveSnow(m, false);
                }
                Message("MsgTextRSW".Translate(), MessageTypeDefOf.PositiveEvent);
            }, true);

            Add(group, "FloatToolsItems3".Translate(), delegate {
                Message("MsgTextRCM".Translate(CleanserUtil.RemoveCorpses()), MessageTypeDefOf.NeutralEvent);
            });
            Add(group, "FloatToolsItems4".Translate(), delegate {
                Message("MsgTextRBL".Translate(CleanserUtil.RemoveAllBattleLogEntries()), MessageTypeDefOf.PositiveEvent);
            });

            Add(group, "FloatToolsItems5".Translate(), delegate {
                Message("MsgTextRAM".Translate(CleanserUtil.RemoveIArchivable(false)), MessageTypeDefOf.PositiveEvent);
            });
            Add(group, "FloatToolsItems5Dev".Translate(), delegate {
                Message("MsgTextRAM".Translate(CleanserUtil.RemoveIArchivable(true)), MessageTypeDefOf.PositiveEvent);
            }, true);

            //StorytellerFix menus here

            //Storyteller Info Window for non Dev Mode
            Add(group, "StorytellerFixQueueInfo".Translate(), delegate { StorytellerFix.StorytellerFix_GetInfoButton(); }, false);

            //Storyteller Clear Queue for Dev Mode only
            Add(group, "StorytellerFixQueueClearDev".Translate(), delegate { StorytellerFix.StorytellerFix_ClearButton(); }, true);

            //end of StorytellerFix


            group = GroupQuickbar;
            Add(group, "QuickCloseLetStack".Translate(), delegate {
                LetterStack ls = Find.LetterStack;
                if (ls == null)
                {
                    return;
                }
                for (int i = ls.LettersListForReading.Count - 1; i > -1; i--)
                {
                    ls.RemoveLetter(ls.LettersListForReading[i]);
                }
            });
            Add(group, "QuickUnlockSpeedLimit".Translate(), delegate {
                CleanserUtil.UnlockNormalSpeedLimit();
                Find.WindowStack.TryRemove(typeof(UserInterface));
            });
            Add(group, "QuickOpenSettings".Translate(), delegate {
                CleanserUtil.OpenModSettingsPage();
            });


            group = GroupMMUpdateMode;
            foreach (MemoryMonitorUpdateMode m in Enum.GetValues(typeof(MemoryMonitorUpdateMode)))
            {
                Add(group, ("MMUpdate_" + m.ToString()).Translate(), delegate
                {
                    RuntimeGC.Settings.MemoryMonitorUpdateInterval = (int)m;
                    UIUtil.Notify_MMBtnLabelChanged();
                }, m.ToString().Contains("Debug_"));
            }
        }
Ejemplo n.º 7
0
 public static void ReceiveLetterAppend(LetterStack stack, string label, string text, LetterDef textLetterDef, LookTargets lookTargets, Faction relatedFaction = null, string debugInfo = null)
 {
     text += "\n\n" + "TD.WhatDropped".Translate(thingLabel);
     stack.ReceiveLetter(label, text, textLetterDef, lookTargets, relatedFaction, debugInfo);
 }
Ejemplo n.º 8
0
        public static void ClearAll(this LetterStack stack)
        {
            var letters = stack.LettersListForReading.ListFullCopy();

            letters.ForEach(stack.RemoveLetter);
        }