コード例 #1
0
 public static void AppendCharityInfoToLetter(TaggedString charityInfo, ref TaggedString letterText)
 {
     if (ModsConfig.IdeologyActive)
     {
         IEnumerable <Pawn> source = IdeoUtility.AllColonistsWithCharityPrecept();
         if (source.Any <Pawn>())
         {
             letterText += "\n\n" + charityInfo + "\n\n" + "PawnsHaveCharitableBeliefs".Translate() + ":";
             foreach (IGrouping <Ideo, Pawn> grouping in from c in source
                      group c by c.Ideo)
             {
                 letterText += "\n  - " + "BelieversIn".Translate(grouping.Key.name.Colorize(grouping.Key.Color), grouping.Select((Pawn f) => f.NameShortColored.Resolve()).ToCommaList(false, false));
             }
         }
     }
 }
コード例 #2
0
        public static bool RecordEvent(HistoryEventsManager __instance, HistoryEvent historyEvent, bool canApplySelfTookThoughts = true)
        {
            try
            {
                IdeoUtility.Notify_HistoryEvent(historyEvent, canApplySelfTookThoughts);
            }
            catch (Exception ex)
            {
                Log.Error("Error while notifying ideos of a HistoryEvent: " + (object)ex);
            }
            int num;

            if (!historyEvent.args.TryGetArg <int>(HistoryEventArgsNames.CustomGoodwill, out num))
            {
                num = 0;
            }
            Pawn pawn;

            if (historyEvent.args.TryGetArg <Pawn>(HistoryEventArgsNames.Doer, out pawn) && pawn.IsColonist)
            {
                HistoryEventsManager.HistoryEventRecords colonistEvent = __instance.colonistEvents[historyEvent.def];
                if (colonistEvent.ticksGame == null)
                {
                    colonistEvent.ticksGame      = new List <int>();
                    colonistEvent.customGoodwill = new List <int>();
                    __instance.colonistEvents[historyEvent.def] = colonistEvent;
                }
                colonistEvent.ticksGame.Add(Find.TickManager.TicksGame);
                colonistEvent.customGoodwill.Add(num);
                if (colonistEvent.ticksGame.Count > historyEvent.def.maxRemembered)
                {
                    colonistEvent.ticksGame.RemoveRange(0, colonistEvent.ticksGame.Count - historyEvent.def.maxRemembered);
                    colonistEvent.customGoodwill.RemoveRange(0, colonistEvent.ticksGame.Count - historyEvent.def.maxRemembered);
                }
            }
            Faction key;

            if (!historyEvent.args.TryGetArg <Faction>(HistoryEventArgsNames.AffectedFaction, out key))
            {
                return(false);
            }
            DefMap <HistoryEventDef, HistoryEventsManager.HistoryEventRecords> defMap;

            lock (__instance.eventsAffectingFaction) //added
            {
                if (!__instance.eventsAffectingFaction.TryGetValue(key, out defMap))
                {
                    defMap = new DefMap <HistoryEventDef, HistoryEventsManager.HistoryEventRecords>();
                    __instance.eventsAffectingFaction.Add(key, defMap);
                }
            }
            HistoryEventsManager.HistoryEventRecords historyEventRecords = defMap[historyEvent.def];
            if (historyEventRecords.ticksGame == null)
            {
                historyEventRecords.ticksGame      = new List <int>();
                historyEventRecords.customGoodwill = new List <int>();
                defMap[historyEvent.def]           = historyEventRecords;
            }
            historyEventRecords.ticksGame.Add(Find.TickManager.TicksGame);
            historyEventRecords.customGoodwill.Add(num);
            if (historyEventRecords.ticksGame.Count <= historyEvent.def.maxRemembered)
            {
                return(false);
            }
            historyEventRecords.ticksGame.RemoveRange(0, historyEventRecords.ticksGame.Count - historyEvent.def.maxRemembered);
            historyEventRecords.customGoodwill.RemoveRange(0, historyEventRecords.ticksGame.Count - historyEvent.def.maxRemembered);
            return(false);
        }