Exemplo n.º 1
0
 public static void DoModalDialogIfNotKnown(ConceptDef conc)
 {
     if (!PlayerKnowledgeDatabase.IsComplete(conc))
     {
         string helpTextAdjusted = conc.HelpTextAdjusted;
         Find.WindowStack.Add(new Dialog_MessageBox(helpTextAdjusted, null, null, null, null, null, false, null, null));
         PlayerKnowledgeDatabase.KnowledgeDemonstrated(conc, KnowledgeAmount.Total);
     }
 }
Exemplo n.º 2
0
 private static float GetOpportunity(ConceptDef conc)
 {
     if (opportunities.TryGetValue(conc, out float value))
     {
         return(value);
     }
     opportunities[conc] = 0f;
     return(0f);
 }
		private int DisplayPriority(ConceptDef conc)
		{
			int num = 1;
			if (MatchesSearchString(conc))
			{
				num += 10000;
			}
			return num;
		}
Exemplo n.º 4
0
 public override void Notify_KnowledgeDemonstrated(ConceptDef conc)
 {
     if (this.def == conc && PlayerKnowledgeDatabase.GetKnowledge(conc) > 0.2f)
     {
         if (!this.Expiring)
         {
             this.expiryTime = Time.timeSinceLevelLoad + 2.1f;
         }
     }
 }
Exemplo n.º 5
0
        private static float GetOpportunity(ConceptDef conc)
        {
            float result;

            if (LessonAutoActivator.opportunities.TryGetValue(conc, out result))
            {
                return(result);
            }
            LessonAutoActivator.opportunities[conc] = 0f;
            return(0f);
        }
 public bool TryActivateConcept(ConceptDef conc)
 {
     if (this.activeConcepts.Contains(conc))
     {
         return(false);
     }
     this.activeConcepts.Add(conc);
     SoundDefOf.LessonActivated.PlayOneShotOnCamera(null);
     this.lastConceptActivateRealTime = RealTime.LastRealTime;
     return(true);
 }
Exemplo n.º 7
0
        public static void SetKnowledge(ConceptDef def, float value)
        {
            float num  = PlayerKnowledgeDatabase.data.knowledge[def];
            float num2 = Mathf.Clamp01(value);

            PlayerKnowledgeDatabase.data.knowledge[def] = num2;
            if (num < 0.999f && num2 >= 0.999f)
            {
                PlayerKnowledgeDatabase.NewlyLearned(def);
            }
        }
        public static void SetKnowledge(ConceptDef def, float value)
        {
            float num  = data.knowledge[def.defName];
            float num2 = Mathf.Clamp01(value);

            data.knowledge[def.defName] = num2;
            if (num < 0.999f && num2 >= 0.999f)
            {
                NewlyLearned(def);
            }
        }
		public bool TryActivateConcept(ConceptDef conc)
		{
			if (activeConcepts.Contains(conc))
			{
				return false;
			}
			activeConcepts.Add(conc);
			SoundDefOf.Lesson_Activated.PlayOneShotOnCamera();
			lastConceptActivateRealTime = RealTime.LastRealTime;
			return true;
		}
Exemplo n.º 10
0
        public static void KnowledgeDemonstrated(ConceptDef conc, KnowledgeAmount know)
        {
            float num;

            switch (know)
            {
            case KnowledgeAmount.FrameDisplayed:
                num = ((Event.current.type != EventType.Repaint) ? 0f : 0.004f);
                break;

            case KnowledgeAmount.FrameInteraction:
                num = 0.008f;
                break;

            case KnowledgeAmount.TinyInteraction:
                num = 0.03f;
                break;

            case KnowledgeAmount.SmallInteraction:
                num = 0.1f;
                break;

            case KnowledgeAmount.SpecificInteraction:
                num = 0.4f;
                break;

            case KnowledgeAmount.Total:
                num = 1f;
                break;

            case KnowledgeAmount.NoteClosed:
                num = 0.5f;
                break;

            case KnowledgeAmount.NoteTaught:
                num = 1f;
                break;

            default:
                throw new NotImplementedException();
            }
            if (num <= 0f)
            {
                return;
            }
            PlayerKnowledgeDatabase.SetKnowledge(conc, PlayerKnowledgeDatabase.GetKnowledge(conc) + num);
            LessonAutoActivator.Notify_KnowledgeDemonstrated(conc);
            if (Find.ActiveLesson != null)
            {
                Find.ActiveLesson.Notify_KnowledgeDemonstrated(conc);
            }
        }
