コード例 #1
0
        public static void Vote(string message, LetterDef type, Thing thing)
        {
            if (message == null)
            {
                message = "";
            }

            Current.Game.letterStack.ReceiveLetter("TwitchStoriesVote".Translate(), message, type, new TargetInfo(thing));
        }
コード例 #2
0
 public static void ReceiveLetterOnce(string label, string text, LetterDef textLetterDef, GlobalTargetInfo lookTarget, string debugInfo)
 {
     //Only send if both letter stack and local indexes do not have the letter
     if (!indexes.Contains(debugInfo) && !Find.LetterStack.LettersListForReading.Any(l => l.debugInfo == debugInfo))
     {
         indexes.Add(debugInfo);
         Find.LetterStack.ReceiveLetter(label, text, textLetterDef, lookTarget, debugInfo);
     }
 }
コード例 #3
0
        // Token: 0x06000078 RID: 120 RVA: 0x00004BB4 File Offset: 0x00002DB4
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string arrivedLetterPart = base.GetArrivedLetterPart(map, ref preferredLetterDef, ref lookTargets);

            lookTargets = (from x in map.mapPawns.AllPawnsSpawned
                           where x.RaceProps.Humanlike && x.HostileTo(Faction.OfPlayer)
                           select x).FirstOrDefault <Pawn>();
            return(arrivedLetterPart);
        }
コード例 #4
0
        public static void Vote(string message, LetterDef type, List <Thing> things)
        {
            if (message == null)
            {
                message = "";
            }

            Find.LetterStack.ReceiveLetter("TwitchStoriesVote".Translate(), message, type, new LookTargets(things));
        }
コード例 #5
0
        public static LetterDef ConvertLetterDefToNotification(LetterDef def)
        {
            if (def.defName.Contains("Notification"))
            {
                return(def);
            }

            return(DefDatabase <LetterDef> .GetNamed("Notification" + def.defName, false) ?? def);
        }
コード例 #6
0
 public static void AddLastPlayerMessagePrefix(string label, ref string text, LetterDef def)
 {
     if (Helper.playerMessages.Count > 0)
     {
         string msg = Helper.playerMessages[0];
         text += msg;
         Helper.playerMessages.RemoveAt(0);
     }
 }
コード例 #7
0
ファイル: Helper.cs プロジェクト: vahnj/twitchtoolkit
        public static void CarePackage(string message, LetterDef type, IntVec3 vec)
        {
            if (message == null)
            {
                message = "";
            }

            Current.Game.letterStack.ReceiveLetter("TwitchToolkitCarePackage".Translate(), message, type, new TargetInfo(vec, Helper.AnyPlayerMap, false));
        }
コード例 #8
0
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string arrivedLetterPart = base.GetArrivedLetterPart(map, out preferredLetterDef, out lookTargets);

            lookTargets = (from x in map.mapPawns.AllPawnsSpawned
                           where x.MentalStateDef == MentalStateDefOf.Manhunter || x.MentalStateDef == MentalStateDefOf.ManhunterPermanent
                           select x).FirstOrDefault();
            return(arrivedLetterPart);
        }
コード例 #9
0
        public static void Make(string label, string text, LetterDef def)
        {
            var lclass = def.letterClass;

            def.letterClass = typeof(OpenUILetter);
            ChoiceLetter Letter = LetterMaker.MakeLetter(label, text, def);

            def.letterClass = lclass;
            Find.LetterStack.ReceiveLetter(Letter);
        }
