Beispiel #1
0
 static void Prefix(ref Tale tale, RulePackDef extraInclude)
 {
     if (extraInclude.defName == "ArtDescription_Plushie")
     {
         tale = null;
     }
 }
Beispiel #2
0
        public override float OpinionOffset()
        {
            if (ThoughtUtility.ThoughtNullified(pawn, def))
            {
                return(0f);
            }
            Predicate <Tale_DoublePawn> validator = delegate(Tale_DoublePawn tale)
            {
                return(otherPawn == tale.secondPawnData?.pawn && OpinionOf(tale.firstPawnData.pawn) >= 20);
            };
            Tale latestTale = VSIE_Utils.GetLatestDoublePawnTale(def.taleDef, validator);

            if (latestTale != null)
            {
                float num = 1f;
                if (latestTale.def.type == TaleType.Expirable)
                {
                    float value = (float)latestTale.AgeTicks / (latestTale.def.expireDays * 60000f);
                    num = Mathf.InverseLerp(1f, def.lerpOpinionToZeroAfterDurationPct, value);
                }
                var value2 = base.CurStage.baseOpinionOffset * num;
                return(value2);
            }
            return(0f);
        }
        public void Post([FromBody] Tale újMese)
        {
            MeseContext context = new MeseContext();

            context.Tales.Add(újMese);
            context.SaveChanges();
        }
 public void ReferenceDestroyed()
 {
     if (tale != null)
     {
         tale.Notify_ReferenceDestroyed();
         tale = null;
     }
 }
Beispiel #5
0
 public static bool Add(TaleManager __instance, Tale tale)
 {
     lock (__instance)
     {
         tales(__instance).Add(tale);
     }
     actionCheckCullTales(__instance, tale);
     return(false);
 }
 public static bool Add(TaleManager __instance, Tale tale)
 {
     lock (__instance)
     {
         __instance.tales.Add(tale);
     }
     __instance.CheckCullTales(tale);
     return(false);
 }
 private static void Postfix(Tale __result, TaleDef def, params object[] args)
 {
     if (__result != null)
     {
         Log.Message($"{def.defName} Recording new tale: {__result}");
     }
     else
     {
         Log.Message("Couldn't create new tale: " + def + " - " + args);
     }
 }
Beispiel #8
0
 public static void RemoveTale(TaleManager __instance, Tale tale)
 {
     if (!tale.Unused)
     {
         Log.Warning("Tried to remove used tale " + tale);
     }
     else
     {
         lock (tales(__instance))
         {
             tales(__instance).Remove(tale);
         }
     }
 }
        public static Tale GetLatestTale(TaleDef def, Predicate <Tale> predicate)
        {
            Tale tale  = null;
            int  num   = 0;
            var  tales = Find.TaleManager.AllTalesListForReading;

            for (int i = 0; i < tales.Count; i++)
            {
                if (tales[i].def == def && predicate(tales[i]) && (tale == null || tales[i].AgeTicks < num))
                {
                    tale = tales[i];
                    num  = tales[i].AgeTicks;
                }
            }
            return(tale);
        }