Exemplo n.º 11
0
        private Rect DrawConceptListRow(float x, float y, float width, ConceptDef conc)
        {
            float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conc);
            bool  flag      = PlayerKnowledgeDatabase.IsComplete(conc);
            bool  flag2     = !flag && knowledge > 0f;
            float num       = Text.CalcHeight(conc.LabelCap, width);

            if (flag2)
            {
                num = num;
            }
            Rect rect = new Rect(x, y, width, num);

            if (flag2)
            {
                Rect rect2 = new Rect(rect);
                rect2.yMin += 1f;
                rect2.yMax -= 1f;
                Widgets.FillableBar(rect2, PlayerKnowledgeDatabase.GetKnowledge(conc), LearningReadout.ProgressBarFillTex, LearningReadout.ProgressBarBGTex, false);
            }
            if (flag)
            {
                GUI.DrawTexture(rect, BaseContent.GreyTex);
            }
            if (this.selectedConcept == conc)
            {
                GUI.DrawTexture(rect, TexUI.HighlightSelectedTex);
            }
            Widgets.DrawHighlightIfMouseover(rect);
            if (this.MatchesSearchString(conc))
            {
                Widgets.DrawHighlight(rect);
            }
            Widgets.Label(rect, conc.LabelCap);
            if (Mouse.IsOver(rect) && this.selectedConcept == null)
            {
                this.mouseoverConcept = conc;
            }
            if (Widgets.ButtonInvisible(rect, true))
            {
                if (this.selectedConcept == conc)
                {
                    this.selectedConcept = null;
                }
                else
                {
                    this.selectedConcept = conc;
                }
                SoundDefOf.PageChange.PlayOneShotOnCamera(null);
            }
            return(rect);
        }
		private Rect DrawConceptListRow(float x, float y, float width, ConceptDef conc)
		{
			float knowledge = PlayerKnowledgeDatabase.GetKnowledge(conc);
			bool num = PlayerKnowledgeDatabase.IsComplete(conc);
			bool num2 = !num && knowledge > 0f;
			float num3 = Text.CalcHeight(conc.LabelCap, width);
			if (num2)
			{
				num3 += 0f;
			}
			Rect rect = new Rect(x, y, width, num3);
			if (num2)
			{
				Rect rect2 = new Rect(rect);
				rect2.yMin += 1f;
				rect2.yMax -= 1f;
				Widgets.FillableBar(rect2, PlayerKnowledgeDatabase.GetKnowledge(conc), ProgressBarFillTex, ProgressBarBGTex, doBorder: false);
			}
			if (num)
			{
				GUI.DrawTexture(rect, BaseContent.GreyTex);
			}
			if (selectedConcept == conc)
			{
				GUI.DrawTexture(rect, TexUI.HighlightSelectedTex);
			}
			Widgets.DrawHighlightIfMouseover(rect);
			if (MatchesSearchString(conc))
			{
				Widgets.DrawHighlight(rect);
			}
			Widgets.Label(rect, conc.LabelCap);
			if (Mouse.IsOver(rect) && selectedConcept == null)
			{
				mouseoverConcept = conc;
			}
			if (Widgets.ButtonInvisible(rect))
			{
				if (selectedConcept == conc)
				{
					selectedConcept = null;
				}
				else
				{
					selectedConcept = conc;
				}
				SoundDefOf.PageChange.PlayOneShotOnCamera();
			}
			return rect;
		}
Exemplo n.º 13
0
 public void Notify_ConceptNewlyLearned(ConceptDef conc)
 {
     if (this.activeConcepts.Contains(conc) || this.selectedConcept == conc)
     {
         SoundDefOf.Lesson_Deactivated.PlayOneShotOnCamera(null);
         SoundDefOf.CommsWindow_Close.PlayOneShotOnCamera(null);
     }
     if (this.activeConcepts.Contains(conc))
     {
         this.activeConcepts.Remove(conc);
     }
     if (this.selectedConcept == conc)
     {
         this.selectedConcept = null;
     }
 }