コード例 #10
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            RFScenarios_Initializer.usingMoonFall = true;
            float SkyFallType = Rand.Value;

            if (SkyFallType < 0.2f)
            {
                // Meteor Swarm
                Messages.Message("RFScenarios.MessageMeteorSwarmTribal".Translate(), MessageTypeDefOf.NeutralEvent);
                return(true);
            }
            else if (SkyFallType < 0.25f)
            {
                // Flashstorm
                Map map = (Map)parms.target;
                if ((map).gameConditionManager.ConditionIsActive(GameConditionDefOf.Flashstorm))
                {
                    return(false);
                }
                FloatRange durationDays = new FloatRange(0.075f, 0.1f);
                int        num          = Mathf.RoundToInt(durationDays.RandomInRange * 60000f);
                GameCondition_Flashstorm gameConditionFlashstorm = (GameCondition_Flashstorm)GameConditionMaker.MakeCondition(GameConditionDefOf.Flashstorm, num);
                map.gameConditionManager.RegisterCondition(gameConditionFlashstorm);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelFlashstorm".Translate(), "RFScenarios.FlashstormTribal".Translate(), LetterDefOf.ThreatSmall, new TargetInfo(gameConditionFlashstorm.centerLocation.ToIntVec3, map, false), null);
                if (map.weatherManager.curWeather.rainRate > 0.1f)
                {
                    map.weatherDecider.StartNextWeather();
                }
                return(true);
            }
            else
            {
                // Meteorite
                IntVec3 intVec3;
                Map     map = (Map)parms.target;
                if (!this.TryFindCell(out intVec3, map))
                {
                    return(false);
                }
                List <Thing> list = ThingSetMakerDefOf.Meteorite.root.Generate();
                if (Controller.Settings.crashBurn.Equals(true) && Rand.Value < 0.67f)
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncomingFlame, list, intVec3, map);
                }
                else
                {
                    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec3, map);
                }
                LetterDef letterDef = (!list[0].def.building.isResourceRock ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent);
                String    text      = TranslatorFormattedStringExtensions.Translate("RFScenarios.MeteoriteTribal", list[0].def.label);
                Find.LetterStack.ReceiveLetter("RFScenarios.LetterLabelMeteoriteTribal".Translate(), text, letterDef, new TargetInfo(intVec3, map, false), null);
                return(true);
            }
        }
コード例 #11
0
 private bool LetterStackContains(LetterDef def)
 {
     foreach (Letter let in Find.LetterStack.LettersListForReading)
     {
         if (let.label.Equals(def.label))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #12
0
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string arrivedLetterPart = base.GetArrivedLetterPart(map, out preferredLetterDef, out lookTargets);
            Thing  arg_6C_0;

            if ((arg_6C_0 = map.listerThings.AllThings.FirstOrDefault((Thing x) => x is Building_TurretGun && x.HostileTo(Faction.OfPlayer))) == null)
            {
                arg_6C_0 = map.listerThings.AllThings.FirstOrDefault((Thing x) => x is Building_TurretGun);
            }
            lookTargets = arg_6C_0;
            return(arrivedLetterPart);
        }
コード例 #13
0
        public static void Enter(Pawn pawn, StringBuilder message)
        {
            var map = Find.CurrentMap;

            if (pawn.Map == map)
            {
                message.Append("You're already on the current map");
                return;
            }

            IntVec3 intVec = DropCellFinder.RandomDropSpot(map);

            LetterDef textLetterDef = LetterDefOf.NeutralEvent;
            string    label         = "LetterLabelRefugeePodCrash".Translate();
            string    text          = "RefugeePodCrash".Translate().AdjustedFor(pawn, "PAWN");

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");

                textLetterDef = LetterDefOf.ThreatSmall;
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(new object[]
                {
                    pawn
                }).AdjustedFor(pawn, "PAWN");
            }

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);

            Find.LetterStack.ReceiveLetter(label, text, textLetterDef, new TargetInfo(intVec, map, false), null, null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(new[] { pawn }, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);

            message.Append(text);
        }
コード例 #14
0
 private List <FloatMenuOption> LetterOptions()
 {
     return(letterOptions
            .Select(entry =>
                    new FloatMenuOption(
                        label: entry.Value,
                        action: () => selectedLetterDef = entry.Key,
                        itemIcon: entry.Key.Icon,
                        iconColor: entry.Key.color,
                        extraPartWidth: 29f
                        ))
            .ToList());
 }
コード例 #15
0
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string             arrivedLetterPart = base.GetArrivedLetterPart(map, out preferredLetterDef, out lookTargets);
            IEnumerable <Pawn> source            = map.mapPawns.AllPawnsSpawned.Where((Pawn x) => x.RaceProps.IsMechanoid);
            Pawn pawn = source.Where((Pawn x) => x.GetLord() != null && x.GetLord().LordJob is LordJob_SleepThenAssaultColony).FirstOrDefault();

            if (pawn == null)
            {
                pawn = source.FirstOrDefault();
            }
            lookTargets = pawn;
            return(arrivedLetterPart);
        }