Beispiel #10
0
 public bool CheckTale()
 {
     if (Props.taleWhenTranslated != null)
     {
         List <Tale> allTalesList = Find.TaleManager.AllTalesListForReading;
         for (int i = 0; i < allTalesList.Count(); i++)
         {
             Tale tale = allTalesList[i];
             if (tale.def == Props.taleWhenTranslated)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #11
0
        public static bool CheckCullUnusedVolatileTales(TaleManager __instance)
        {
            int num = 0;

            for (int i = 0; i < tales(__instance).Count; i++)
            {
                Tale tale1;
                try
                {
                    tale1 = tales(__instance)[i];
                } catch (ArgumentOutOfRangeException)
                {
                    break;
                }
                if (tale1 != null && tale1.def.type == TaleType.Volatile && tale1.Unused)
                {
                    num++;
                }
            }

            while (num > 350)
            {
                Tale  tale = null;
                float num2 = float.MaxValue;
                for (int j = 0; j < tales(__instance).Count; j++)
                {
                    Tale tale2;
                    try
                    {
                        tale2 = tales(__instance)[j];
                    } catch (ArgumentOutOfRangeException)
                    {
                        break;
                    }
                    if (tale2 != null && tale2.def.type == TaleType.Volatile && tale2.Unused && tale2.InterestLevel < num2)
                    {
                        tale = tale2;
                        num2 = tale2.InterestLevel;
                    }
                }

                RemoveTale(__instance, tale);
                num--;
            }
            return(false);
        }
 public BoekInformation(
     Tietel tietel,
     Skrywer skrywer,
     Genres genre,
     OuderdomsGroepe ouderdomsGroep,
     BoekNommer boekNommer,
     Dewey dewey,
     Tale taal)
 {
     this.Tietel         = tietel;
     this.Skrywer        = skrywer;
     this.Genre          = genre;
     this.OuderdomsGroep = ouderdomsGroep;
     this.BoekNommer     = boekNommer;
     this.Dewey          = dewey;
     this.Taal           = taal;
 }
 public static bool RemoveTale(TaleManager __instance, Tale tale)
 {
     if (!tale.Unused)
     {
         Log.Warning("Tried to remove used tale " + tale);
     }
     else
     {
         lock (__instance)
         {
             List <Tale> newTales = new List <Tale>(__instance.tales);
             newTales.Remove(tale);
             __instance.tales = newTales;
         }
     }
     return(false);
 }
Beispiel #14
0
        /// <summary>
        /// A reimplementation of CompArt.InitializeArt() for specific tales.
        /// </summary>
        private static void InitializeArt(CompArt comp, Tale tale)
        {
            if (comp.TaleRef != null)
            {
                comp.TaleRef.ReferenceDestroyed();
            }
            TaleReference taleRef;

            if (tale == null)
            {
                taleRef = TaleReference.Taleless;
            }
            else
            {
                tale.Notify_NewlyUsed();
                taleRef = new TaleReference(tale);
            }
            var traverse = Traverse.Create(comp);

            traverse.Field("taleRef").SetValue(taleRef);
            traverse.Field("titleInt").SetValue(new TaggedString(traverse.Method("GenerateTitle").GetValue <string>()));
        }
        public override float OpinionOffset()
        {
            if (ThoughtUtility.ThoughtNullified(pawn, def))
            {
                return(0f);
            }
            Predicate <Tale> validator = delegate(Tale tale)
            {
                return(tale.DominantPawn == otherPawn);
            };
            Tale latestTale = VSIE_Utils.GetLatestTale(def.taleDef, validator);

            if (latestTale != null)
            {
                float num = 1f;
                if (latestTale.def.type == TaleType.Expirable)
                {
                    float value = (float)latestTale.AgeTicks / (latestTale.def.expireDays * 60000f);
                    num = Mathf.InverseLerp(1f, def.lerpOpinionToZeroAfterDurationPct, value);
                }
                return(base.CurStage.baseOpinionOffset * num);
            }
            return(0f);
        }
 public TaleBookReference(Tale tale)
 {
     this.tale = tale;
     seed      = Rand.Range(0, int.MaxValue);
 }
        private void DoGraphPage(Rect rect)
        {
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width - GraphItemAreaWidth - GraphLegendAreaWidth - FramePadding, GraphAreaHeight);
            Rect legendRect = new Rect(graphRect.xMax + FramePadding, graphRect.yMin, GraphLegendAreaWidth - FramePadding, GraphAreaHeight);

            if (this.historyAutoRecorderGroup != null)
            {
                MainTabWindow_DetailedHistory.marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        MainTabWindow_DetailedHistory.marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                GraphUtility.DrawGraph(graphRect, legendRect, this.graphSection, MainTabWindow_DetailedHistory.marks, this.historyAutoRecorderGroup);
            }
            Text.Font = GameFont.Small;
            float  num = (float)Find.TickManager.TicksGame / 60000f;
            string str;
            float  daysMin;

            if (this.sliderValue > 300f)
            {
                str     = "AllDays";
                daysMin = 0f;
            }
            else
            {
                str     = "Last {0}Days".Translate(this.sliderValue);
                daysMin = Mathf.Max(0f, num - this.sliderValue);
            }
            Rect horizontalRect = new Rect(0f, GraphAreaHeight, 300f, 40f);

            this.sliderValue = Widgets.HorizontalSlider(horizontalRect, this.sliderValue, 5, 301f, true, str);

            this.graphSection = new FloatRange(daysMin, num);

            List <HistoryAutoRecorderGroup> list2 = Find.History.Groups();
            Rect outRect  = new Rect(legendRect.xMax + FramePadding, graphRect.yMin, GraphItemAreaWidth - FramePadding, GraphAreaHeight);
            Rect viewRect = new Rect(0f, 2f, outRect.width, 24f * list2.Count);

            GUI.color = Color.white;
            Widgets.DrawBox(outRect, 1);
            Widgets.BeginScrollView(outRect, ref this.graphItemScrollPosition, viewRect, true);
            Listing_Standard listing = new Listing_Standard();

            listing.Begin(new Rect(0f, 2f, viewRect.width, 9999f));
            for (int i = 0; i < list2.Count; i++)
            {
                HistoryAutoRecorderGroup groupLocal = list2[i];
                if (listing.RadioButton(groupLocal.def.LabelCap, this.historyAutoRecorderGroup == groupLocal))
                {
                    this.historyAutoRecorderGroup = groupLocal;
                    GraphUtility.RecalculateGraph(groupLocal);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total);
                }
            }
            listing.End();
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
Beispiel #18
0
        public static void Draw(Rect rect)
        {
            rect.yMin += 17f;
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width, rect.height - 100f);
            Rect legendRect = new Rect(468f, graphRect.yMax, rect.width - 468f, 80f);
            Rect rect2      = new Rect(0f, legendRect.yMin + 44f, rect.width, 40f);

            if (RecordGraphUtility.CurRecordGroup != null)
            {
                RecordGraphUtility.marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        RecordGraphUtility.marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                RecordGraphUtility.CurRecordGroup.DrawGraph(graphRect, legendRect, RecordGraphUtility.graphSection, RecordGraphUtility.marks);
            }
            Text.Font = GameFont.Small;
            float num = (float)Find.TickManager.TicksGame / 60000f;

            if (Widgets.ButtonText(new Rect(0f, legendRect.yMin, 110f, 40f), "Last30Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(114f, legendRect.yMin, 110f, 40f), "Last100Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(342f, legendRect.yMin, 110f, 40f), "AllDays".Translate(), true, true, true))
            {
                RecordGraphUtility.graphSection = new FloatRange(0f, num);
                SoundDefOf.Click.PlayOneShotOnCamera(null);
            }
            if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate(), true, true, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (RecordIdentifier recordID in RecordGraphUtility.comp.NumericRecords)
                {
                    RecordIdentifier localRecordID = recordID;
                    list.Add(new FloatMenuOption(localRecordID.Label, delegate() {
                        RecordGraphUtility.CurRecordID = localRecordID;
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                FloatMenu window = new FloatMenu(list, "SelectGraph".Translate(), false);
                Find.WindowStack.Add(window);
            }
            if (RecordGraphUtility.CurRecordID.IsVaild)
            {
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(new Rect(rect2.x + 118f, rect2.y, 300f, 40f), RecordGraphUtility.CurRecordID.Label);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.EndGroup();
        }
Beispiel #19
0
        public static TaggedString GenerateTextFromTale(TextGenerationPurpose purpose, Tale tale,
                                                        int seed, RulePackDef extraInclude, CompBook compBook)
        {
            Rand.PushState();
            Rand.Seed = seed;
            string         rootKeyword = null;
            GrammarRequest request     = default(GrammarRequest);

            request.Includes.Add(extraInclude);

            switch (purpose)
            {
            case TextGenerationPurpose.ArtDescription:
                rootKeyword = compBook.Props.nameMaker.RulesImmediate
                              .Where(x => x.keyword != null && x.keyword.Length > 0).RandomElement().keyword;
                //Log.Message("rootKeyword for description: " + rootKeyword);
                if (tale != null && !Rand.Chance(0.2f))
                {
                    request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_HasTale);
                    request.IncludesBare.AddRange(tale.GetTextGenerationIncludes());
                    request.Rules.AddRange(tale.GetTextGenerationRules());
                }
                else
                {
                    request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_Taleless);
                    request.Includes.Add(RulePackDefOf.TalelessImages);
                }
                request.Includes.Add(RulePackDefOf.ArtDescriptionUtility_Global);
                break;

            case TextGenerationPurpose.ArtName:
                rootKeyword = compBook.Props.descriptionMaker.RulesImmediate
                              .Where(x => x.keyword != null && x.keyword.Length > 0).RandomElement().keyword;
                //Log.Message("rootKeyword for name: " + rootKeyword);
                if (tale != null)
                {
                    request.IncludesBare.AddRange(tale.GetTextGenerationIncludes());
                    request.Rules.AddRange(tale.GetTextGenerationRules());
                }
                break;
            }
            string str = GrammarResolver.Resolve(rootKeyword, request, (tale != null) ? tale.def.defName : "null_tale");

            Rand.PopState();
            return(str);
        }
Beispiel #20
0
        public async Task <int> CreateTaleAsync(Tale tale)
        {
            await _context.AddAsync(tale);

            return(await _context.SaveChangesAsync());
        }
Beispiel #21
0
        private void DoPerformancePage(Rect rect)
        {
            rect.yMin += 17f;
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width, 450f);
            Rect legendRect = new Rect(0f, graphRect.yMax, rect.width / 2f, 40f);
            Rect rect2      = new Rect(0f, legendRect.yMax, rect.width, 40f);

            if (historyAutoRecorderGroup != null)
            {
                marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                historyAutoRecorderGroup.DrawGraph(graphRect, legendRect, graphSection, marks);
            }
            Text.Font = GameFont.Small;
            float num = (float)Find.TickManager.TicksGame / 60000f;

            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width, legendRect.yMin, 110f, 40f), "Last30Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 30f), num);
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 110f + 4f, legendRect.yMin, 110f, 40f), "Last100Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 100f), num);
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 228f, legendRect.yMin, 110f, 40f), "Last300Days".Translate()))
            {
                graphSection = new FloatRange(Mathf.Max(0f, num - 300f), num);
            }
            if (Widgets.ButtonText(new Rect(legendRect.xMin + legendRect.width + 342f, legendRect.yMin, 110f, 40f), "AllDays".Translate()))
            {
                graphSection = new FloatRange(0f, num);
            }
            if (Widgets.ButtonText(new Rect(rect2.x, rect2.y, 110f, 40f), "SelectGraph".Translate()))
            {
                List <FloatMenuOption>          list  = new List <FloatMenuOption>();
                List <HistoryAutoRecorderGroup> list2 = Find.History.Groups();
                for (int j = 0; j < list2.Count; j++)
                {
                    HistoryAutoRecorderGroup groupLocal = list2[j];
                    if (groupLocal.def.defName.Contains("RimWar_"))
                    {
                        list.Add(new FloatMenuOption(groupLocal.def.LabelCap, delegate
                        {
                            historyAutoRecorderGroup = groupLocal;
                        }));
                    }
                }
                FloatMenu window = new FloatMenu(list, "SelectGraph".Translate());
                Find.WindowStack.Add(window);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total);
            }
            GUI.EndGroup();
        }