Exemplo n.º 14
0
        private static float GetOpportunity(ConceptDef conc)
        {
            float num;
            float result;

            if (LessonAutoActivator.opportunities.TryGetValue(conc, out num))
            {
                result = num;
            }
            else
            {
                LessonAutoActivator.opportunities[conc] = 0f;
                result = 0f;
            }
            return(result);
        }
Exemplo n.º 15
0
        public bool TryActivateConcept(ConceptDef conc)
        {
            bool result;

            if (this.activeConcepts.Contains(conc))
            {
                result = false;
            }
            else
            {
                this.activeConcepts.Add(conc);
                SoundDefOf.Lesson_Activated.PlayOneShotOnCamera(null);
                this.lastConceptActivateRealTime = RealTime.LastRealTime;
                result = true;
            }
            return(result);
        }
Exemplo n.º 16
0
        private static ConceptDef MostDesiredConcept()
        {
            float             num    = -9999f;
            ConceptDef        result = null;
            List <ConceptDef> allDefsListForReading = DefDatabase <ConceptDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                ConceptDef conceptDef = allDefsListForReading[i];
                float      desire     = GetDesire(conceptDef);
                if (desire > num && (!conceptDef.needsOpportunity || !(GetOpportunity(conceptDef) < 0.1f)) && !(PlayerKnowledgeDatabase.GetKnowledge(conceptDef) > 0.15f))
                {
                    num    = desire;
                    result = conceptDef;
                }
            }
            return(result);
        }
Exemplo n.º 17
0
 private static float GetDesire(ConceptDef conc)
 {
     if (PlayerKnowledgeDatabase.IsComplete(conc))
     {
         return(0f);
     }
     if (Find.Tutor.learningReadout.IsActive(conc))
     {
         return(0f);
     }
     if (Current.ProgramState != conc.gameMode)
     {
         return(0f);
     }
     if (conc.needsOpportunity && GetOpportunity(conc) < 0.1f)
     {
         return(0f);
     }
     return((0f + conc.priority + GetOpportunity(conc) / 100f * 60f) * (1f - PlayerKnowledgeDatabase.GetKnowledge(conc)));
 }
		public void LearningReadoutOnGUI()
		{
			if (!TutorSystem.TutorialMode && TutorSystem.AdaptiveTrainingEnabled && (Find.PlaySettings.showLearningHelper || activeConcepts.Count != 0) && !Find.WindowStack.IsOpen<Screen_Credits>())
			{
				float b = (float)UI.screenHeight / 2f;
				float a = contentHeight + 14f;
				windowRect = new Rect((float)UI.screenWidth - 8f - 200f, 8f, 200f, Mathf.Min(a, b));
				Rect rect = windowRect;
				Find.WindowStack.ImmediateWindow(76136312, windowRect, WindowLayer.Super, windowOnGUICached, doBackground: false);
				float num = Time.realtimeSinceStartup - lastConceptActivateRealTime;
				if (num < 1f && num > 0f)
				{
					GenUI.DrawFlash(rect.x, rect.center.y, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num) * 0.85f, new Color(0.8f, 0.77f, 0.53f));
				}
				ConceptDef conceptDef = ((selectedConcept != null) ? selectedConcept : mouseoverConcept);
				if (conceptDef != null)
				{
					DrawInfoPane(conceptDef);
					conceptDef.HighlightAllTags();
				}
				mouseoverConcept = null;
			}
		}
Exemplo n.º 19
0
        private static float GetDesire(ConceptDef conc)
        {
            if (PlayerKnowledgeDatabase.IsComplete(conc))
            {
                return(0f);
            }
            if (Find.Tutor.learningReadout.IsActive(conc))
            {
                return(0f);
            }
            if (Current.ProgramState != conc.gameMode)
            {
                return(0f);
            }
            if (conc.needsOpportunity && LessonAutoActivator.GetOpportunity(conc) < 0.10000000149011612)
            {
                return(0f);
            }
            float num = 0f;

            num += conc.priority;
            num  = (float)(num + LessonAutoActivator.GetOpportunity(conc) / 100.0 * 60.0);
            return((float)(num * (1.0 - PlayerKnowledgeDatabase.GetKnowledge(conc))));
        }