コード例 #16
0
        public static void Make(string label, string text, LetterDef def, TravelingIncidentCaravan caravan)
        {
            var lclass = def.letterClass;

            def.letterClass = typeof(SparkUILetter);
            ChoiceLetter Letter = LetterMaker.MakeLetter(label, text, def);

            def.letterClass = lclass;
            if (Letter is SparkUILetter sLetter)
            {
                sLetter.caravan = caravan;
            }
            Find.LetterStack.ReceiveLetter(Letter);
        }
コード例 #17
0
            public static bool Prefix(LetterDef textLetterDef, LookTargets lookTargets)
            {
                if (textLetterDef == LetterDefOf.Death && lookTargets.PrimaryTarget.HasThing)
                {
                    Pawn deadPawn = lookTargets.PrimaryTarget.Thing as Pawn;

                    if (deadPawn != null && deadPawn.kindDef == MeeseeksDefOf.MeeseeksKind)
                    {
                        return(false);
                    }
                }

                return(true);
            }
コード例 #18
0
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string       arrivedLetterPart = base.GetArrivedLetterPart(map, out preferredLetterDef, out lookTargets);
            List <Thing> list = new List <Thing>();

            foreach (Thing allThing in map.listerThings.AllThings)
            {
                if ((allThing.def.building != null && allThing.def.building.buildingTags != null && allThing.def.building.buildingTags.Contains("MechClusterMember")) || (allThing is Pawn && allThing.def.race.IsMechanoid))
                {
                    list.Add(allThing);
                }
            }
            lookTargets = new LookTargets(list);
            return(arrivedLetterPart);
        }
コード例 #19
0
        private static void EventNotification(string label, string description, LetterDef letterDef, IntVec3?location)
        {
            var currentMap = Find.CurrentMap;

            if (location == null)
            {
                Find.LetterStack.ReceiveLetter(label, description, letterDef);
            }
            else
            {
                // Have to make sure that location isn't null otherwise compiler complains
                var newVector = location.GetValueOrDefault();
                Find.LetterStack.ReceiveLetter(label, description, letterDef, new LookTargets(newVector, currentMap));
            }
        }
コード例 #20
0
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks,
                                        out string letterText, out string letterLabel,
                                        out LetterDef letterDef, out LookTargets lookTargets)
        {
            base.Interacted(initiator, recipient, extraSentencePacks, out letterText, out letterLabel, out letterDef, out lookTargets);
            int diff     = initiator.VampComp().Level - recipient.VampComp().Level;
            int xpToGive = (int)(10 + (VAMPIRE_XPPERLEVELDIFF * diff));

            if (recipient.IsGhoul())
            {
                xpToGive = (int)(xpToGive * 0.5f);
            }
            recipient.VampComp().XP += xpToGive;
            MoteMaker.ThrowText(recipient.DrawPos, recipient.MapHeld, "XP +" + xpToGive);
        }
コード例 #21
0
        /// <summary>
        ///     called when the initiator interacts with the specified recipient.
        /// </summary>
        /// <param name="initiator">The initiator.</param>
        /// <param name="recipient">The recipient.</param>
        /// <param name="extraSentencePacks">The extra sentence packs.</param>
        /// <param name="letterText">The letter text.</param>
        /// <param name="letterLabel">The letter label.</param>
        /// <param name="letterDef">The letter definition.</param>
        /// <param name="lookTargets">The look targets.</param>
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks,
                                        out string letterText, out string letterLabel,
                                        out LetterDef letterDef, out LookTargets lookTargets)
        {
            base.Interacted(initiator, recipient, extraSentencePacks, out letterText, out letterLabel, out letterDef,
                            out lookTargets);
            if (extraSentencePacks == null)
            {
                return;
            }
            SapienceLevel?sapientLevel = recipient?.GetQuantizedSapienceLevel();

            if (sapientLevel == null)
            {
                return;
            }
            RulePackDef variant;

            if (extraSentencePacks.Count != 0)
            {
                _scratchList.Clear();
                _scratchList.AddRange(extraSentencePacks);
                extraSentencePacks.Clear(); //we need to substitute any variants if any exist

                foreach (RulePackDef rulePackDef in _scratchList)
                {
                    if (rulePackDef.TryGetSapientDefVariant(recipient, out variant))
                    {
                        extraSentencePacks.Add(variant); //add the variant if a variant is found
                    }
                    else
                    {
                        extraSentencePacks.Add(rulePackDef); //add the original if no variant is found
                    }
                }
            }

            //now get additions from the interaction def
            if (interaction.TryGetSapientDefVariant(recipient, out variant))
            {
                extraSentencePacks.Add(variant);
            }

            if (recipient.Faction == Faction.OfPlayer)
            {
                recipient.TryGainMemory(PMThoughtDefOf.FormerHumanTameThought);
            }
        }
