Пример #1
0
        public void AddCommunicationWithLetter(Communication comm, string letterTitle, string letterText = null
                                               , LetterDef letterDef  = null, bool lookAtComms = false, int ticksUntilDisabled = -1, bool removeWhenDisabled = true
                                               , bool persistWithComm = false)
        {
            comms.Add(new CommStruct(comm, ticksUntilDisabled, removeWhenDisabled));
            comm.SetManager(this);
            GlobalTargetInfo lookTarget = default(GlobalTargetInfo);

            if (lookAtComms && this.map.listerBuildings.AllBuildingsColonistOfClass <Building_CommsConsole>().Any())
            {
                this.map.listerBuildings.AllBuildingsColonistOfClass <Building_CommsConsole>().
                Select <Building_CommsConsole, GlobalTargetInfo>(cc => new GlobalTargetInfo(cc)).TryRandomElement(out lookTarget);
            }
            letterDef = ConvertLetterDefToNotification(letterDef ?? LetterDefOf.NeutralEvent);
            NotificationLetter letter = (NotificationLetter)LetterMaker.MakeLetter(letterTitle, letterText ?? letterTitle, letterDef, lookTarget);

            letter.communication   = comm;
            letter.persistWithComm = persistWithComm;
            comm.SetNotificationLetter(letter);
            if (ticksUntilDisabled != -1)
            {
                letter.StartTimeout(ticksUntilDisabled);
            }
            Find.LetterStack.ReceiveLetter(letter);
        }
Пример #2
0
        public void TryRemoveNotificationLetter()
        {
            if (this.letter == null)
            {
                return;
            }

            Find.LetterStack.RemoveLetter(this.letter);
            this.letter = null;
        }
Пример #3
0
        public static Letter MakeNotificationLetter(string title, string text = null, LetterDef def = null, int duration = -1)
        {
            if (def == null)
            {
                def = LetterDefOf.NeutralEvent;
            }
            def = ConvertLetterDefToNotification(def);
            NotificationLetter letter = new NotificationLetter();

            letter.label = letter.title = title;
            letter.text  = text ?? title;
            letter.def   = def;
            if (duration != -1)
            {
                letter.StartTimeout(duration);
            }
            return(letter);
        }
Пример #4
0
 //Called by the letter in the PostLoadInit phase of loading
 public void SetNotificationLetter(NotificationLetter letter)
 {
     this.letter = letter;
 }