Exemplo n.º 20
0
 private static bool <ExposeData> m__0(ConceptDef c)
 {
     return(PlayerKnowledgeDatabase.IsComplete(c));
 }
Exemplo n.º 21
0
        private Rect DrawInfoPane(ConceptDef conc)
        {
            float knowledge       = PlayerKnowledgeDatabase.GetKnowledge(conc);
            bool  complete        = PlayerKnowledgeDatabase.IsComplete(conc);
            bool  drawProgressBar = !complete && knowledge > 0f;

            Text.Font = GameFont.Medium;
            float titleHeight = Text.CalcHeight(conc.LabelCap, 276f);

            Text.Font = GameFont.Small;
            float textHeight = Text.CalcHeight(conc.HelpTextAdjusted, 296f);
            float num        = titleHeight + textHeight + 14f + 5f;

            if (this.selectedConcept == conc)
            {
                num += 40f;
            }
            if (drawProgressBar)
            {
                num += 30f;
            }
            Rect outRect  = new Rect((float)UI.screenWidth - 8f - 200f - 8f - 310f, 8f, 310f, num);
            Rect outRect2 = outRect;

            Find.WindowStack.ImmediateWindow(987612111, outRect, WindowLayer.Super, delegate
            {
                outRect   = outRect.AtZero();
                Rect rect = outRect.ContractedBy(7f);
                Widgets.DrawShadowAround(outRect);
                Widgets.DrawWindowBackgroundTutor(outRect);
                Rect rect2   = rect;
                rect2.width -= 20f;
                rect2.height = titleHeight + 5f;
                Text.Font    = GameFont.Medium;
                Widgets.Label(rect2, conc.LabelCap);
                Text.Font    = GameFont.Small;
                Rect rect3   = rect;
                rect3.yMin   = rect2.yMax;
                rect3.height = textHeight;
                Widgets.Label(rect3, conc.HelpTextAdjusted);
                if (drawProgressBar)
                {
                    Rect rect4   = rect;
                    rect4.yMin   = rect3.yMax;
                    rect4.height = 30f;
                    Widgets.FillableBar(rect4, PlayerKnowledgeDatabase.GetKnowledge(conc), LearningReadout.ProgressBarFillTex);
                }
                if (this.selectedConcept == conc)
                {
                    if (Widgets.CloseButtonFor(outRect))
                    {
                        this.selectedConcept = null;
                        SoundDefOf.PageChange.PlayOneShotOnCamera(null);
                    }
                    Rect rect5 = new Rect(rect.center.x - 70f, rect.yMax - 30f, 140f, 30f);
                    if (!complete)
                    {
                        if (Widgets.ButtonText(rect5, "MarkLearned".Translate(), true, false, true))
                        {
                            this.selectedConcept = null;
                            SoundDefOf.PageChange.PlayOneShotOnCamera(null);
                            PlayerKnowledgeDatabase.SetKnowledge(conc, 1f);
                        }
                    }
                    else
                    {
                        GUI.color   = new Color(1f, 1f, 1f, 0.5f);
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(rect5, "AlreadyLearned".Translate());
                        Text.Anchor = TextAnchor.UpperLeft;
                        GUI.color   = Color.white;
                    }
                }
            }, false, false, 1f);
            return(outRect2);
        }
Exemplo n.º 22
0
 private bool MatchesSearchString(ConceptDef conc)
 {
     return(this.searchString != "" && conc.label.IndexOf(this.searchString, StringComparison.OrdinalIgnoreCase) >= 0);
 }