コード例 #22
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindCell(out IntVec3 cell, map))
            {
                return(false);
            }
            List <Thing> list = ThingSetMakerDefOf.Meteorite.root.Generate();

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, cell, map);
            LetterDef textLetterDef = (!list[0].def.building.isResourceRock) ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent;
            string    text          = string.Format(def.letterText, list[0].def.label).CapitalizeFirst();

            Find.LetterStack.ReceiveLetter(def.letterLabel, text, textLetterDef, new TargetInfo(cell, map));
            return(true);
        }
        public override string GetArrivedLetterPart(Map map, out LetterDef preferredLetterDef, out LookTargets lookTargets)
        {
            string             arrivedLetterPart = base.GetArrivedLetterPart(map, out preferredLetterDef, out lookTargets);
            IEnumerable <Pawn> source            = from x in map.mapPawns.AllPawnsSpawned
                                                   where x.RaceProps.Humanlike
                                                   select x;
            Pawn pawn = (from x in source
                         where x.GetLord() != null && x.GetLord().LordJob is LordJob_DefendBase
                         select x).FirstOrDefault();

            if (pawn == null)
            {
                pawn = source.FirstOrDefault();
            }
            lookTargets = pawn;
            return(arrivedLetterPart);
        }
コード例 #24
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!TryFindCell(out var cell, map))
            {
                return(false);
            }
            List <Thing> list = ThingSetMakerDefOf.Meteorite.root.Generate();

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, cell, map);
            LetterDef baseLetterDef = (list[0].def.building.isResourceRock ? LetterDefOf.PositiveEvent : LetterDefOf.NeutralEvent);
            string    str           = string.Format(def.letterText, list[0].def.label).CapitalizeFirst();

            SendStandardLetter(def.letterLabel + ": " + list[0].def.LabelCap, str, baseLetterDef, parms, new TargetInfo(cell, map));
            return(true);
        }
コード例 #25
0
        private string ColouredOptionLabel(LetterDef def)
        {
            string nameString;

            switch (def.defName)
            {
            case "RansomDemand":
                nameString = "ACEN_RansomDemand".Translate();
                break;

            case "ItemStashFeeDemand":
                nameString = "ACEN_ItemStashFeeDemand".Translate();
                break;

            case "ThreatBig":
                nameString = "ACEN_ThreatBig".Translate();
                break;

            case "ThreatSmall":
                nameString = "ACEN_ThreatSmall".Translate();
                break;

            case "NegativeEvent":
                nameString = "ACEN_NegativeEvent".Translate();
                break;

            case "NeutralEvent":
                nameString = "ACEN_NeutralEvent".Translate();
                break;

            case "PositiveEvent":
                nameString = "ACEN_PositiveEvent".Translate();
                break;

            default:
                nameString = def.defName;
                break;
            }

            Color32 color         = def.color;     //Cast to Color32 for hex conversion
            string  hexColor      = color.r.ToString("X2") + color.g.ToString("X2") + color.b.ToString("X2");
            string  colouredLabel = "<b><color=#" + hexColor + ">" + nameString + "</color></b>";

            return("ACEN_SetLetterPref".Translate(new string[] { colouredLabel }));
        }
