/* private class OptionStruct : IExposable * { * public bool enabled */ 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); }
public void AddCommunicationWithLetter(Communication comm, string letterTitle, string letterText = null, LetterDef letterDef = null, bool lookAtComms = false, int ticksUntilDisabled = -1, bool removeWhenDisabled = true) { comms.Add(new CommStruct(comm, ticksUntilDisabled, removeWhenDisabled)); 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; comm.SetNotificationLetter(letter); if (ticksUntilDisabled != -1) { letter.StartTimeout(ticksUntilDisabled); } Find.LetterStack.ReceiveLetter(letter); }