Exemplo n.º 23
0
 public void LearningReadoutOnGUI()
 {
     if (!TutorSystem.TutorialMode && TutorSystem.AdaptiveTrainingEnabled)
     {
         if (Find.PlaySettings.showLearningHelper || this.activeConcepts.Count != 0)
         {
             if (!Find.WindowStack.IsOpen <Screen_Credits>())
             {
                 float b        = (float)UI.screenHeight / 2f;
                 float a        = this.contentHeight + 14f;
                 Rect  outRect  = new Rect((float)UI.screenWidth - 8f - 200f, 8f, 200f, Mathf.Min(a, b));
                 Rect  outRect2 = outRect;
                 Find.WindowStack.ImmediateWindow(76136312, outRect, WindowLayer.Super, delegate
                 {
                     outRect       = outRect.AtZero();
                     Rect rect     = outRect.ContractedBy(7f);
                     Rect viewRect = rect.AtZero();
                     bool flag     = this.contentHeight > rect.height;
                     Widgets.DrawWindowBackgroundTutor(outRect);
                     if (flag)
                     {
                         viewRect.height     = this.contentHeight + 40f;
                         viewRect.width     -= 20f;
                         this.scrollPosition = GUI.BeginScrollView(rect, this.scrollPosition, viewRect);
                     }
                     else
                     {
                         GUI.BeginGroup(rect);
                     }
                     float num2 = 0f;
                     Text.Font  = GameFont.Small;
                     Rect rect2 = new Rect(0f, 0f, viewRect.width - 24f, 24f);
                     Widgets.Label(rect2, "LearningHelper".Translate());
                     num2         = rect2.yMax;
                     Rect butRect = new Rect(rect2.xMax, rect2.y, 24f, 24f);
                     if (Widgets.ButtonImage(butRect, this.showAllMode ? TexButton.Minus : TexButton.Plus))
                     {
                         this.showAllMode = !this.showAllMode;
                         if (this.showAllMode)
                         {
                             SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                         }
                         else
                         {
                             SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                         }
                     }
                     if (this.showAllMode)
                     {
                         Rect rect3        = new Rect(0f, num2, viewRect.width - 20f - 2f, 28f);
                         this.searchString = this.FilterSearchStringInput(Widgets.TextField(rect3, this.searchString));
                         if (this.searchString == "")
                         {
                             GUI.color   = new Color(0.6f, 0.6f, 0.6f, 1f);
                             Text.Anchor = TextAnchor.MiddleLeft;
                             Rect rect4  = rect3;
                             rect4.xMin += 7f;
                             Widgets.Label(rect4, "Filter".Translate() + "...");
                             Text.Anchor = TextAnchor.UpperLeft;
                             GUI.color   = Color.white;
                         }
                         Rect butRect2 = new Rect(viewRect.width - 20f, num2 + 14f - 10f, 20f, 20f);
                         if (Widgets.ButtonImage(butRect2, TexButton.CloseXSmall))
                         {
                             this.searchString = "";
                             SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                         }
                         num2 = rect3.yMax + 4f;
                     }
                     IEnumerable <ConceptDef> enumerable = this.showAllMode ? DefDatabase <ConceptDef> .AllDefs : this.activeConcepts;
                     if (enumerable.Any <ConceptDef>())
                     {
                         GUI.color = new Color(1f, 1f, 1f, 0.5f);
                         Widgets.DrawLineHorizontal(0f, num2, viewRect.width);
                         GUI.color = Color.white;
                         num2     += 4f;
                     }
                     if (this.showAllMode)
                     {
                         enumerable = from c in enumerable
                                      orderby this.DisplayPriority(c) descending, c.label
                         select c;
                     }
                     foreach (ConceptDef conceptDef2 in enumerable)
                     {
                         if (!conceptDef2.TriggeredDirect)
                         {
                             num2 = this.DrawConceptListRow(0f, num2, viewRect.width, conceptDef2).yMax;
                         }
                     }
                     this.contentHeight = num2;
                     if (flag)
                     {
                         GUI.EndScrollView();
                     }
                     else
                     {
                         GUI.EndGroup();
                     }
                 }, false, false, 1f);
                 float num = Time.realtimeSinceStartup - this.lastConceptActivateRealTime;
                 if (num < 1f && num > 0f)
                 {
                     GenUI.DrawFlash(outRect2.x, outRect2.center.y, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num) * 0.85f, new Color(0.8f, 0.77f, 0.53f));
                 }
                 ConceptDef conceptDef = (this.selectedConcept == null) ? this.mouseoverConcept : this.selectedConcept;
                 if (conceptDef != null)
                 {
                     this.DrawInfoPane(conceptDef);
                     conceptDef.HighlightAllTags();
                 }
                 this.mouseoverConcept = null;
             }
         }
     }
 }