コード例 #26
0
ファイル: HarmonyTest.cs プロジェクト: AKreedz/ra2inRW
 public static bool Prefix(LetterDef textLetterDef, ref LookTargets lookTargets)
 {
     if (textLetterDef == LetterDefOf.Death)
     {
         foreach (GlobalTargetInfo target in lookTargets.targets)
         {
             if (target.Thing is Pawn)
             {
                 Pawn pp = target.Thing as Pawn;
                 if (pp.Faction.IsPlayer && pp.kindDef.defName.StartsWith("ra2_"))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
コード例 #27
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map    = (Map)parms.target;
            IntVec3 intVec = default(IntVec3);

            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }
            List <Thing> list = ItemCollectionGeneratorDefOf.Meteorite.Worker.Generate(default(ItemCollectionGeneratorParams));

            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.MeteoriteIncoming, list, intVec, map);
            LetterDef textLetterDef = (!list[0].def.building.isResourceRock) ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent;
            string    text          = string.Format(base.def.letterText, list[0].def.label).CapitalizeFirst();

            Find.LetterStack.ReceiveLetter(base.def.letterLabel, text, textLetterDef, new TargetInfo(intVec, map, false), null);
            return(true);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map     map = (Map)parms.target;
            IntVec3 intVec;

            if (!this.TryFindCell(out intVec, map))
            {
                return(false);
            }

            var list = GenerateBloodStone();

            map.weatherManager.eventHandler.AddEvent(new WeatherEvent_BloodCometFlash(map));
            SkyfallerMaker.SpawnSkyfaller(UvhashDefOf.Uvhash_BloodCometFragmentIncoming, list, intVec, map);
            LetterDef textLetterDef = (!list[0].def.building.isResourceRock) ? LetterDefOf.NeutralEvent : LetterDefOf.PositiveEvent;
            string    text          = string.Format(this.def.letterText, list[0].def.label).CapitalizeFirst();

            Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, textLetterDef, new TargetInfo(intVec, map, false), null);
            return(true);
        }
コード例 #29
0
ファイル: Quest.cs プロジェクト: KraigXu/GameProject
        public void End(QuestEndOutcome outcome, bool sendLetter = true)
        {
            if (Historical)
            {
                Log.Error("Tried to resolve a historical quest. id=" + id);
                return;
            }
            ended      = true;
            endOutcome = outcome;
            CleanupQuestParts();
            if ((EverAccepted || State != QuestState.EndedOfferExpired) && sendLetter)
            {
                string    key           = null;
                string    key2          = null;
                LetterDef textLetterDef = null;
                switch (State)
                {
                case QuestState.EndedFailed:
                    key2          = "LetterQuestFailedLabel";
                    key           = "LetterQuestCompletedFail";
                    textLetterDef = LetterDefOf.NegativeEvent;
                    SoundDefOf.Quest_Failed.PlayOneShotOnCamera();
                    break;

                case QuestState.EndedSuccess:
                    key2          = "LetterQuestCompletedLabel";
                    key           = "LetterQuestCompletedSuccess";
                    textLetterDef = LetterDefOf.PositiveEvent;
                    SoundDefOf.Quest_Succeded.PlayOneShotOnCamera();
                    break;

                case QuestState.EndedUnknownOutcome:
                    key2          = "LetterQuestConcludedLabel";
                    key           = "LetterQuestCompletedConcluded";
                    textLetterDef = LetterDefOf.NeutralEvent;
                    SoundDefOf.Quest_Concluded.PlayOneShotOnCamera();
                    break;
                }
                Find.LetterStack.ReceiveLetter(key2.Translate(), key.Translate(name.CapitalizeFirst()), textLetterDef, null, null, this);
            }
        }
コード例 #30
0
        public override void DoWindowContents(Rect inRect)
        {
            var listing = new Listing_Standard();

            listing.Begin(inRect);
            if (listing.ButtonTextLabeled("BetterLetters.Def".Translate(),
                                          def != null ? def.defName : "BetterLetters.None".Translate().ToString()))
            {
                var opts = new List <FloatMenuOption>
                {
                    new FloatMenuOption("BetterLetters.None".Translate(), () => def = null)
                };
                opts.AddRange(DefDatabase <LetterDef> .AllDefs.Select(letterDef =>
                                                                      new FloatMenuOption(letterDef.defName, () => def = letterDef)));
                Log.Message("Count: " + opts.Count);
                Find.WindowStack.Add(new FloatMenu(opts));
            }

            text = listing.TextEntryLabeled("BetterLetters.Text".Translate(), text);
            listing.End();
        }