Ejemplo n.º 1
0
        public void LogTaleInterestSummary()
        {
            StringBuilder stringBuilder = new StringBuilder();
            float         num           = (from t in this.tales
                                           where t.def.usableForArt
                                           select t).Sum((Tale t) => t.InterestLevel);
            Func <TaleDef, float> defInterest = (TaleDef def) => (from t in this.tales
                                                                  where t.def == def
                                                                  select t).Sum((Tale t) => t.InterestLevel);

            using (IEnumerator <TaleDef> enumerator = (from def in DefDatabase <TaleDef> .AllDefs
                                                       where def.usableForArt
                                                       orderby defInterest(def) descending
                                                       select def).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TaleDef def = enumerator.Current;
                    stringBuilder.AppendLine(string.Concat(new object[]
                    {
                        def.defName,
                        ":   [",
                        (from t in this.tales
                         where t.def == def
                         select t).Count <Tale>(),
                        "]   ",
                        (defInterest(def) / num).ToStringPercent("F2")
                    }));
                }
            }
            Log.Message(stringBuilder.ToString(), false);
        }
Ejemplo n.º 2
0
        public static void RecordTale(TaleDef def, params object[] args)
        {
            bool flag = Rand.Value < def.ignoreChance;

            if (Rand.Value >= def.ignoreChance || DebugViewSettings.logTaleRecording)
            {
                if (def.colonistOnly)
                {
                    bool flag2 = false;
                    bool flag3 = false;
                    for (int i = 0; i < args.Length; i++)
                    {
                        Pawn pawn = args[i] as Pawn;
                        if (pawn != null)
                        {
                            flag2 = true;
                            if (pawn.Faction == Faction.OfPlayer)
                            {
                                flag3 = true;
                            }
                        }
                    }
                    if (flag2 && !flag3)
                    {
                        return;
                    }
                }
                Tale tale = TaleFactory.MakeRawTale(def, args);
                if (tale != null)
                {
                    if (DebugViewSettings.logTaleRecording)
                    {
                        string   format = "Tale {0} from {1}, targets {2}:\n{3}";
                        object[] array  = new object[4];
                        array[0] = ((!flag) ? "recorded" : "ignored");
                        array[1] = def;
                        array[2] = (from arg in args
                                    select arg.ToStringSafe <object>()).ToCommaList(false);
                        array[3] = TaleTextGenerator.GenerateTextFromTale(TextGenerationPurpose.ArtDescription, tale, Rand.Int, RulePackDefOf.ArtDescription_Sculpture);
                        Log.Message(string.Format(format, array), false);
                    }
                    if (!flag)
                    {
                        Find.TaleManager.Add(tale);
                        for (int j = 0; j < args.Length; j++)
                        {
                            Pawn pawn2 = args[j] as Pawn;
                            if (pawn2 != null)
                            {
                                if (!pawn2.Dead && pawn2.needs.mood != null)
                                {
                                    pawn2.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
                                }
                                pawn2.records.AccumulateStoryEvent(StoryEventDefOf.TaleCreated);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static Tale RecordTale(TaleDef def, params object[] args)
        {
            bool flag = Rand.Value < def.ignoreChance;

            if (Rand.Value < def.ignoreChance && !DebugViewSettings.logTaleRecording)
            {
                return(null);
            }
            if (def.colonistOnly)
            {
                bool flag2 = false;
                bool flag3 = false;
                for (int i = 0; i < args.Length; i++)
                {
                    Pawn pawn = args[i] as Pawn;
                    if (pawn != null)
                    {
                        flag2 = true;
                        if (pawn.Faction == Faction.OfPlayer)
                        {
                            flag3 = true;
                        }
                    }
                }
                if (flag2 && !flag3)
                {
                    return(null);
                }
            }
            Tale tale = TaleFactory.MakeRawTale(def, args);

            if (tale == null)
            {
                return(null);
            }
            if (DebugViewSettings.logTaleRecording)
            {
                Log.Message(string.Format("Tale {0} from {1}, targets {2}:\n{3}", flag ? "ignored" : "recorded", def, args.Select((object arg) => arg.ToStringSafe()).ToCommaList(), TaleTextGenerator.GenerateTextFromTale(TextGenerationPurpose.ArtDescription, tale, Rand.Int, RulePackDefOf.ArtDescription_Sculpture)));
            }
            if (flag)
            {
                return(null);
            }
            Find.TaleManager.Add(tale);
            for (int j = 0; j < args.Length; j++)
            {
                Pawn pawn2 = args[j] as Pawn;
                if (pawn2 != null)
                {
                    if (!pawn2.Dead && pawn2.needs.mood != null)
                    {
                        pawn2.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
                    }
                    pawn2.records.AccumulateStoryEvent(StoryEventDefOf.TaleCreated);
                }
            }
            return(tale);
        }
Ejemplo n.º 4
0
        public static void LogSpecificTale(TaleDef def, int count)
        {
            List <Tale> list = new List <Tale>();

            for (int i = 0; i < count; i++)
            {
                list.Add(TaleFactory.MakeRandomTestTale(def));
            }
            TaleTester.LogTales(list);
        }
Ejemplo n.º 5
0
        public static Tale MakeRandomTestTale(TaleDef def = null)
        {
            if (def == null)
            {
                def = DefDatabase <TaleDef> .AllDefs.Where((TaleDef d) => d.usableForArt).RandomElement();
            }
            Tale tale = MakeRawTale(def);

            tale.GenerateTestData();
            return(tale);
        }
        public static Tale MakeRandomTestTale(TaleDef def = null)
        {
            if (def == null)
            {
                def = (from d in DefDatabase <TaleDef> .AllDefs
                       where d.usableForArt
                       select d).RandomElement <TaleDef>();
            }
            Tale tale = TaleFactory.MakeRawTale(def, new object[0]);

            tale.GenerateTestData();
            return(tale);
        }
Ejemplo n.º 7
0
        public Tale GetLatestTale(TaleDef def, Pawn pawn)
        {
            Tale tale = null;
            int  num  = 0;

            for (int i = 0; i < this.tales.Count; i++)
            {
                if (this.tales[i].def == def && this.tales[i].DominantPawn == pawn && (tale == null || this.tales[i].AgeTicks < num))
                {
                    tale = this.tales[i];
                    num  = this.tales[i].AgeTicks;
                }
            }
            return(tale);
        }
Ejemplo n.º 8
0
 public static Tale MakeRawTale(TaleDef def, params object[] args)
 {
     try
     {
         Tale tale = (Tale)Activator.CreateInstance(def.taleClass, args);
         tale.def  = def;
         tale.id   = Find.UniqueIDsManager.GetNextTaleID();
         tale.date = Find.TickManager.TicksAbs;
         return(tale);
     }
     catch (Exception arg)
     {
         Log.Error(string.Format("Failed to create tale object {0} with parameters {1}: {2}", def, GenText.ToCommaList(args.Select(Gen.ToStringSafe <object>), true), arg));
         return(null);
     }
 }
Ejemplo n.º 9
0
 public static Tale MakeRawTale(TaleDef def, params object[] args)
 {
     try
     {
         Tale obj = (Tale)Activator.CreateInstance(def.taleClass, args);
         obj.def  = def;
         obj.id   = Find.UniqueIDsManager.GetNextTaleID();
         obj.date = Find.TickManager.TicksAbs;
         return(obj);
     }
     catch (Exception arg2)
     {
         Log.Error($"Failed to create tale object {def} with parameters {args.Select((object arg) => arg.ToStringSafe()).ToCommaList()}: {arg2}");
         return(null);
     }
 }
Ejemplo n.º 10
0
        public static Tale MakeRawTale(TaleDef def, params object[] args)
        {
            Tale result;

            try
            {
                Tale tale = (Tale)Activator.CreateInstance(def.taleClass, args);
                tale.def  = def;
                tale.id   = Find.UniqueIDsManager.GetNextTaleID();
                tale.date = Find.TickManager.TicksAbs;
                result    = tale;
            }
            catch (Exception arg)
            {
                Log.Error(string.Format("Failed to create tale object {0} with parameters {1}: {2}", def, args.Select(new Func <object, string>(Gen.ToStringSafe <object>)).ToCommaList(false), arg), false);
                result = null;
            }
            return(result);
        }
Ejemplo n.º 11
0
        public static string ThoughtNullifiedMessage(Pawn pawn, ThoughtDef def)
        {
            TaggedString t     = "ThoughtNullifiedBy".Translate().CapitalizeFirst() + ": ";
            Trait        trait = NullifyingTrait(def, pawn);

            if (trait != null)
            {
                return(t + trait.LabelCap);
            }
            Hediff hediff = NullifyingHediff(def, pawn);

            if (hediff != null)
            {
                return(t + hediff.def.LabelCap);
            }
            TaleDef taleDef = NullifyingTale(def, pawn);

            if (taleDef != null)
            {
                return(t + taleDef.LabelCap);
            }
            return("");
        }
 private static bool <MakeRandomTestTale> m__0(TaleDef d)
 {
     return(d.usableForArt);
 }
Ejemplo n.º 13
0
 private static bool <LogTaleInterestSummary> m__9(TaleDef def)
 {
     return(def.usableForArt);
 }