Exemplo n.º 24
0
 private static float <DebugForceInitiateBestLessonNow> m__1(ConceptDef def)
 {
     return(LessonAutoActivator.GetDesire(def));
 }
Exemplo n.º 25
0
 private static float <DebugString> m__0(ConceptDef co)
 {
     return(LessonAutoActivator.GetDesire(co));
 }
Exemplo n.º 26
0
 internal int <> m__1(ConceptDef c)
 {
     return(this.$this.DisplayPriority(c));
 }
Exemplo n.º 27
0
 private static string <> m__2(ConceptDef c)
 {
     return(c.label);
 }
Exemplo n.º 28
0
 public static void TeachOpportunity(ConceptDef conc, OpportunityType opp)
 {
     LessonAutoActivator.TeachOpportunity(conc, null, opp);
 }
Exemplo n.º 29
0
 public bool IsActive(ConceptDef conc)
 {
     return(this.activeConcepts.Contains(conc));
 }
Exemplo n.º 30
0
 public static void LessonAutoActivatorUpdate()
 {
     if (TutorSystem.AdaptiveTrainingEnabled && Current.Game != null && !Find.Tutor.learningReadout.ShowAllMode)
     {
         LessonAutoActivator.timeSinceLastLesson += RealTime.realDeltaTime;
         if (Current.ProgramState == ProgramState.Playing)
         {
             if (Time.timeSinceLevelLoad < 8f || Find.WindowStack.SecondsSinceClosedGameStartDialog < 8f || Find.TickManager.NotPlaying)
             {
                 return;
             }
         }
         for (int i = LessonAutoActivator.alertingConcepts.Count - 1; i >= 0; i--)
         {
             if (PlayerKnowledgeDatabase.IsComplete(LessonAutoActivator.alertingConcepts[i]))
             {
                 LessonAutoActivator.alertingConcepts.RemoveAt(i);
             }
         }
         if (Time.frameCount % 15 == 0 && Find.ActiveLesson.Current == null)
         {
             for (int j = 0; j < DefDatabase <ConceptDef> .AllDefsListForReading.Count; j++)
             {
                 ConceptDef conceptDef = DefDatabase <ConceptDef> .AllDefsListForReading[j];
                 if (!PlayerKnowledgeDatabase.IsComplete(conceptDef))
                 {
                     float num = PlayerKnowledgeDatabase.GetKnowledge(conceptDef);
                     num -= 0.00015f * Time.deltaTime * 15f;
                     if (num < 0f)
                     {
                         num = 0f;
                     }
                     PlayerKnowledgeDatabase.SetKnowledge(conceptDef, num);
                     if (conceptDef.opportunityDecays)
                     {
                         float num2 = LessonAutoActivator.GetOpportunity(conceptDef);
                         num2 -= 0.4f * Time.deltaTime * 15f;
                         if (num2 < 0f)
                         {
                             num2 = 0f;
                         }
                         LessonAutoActivator.opportunities[conceptDef] = num2;
                     }
                 }
             }
             if (Find.Tutor.learningReadout.ActiveConceptsCount < 3)
             {
                 ConceptDef conceptDef2 = LessonAutoActivator.MostDesiredConcept();
                 if (conceptDef2 != null)
                 {
                     float desire = LessonAutoActivator.GetDesire(conceptDef2);
                     if (desire > 0.1f && LessonAutoActivator.RelaxDesire < desire)
                     {
                         LessonAutoActivator.TryInitiateLesson(conceptDef2);
                     }
                 }
             }
             else
             {
                 LessonAutoActivator.SetLastLessonTimeToNow();
             }
         }
     }
 }