public override void PostGameStart()
 {
     if (Find.GameInitData.startedFromEntry)
     {
         Find.MusicManagerPlay.disabled = true;
         Find.WindowStack.Notify_GameStartDialogOpened();
         DiaNode   diaNode   = new DiaNode(text.NullOrEmpty() ? textKey.TranslateSimple() : text);
         DiaOption diaOption = new DiaOption();
         diaOption.resolveTree = true;
         diaOption.clickSound  = null;
         diaNode.options.Add(diaOption);
         Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode);
         dialog_NodeTree.soundClose  = ((closeSound != null) ? closeSound : SoundDefOf.GameStartSting);
         dialog_NodeTree.closeAction = delegate
         {
             Find.MusicManagerPlay.ForceSilenceFor(7f);
             Find.MusicManagerPlay.disabled = false;
             Find.WindowStack.Notify_GameStartDialogClosed();
             Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
             TutorSystem.Notify_Event("GameStartDialogClosed");
         };
         Find.WindowStack.Add(dialog_NodeTree);
         Find.Archive.Add(new ArchivedDialog(diaNode.text));
     }
 }
 public override void PostOpen()
 {
     base.PostOpen();
     Find.GameInitData.ChooseRandomStartingTile();
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.WorldCameraMovement, OpportunityType.Important);
     TutorSystem.Notify_Event("PageStart-SelectLandingSite");
 }
예제 #3
0
        private List <FloatMenuOption> < FillTab > m__0()
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++)
            {
                if (this.SelTable.def.AllRecipes[i].AvailableNow)
                {
                    RecipeDef recipe = this.SelTable.def.AllRecipes[i];
                    list.Add(new FloatMenuOption(recipe.LabelCap, delegate()
                    {
                        if (!this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }
                        Bill bill = recipe.MakeNewBill();
                        this.SelTable.billStack.AddBill(bill);
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }
                        if (TutorSystem.TutorialMode)
                        {
                            TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                        }
                    }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe), null));
                }
            }
            if (!list.Any <FloatMenuOption>())
            {
                list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            return(list);
        }
예제 #4
0
 private static void <PostGameStart> m__0()
 {
     Find.MusicManagerPlay.ForceSilenceFor(7f);
     Find.MusicManagerPlay.disabled = false;
     Find.WindowStack.Notify_GameStartDialogClosed();
     Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
     TutorSystem.Notify_Event("GameStartDialogClosed");
 }
예제 #5
0
 private void RandomizeCurPawn()
 {
     if (TutorSystem.AllowAction("RandomizePawn"))
     {
         this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
         TutorSystem.Notify_Event("RandomizePawn");
     }
 }
 private static void NewlyLearned(ConceptDef conc)
 {
     TutorSystem.Notify_Event("ConceptLearned-" + conc.defName);
     if (Find.Tutor != null)
     {
         Find.Tutor.learningReadout.Notify_ConceptNewlyLearned(conc);
     }
 }
예제 #7
0
파일: Page.cs 프로젝트: ehtnnd/RW-Decompile
 protected virtual void DoBack()
 {
     if (this.prev != null)
     {
         Find.WindowStack.Add(this.prev);
     }
     TutorSystem.Notify_Event("PageClosed");
     TutorSystem.Notify_Event("GoToPrevPage");
     this.Close(true);
 }
예제 #8
0
 protected virtual void DoBack()
 {
     TutorSystem.Notify_Event("PageClosed");
     TutorSystem.Notify_Event("GoToPrevPage");
     if (prev != null)
     {
         Find.WindowStack.Add(prev);
     }
     Close();
 }
예제 #9
0
 public override void PostDeactivated()
 {
     SoundDefOf.CommsWindow_Close.PlayOneShotOnCamera(null);
     TutorSystem.Notify_Event("InstructionDeactivated-" + this.def.defName);
     if (this.def.endTutorial)
     {
         Find.ActiveLesson.Deactivate();
         Find.TutorialState.Notify_TutorialEnding();
         LessonAutoActivator.Notify_TutorialEnding();
     }
 }
예제 #10
0
 private void RandomizeCurPawn()
 {
     if (TutorSystem.AllowAction("RandomizePawn"))
     {
         int num = 0;
         do
         {
             curPawn = StartingPawnUtility.RandomizeInPlace(curPawn);
             num++;
         }while (num <= 20 && !StartingPawnUtility.WorkTypeRequirementsSatisfied());
         TutorSystem.Notify_Event("RandomizePawn");
     }
 }
예제 #11
0
파일: Page.cs 프로젝트: ehtnnd/RW-Decompile
 protected virtual void DoNext()
 {
     if (this.next != null)
     {
         Find.WindowStack.Add(this.next);
     }
     if (this.nextAct != null)
     {
         this.nextAct();
     }
     TutorSystem.Notify_Event("PageClosed");
     TutorSystem.Notify_Event("GoToNextPage");
     this.Close(true);
 }
예제 #12
0
            internal void <> m__0()
            {
                if (!this.$this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => this.recipe.PawnSatisfiesSkillRequirements(col)))
                {
                    Bill.CreateNoPawnsWithSkillDialog(this.recipe);
                }
                Bill bill = this.recipe.MakeNewBill();

                this.$this.SelTable.billStack.AddBill(bill);
                if (this.recipe.conceptLearned != null)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(this.recipe.conceptLearned, KnowledgeAmount.Total);
                }
                if (TutorSystem.TutorialMode)
                {
                    TutorSystem.Notify_Event("AddBill-" + this.recipe.LabelCap);
                }
            }
예제 #13
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Vector2 winSize  = ITab_Bills.WinSize;
            float   x        = winSize.x;
            Vector2 winSize2 = ITab_Bills.WinSize;
            Rect    rect2    = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++)
                {
                    ITab_Bills tab_Bills = this;
                    if (this.SelTable.def.AllRecipes[i].AvailableNow)
                    {
                        RecipeDef recipe = this.SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill = recipe.MakeNewBill();
                            tab_Bills.SelTable.billStack.AddBill(bill);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap);
                            }
                        }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe), null));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                return(list);
            };

            this.mouseoverBill = this.SelTable.billStack.DoListing(rect2, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight);
        }
        private void RandomizeCurPawn()
        {
            if (!TutorSystem.AllowAction("RandomizePawn"))
            {
                return;
            }
            int num = 0;

            do
            {
                this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
                num++;
                if (num > 20)
                {
                    break;
                }
            }while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
            TutorSystem.Notify_Event("RandomizePawn");
        }
예제 #15
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(new EventPack(base.TutorTagDesignate, c)))
            {
                return;
            }
            if (DebugSettings.godMode || entDef.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef) == 0f)
            {
                if (entDef is TerrainDef)
                {
                    base.Map.terrainGrid.SetTerrain(c, (TerrainDef)entDef);
                }
                else
                {
                    Thing thing = ThingMaker.MakeThing((ThingDef)entDef, stuffDef);
                    thing.SetFactionDirect(Faction.OfPlayer);
                    GenSpawn.Spawn(thing, c, base.Map, placingRot);
                }
            }
            else
            {
                GenSpawn.WipeExistingThings(c, placingRot, entDef.blueprintDef, base.Map, DestroyMode.Deconstruct);
                GenConstruct.PlaceBlueprintForBuild(entDef, c, base.Map, placingRot, Faction.OfPlayer, stuffDef);
            }
            MoteMaker.ThrowMetaPuffs(GenAdj.OccupiedRect(c, placingRot, entDef.Size), base.Map);
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.IsOrbitalTradeBeacon)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BuildOrbitalTradeBeacon, KnowledgeAmount.Total);
            }
            if (TutorSystem.TutorialMode)
            {
                TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, c));
            }
            if (entDef.PlaceWorkers != null)
            {
                for (int i = 0; i < entDef.PlaceWorkers.Count; i++)
                {
                    entDef.PlaceWorkers[i].PostPlace(base.Map, entDef, c, placingRot);
                }
            }
        }
 public void ToggleTab(MainButtonDef newTab, bool playSound = true)
 {
     if (this.OpenTab == null && newTab == null)
     {
         return;
     }
     if (this.OpenTab == newTab)
     {
         Find.WindowStack.TryRemove(this.OpenTab.TabWindow, true);
         if (playSound)
         {
             SoundDefOf.TabClose.PlayOneShotOnCamera(null);
         }
     }
     else
     {
         if (this.OpenTab != null)
         {
             Find.WindowStack.TryRemove(this.OpenTab.TabWindow, true);
         }
         if (newTab != null)
         {
             Find.WindowStack.Add(newTab.TabWindow);
         }
         if (playSound)
         {
             if (newTab == null)
             {
                 SoundDefOf.TabClose.PlayOneShotOnCamera(null);
             }
             else
             {
                 SoundDefOf.TabOpen.PlayOneShotOnCamera(null);
             }
         }
         if (TutorSystem.TutorialMode && newTab != null)
         {
             TutorSystem.Notify_Event("Open-MainTab-" + newTab.defName);
         }
     }
 }
        public override void DesignateMultiCell(IEnumerable <IntVec3> cells)
        {
            List <IntVec3> list = cells.ToList <IntVec3>();

            if (list.Count == 1)
            {
                Zone zone = base.Map.zoneManager.ZoneAt(list[0]);
                if (zone != null)
                {
                    if (zone.GetType() == this.zoneTypeToPlace)
                    {
                        this.SelectedZone = zone;
                    }
                    return;
                }
            }
            if (this.SelectedZone == null)
            {
                Zone zone2 = null;
                foreach (IntVec3 c3 in cells)
                {
                    Zone zone3 = base.Map.zoneManager.ZoneAt(c3);
                    if (zone3 != null && zone3.GetType() == this.zoneTypeToPlace)
                    {
                        if (zone2 == null)
                        {
                            zone2 = zone3;
                        }
                        else if (zone3 != zone2)
                        {
                            zone2 = null;
                            break;
                        }
                    }
                }
                this.SelectedZone = zone2;
            }
            list.RemoveAll((IntVec3 c) => base.Map.zoneManager.ZoneAt(c) != null);
            if (list.Count == 0)
            {
                return;
            }
            if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(new EventPack(base.TutorTagDesignate, list)))
            {
                return;
            }
            if (this.SelectedZone == null)
            {
                this.SelectedZone = this.MakeNewZone();
                base.Map.zoneManager.RegisterZone(this.SelectedZone);
                this.SelectedZone.AddCell(list[0]);
                list.RemoveAt(0);
            }
            bool somethingSucceeded;

            for (;;)
            {
                somethingSucceeded = true;
                int count = list.Count;
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    bool flag = false;
                    for (int j = 0; j < 4; j++)
                    {
                        IntVec3 c2 = list[i] + GenAdj.CardinalDirections[j];
                        if (c2.InBounds(base.Map))
                        {
                            if (base.Map.zoneManager.ZoneAt(c2) == this.SelectedZone)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        this.SelectedZone.AddCell(list[i]);
                        list.RemoveAt(i);
                    }
                }
                if (list.Count == 0)
                {
                    break;
                }
                if (list.Count == count)
                {
                    this.SelectedZone = this.MakeNewZone();
                    base.Map.zoneManager.RegisterZone(this.SelectedZone);
                    this.SelectedZone.AddCell(list[0]);
                    list.RemoveAt(0);
                }
            }
            this.SelectedZone.CheckContiguous();
            base.Finalize(somethingSucceeded);
            TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, list));
        }
예제 #18
0
        protected override void DoConfigInterface(Rect baseRect, Color baseColor)
        {
            Rect rect = new Rect(28f, 32f, 100f, 30f);

            GUI.color = new Color(1f, 1f, 1f, 0.65f);
            Widgets.Label(rect, RepeatInfoText);
            GUI.color = baseColor;
            WidgetRow widgetRow = new WidgetRow(baseRect.xMax, baseRect.y + 29f, UIDirection.LeftThenUp);

            if (widgetRow.ButtonText("Details".Translate() + "..."))
            {
                Find.WindowStack.Add(new Dialog_BillConfig(this, ((Thing)billStack.billGiver).Position));
            }
            if (widgetRow.ButtonText(repeatMode.LabelCap.PadRight(20)))
            {
                BillRepeatModeUtility.MakeConfigFloatMenu(this);
            }
            if (widgetRow.ButtonIcon(TexButton.Plus))
            {
                if (repeatMode == BillRepeatModeDefOf.Forever)
                {
                    repeatMode  = BillRepeatModeDefOf.RepeatCount;
                    repeatCount = 1;
                }
                else if (repeatMode == BillRepeatModeDefOf.TargetCount)
                {
                    int num = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier();
                    targetCount        += num;
                    unpauseWhenYouHave += num;
                }
                else if (repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    repeatCount += GenUI.CurrentAdjustmentMultiplier();
                }
                SoundDefOf.AmountIncrement.PlayOneShotOnCamera();
                if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount);
                }
            }
            if (widgetRow.ButtonIcon(TexButton.Minus))
            {
                if (repeatMode == BillRepeatModeDefOf.Forever)
                {
                    repeatMode  = BillRepeatModeDefOf.RepeatCount;
                    repeatCount = 1;
                }
                else if (repeatMode == BillRepeatModeDefOf.TargetCount)
                {
                    int num2 = recipe.targetCountAdjustment * GenUI.CurrentAdjustmentMultiplier();
                    targetCount        = Mathf.Max(0, targetCount - num2);
                    unpauseWhenYouHave = Mathf.Max(0, unpauseWhenYouHave - num2);
                }
                else if (repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    repeatCount = Mathf.Max(0, repeatCount - GenUI.CurrentAdjustmentMultiplier());
                }
                SoundDefOf.AmountDecrement.PlayOneShotOnCamera();
                if (TutorSystem.TutorialMode && repeatMode == BillRepeatModeDefOf.RepeatCount)
                {
                    TutorSystem.Notify_Event(recipe.defName + "-RepeatCountSetTo-" + repeatCount);
                }
            }
        }
        private void DrawPawnList(Rect rect)
        {
            Rect rect2 = rect;

            rect2.height = 60f;
            rect2        = rect2.ContractedBy(4f);
            int groupID = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                if (TutorSystem.AllowAction("ReorderPawn"))
                {
                    Pawn item = Find.GameInitData.startingAndOptionalPawns[from];
                    Find.GameInitData.startingAndOptionalPawns.Insert(to, item);
                    Find.GameInitData.startingAndOptionalPawns.RemoveAt((from < to) ? from : (from + 1));
                    TutorSystem.Notify_Event("ReorderPawn");
                    if (to < Find.GameInitData.startingPawnCount && from >= Find.GameInitData.startingPawnCount)
                    {
                        TutorSystem.Notify_Event("ReorderPawnOptionalToStarting");
                    }
                }
            }, ReorderableDirection.Vertical);

            rect2.y += 15f;
            DrawPawnListLabelAbove(rect2, "StartingPawnsSelected".Translate());
            for (int i = 0; i < Find.GameInitData.startingAndOptionalPawns.Count; i++)
            {
                if (i == Find.GameInitData.startingPawnCount)
                {
                    rect2.y += 30f;
                    DrawPawnListLabelAbove(rect2, "StartingPawnsLeftBehind".Translate());
                }
                Pawn pawn = Find.GameInitData.startingAndOptionalPawns[i];
                GUI.BeginGroup(rect2);
                Rect rect3 = new Rect(Vector2.zero, rect2.size);
                Widgets.DrawOptionBackground(rect3, curPawn == pawn);
                MouseoverSounds.DoRegion(rect3);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                GUI.DrawTexture(new Rect(110f - PawnSelectorPortraitSize.x / 2f, 40f - PawnSelectorPortraitSize.y / 2f, PawnSelectorPortraitSize.x, PawnSelectorPortraitSize.y), PortraitsCache.Get(pawn, PawnSelectorPortraitSize));
                GUI.color = Color.white;
                Rect       rect4      = rect3.ContractedBy(4f).Rounded();
                NameTriple nameTriple = pawn.Name as NameTriple;
                Widgets.Label(label: (nameTriple == null) ? pawn.LabelShort : (string.IsNullOrEmpty(nameTriple.Nick) ? nameTriple.First : nameTriple.Nick), rect: rect4.TopPart(0.5f).Rounded());
                if (Text.CalcSize(pawn.story.TitleCap).x > rect4.width)
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleShortCap);
                }
                else
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleCap);
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
                {
                    curPawn = pawn;
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                }
                GUI.EndGroup();
                if (ReorderableWidget.Reorderable(groupID, rect2.ExpandedBy(4f)))
                {
                    Widgets.DrawRectFast(rect2, Widgets.WindowBGFillColor * new Color(1f, 1f, 1f, 0.5f));
                }
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, new TipSignal("DragToReorder".Translate(), pawn.GetHashCode() * 3499));
                }
                rect2.y += 60f;
            }
        }
예제 #20
0
        private void DrawLeftRect(Rect leftOutRect)
        {
            Rect position = leftOutRect;

            GUI.BeginGroup(position);
            if (selectedProject != null)
            {
                Rect outRect  = new Rect(0f, 0f, position.width, 500f);
                Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, leftScrollViewHeight);
                Widgets.BeginScrollView(outRect, ref leftScrollPosition, viewRect);
                float num = 0f;
                Text.Font = GameFont.Medium;
                GenUI.SetLabelAlign(TextAnchor.MiddleLeft);
                Rect rect = new Rect(0f, num, viewRect.width, 50f);
                Widgets.LabelCacheHeight(ref rect, selectedProject.LabelCap);
                GenUI.ResetLabelAlign();
                Text.Font = GameFont.Small;
                num      += rect.height;
                Rect rect2 = new Rect(0f, num, viewRect.width, 0f);
                Widgets.LabelCacheHeight(ref rect2, selectedProject.description);
                num += rect2.height + 10f;
                string text = "ProjectTechLevel".Translate().CapitalizeFirst() + ": " + selectedProject.techLevel.ToStringHuman().CapitalizeFirst() + "\n" + "YourTechLevel".Translate().CapitalizeFirst() + ": " + Faction.OfPlayer.def.techLevel.ToStringHuman().CapitalizeFirst();
                float  num2 = selectedProject.CostFactor(Faction.OfPlayer.def.techLevel);
                if (num2 != 1f)
                {
                    string text2 = text;
                    text = text2 + "\n\n" + "ResearchCostMultiplier".Translate().CapitalizeFirst() + ": " + num2.ToStringPercent() + "\n" + "ResearchCostComparison".Translate(selectedProject.baseCost.ToString("F0"), selectedProject.CostApparent.ToString("F0"));
                }
                Rect rect3 = new Rect(0f, num, viewRect.width, 0f);
                Widgets.LabelCacheHeight(ref rect3, text);
                num = rect3.yMax + 10f;
                float num3 = DrawResearchPrereqs(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject);
                if (num3 > 0f)
                {
                    num += num3 + 15f;
                }
                num += DrawResearchBenchRequirements(rect: new Rect(0f, num, viewRect.width, 500f), project: selectedProject);
                num  = (leftScrollViewHeight = num + 3f);
                Widgets.EndScrollView();
                bool flag  = Prefs.DevMode && selectedProject != Find.ResearchManager.currentProj && !selectedProject.IsFinished;
                Rect rect6 = new Rect(0f, 0f, 90f, 50f);
                if (flag)
                {
                    rect6.x = (outRect.width - (rect6.width * 2f + 20f)) / 2f;
                }
                else
                {
                    rect6.x = (outRect.width - rect6.width) / 2f;
                }
                rect6.y = outRect.y + outRect.height + 20f;
                if (selectedProject.IsFinished)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "Finished".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (selectedProject == Find.ResearchManager.currentProj)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "InProgress".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (!selectedProject.CanStartNow)
                {
                    Widgets.DrawMenuSection(rect6);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Widgets.Label(rect6, "Locked".Translate());
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                else if (Widgets.ButtonText(rect6, "Research".Translate()))
                {
                    SoundDefOf.ResearchStart.PlayOneShotOnCamera();
                    Find.ResearchManager.currentProj = selectedProject;
                    TutorSystem.Notify_Event("StartResearchProject");
                }
                if (flag)
                {
                    Rect rect7 = rect6;
                    rect7.x += rect7.width + 20f;
                    if (Widgets.ButtonText(rect7, "Debug Insta-finish"))
                    {
                        Find.ResearchManager.currentProj = selectedProject;
                        Find.ResearchManager.FinishProject(selectedProject);
                    }
                }
                Rect rect8 = new Rect(15f, rect6.y + rect6.height + 20f, position.width - 30f, 35f);
                Widgets.FillableBar(rect8, selectedProject.ProgressPercent, ResearchBarFillTex, ResearchBarBGTex, doBorder: true);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(rect8, selectedProject.ProgressApparent.ToString("F0") + " / " + selectedProject.CostApparent.ToString("F0"));
                Text.Anchor = TextAnchor.UpperLeft;
            }
            GUI.EndGroup();
        }
 public override void PostOpen()
 {
     base.PostOpen();
     TutorSystem.Notify_Event("PageStart-ConfigureStartingPawns");
 }
예제 #22
0
        internal static void DrawStorytellerSelectionInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard selectedStorytellerInfoListing)
        {
            GUI.BeginGroup(rect);
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                float   height            = rect.height;
                Vector2 portraitSizeLarge = Storyteller.PortraitSizeLarge;
                double  y = height - portraitSizeLarge.y - 1.0;
                Vector2 portraitSizeLarge2 = Storyteller.PortraitSizeLarge;
                float   x = portraitSizeLarge2.x;
                Vector2 portraitSizeLarge3 = Storyteller.PortraitSizeLarge;
                Rect    position           = new Rect(390f, (float)y, x, portraitSizeLarge3.y);
                GUI.DrawTexture(position, chosenStoryteller.portraitLargeTex);
                Widgets.DrawLineHorizontal(0f, rect.height, rect.width);
            }
            Vector2 portraitSizeTiny  = Storyteller.PortraitSizeTiny;
            Rect    outRect           = new Rect(0f, 0f, (float)(portraitSizeTiny.x + 16.0), rect.height);
            Vector2 portraitSizeTiny2 = Storyteller.PortraitSizeTiny;
            float   x2  = portraitSizeTiny2.x;
            float   num = (float)DefDatabase <StorytellerDef> .AllDefs.Count();

            Vector2 portraitSizeTiny3 = Storyteller.PortraitSizeTiny;
            Rect    viewRect          = new Rect(0f, 0f, x2, (float)(num * (portraitSizeTiny3.y + 10.0)));

            Widgets.BeginScrollView(outRect, ref StorytellerUI.scrollPosition, viewRect, true);
            Vector2 portraitSizeTiny4 = Storyteller.PortraitSizeTiny;
            float   x3 = portraitSizeTiny4.x;
            Vector2 portraitSizeTiny5 = Storyteller.PortraitSizeTiny;
            Rect    rect2             = new Rect(0f, 0f, x3, portraitSizeTiny5.y);

            foreach (StorytellerDef item in from tel in DefDatabase <StorytellerDef> .AllDefs
                     orderby tel.listOrder
                     select tel)
            {
                if (item.listVisible)
                {
                    if (Widgets.ButtonImage(rect2, item.portraitTinyTex))
                    {
                        TutorSystem.Notify_Event("ChooseStoryteller");
                        chosenStoryteller = item;
                    }
                    if (chosenStoryteller == item)
                    {
                        GUI.DrawTexture(rect2, StorytellerUI.StorytellerHighlightTex);
                    }
                    rect2.y += (float)(rect2.height + 8.0);
                }
            }
            Widgets.EndScrollView();
            Text.Font = GameFont.Small;
            Rect rect3 = new Rect((float)(outRect.xMax + 8.0), 0f, 240f, 999f);

            Widgets.Label(rect3, "HowStorytellersWork".Translate());
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                Rect rect4 = new Rect((float)(outRect.xMax + 8.0), (float)(outRect.yMin + 200.0), 290f, 0f);
                rect4.height = rect.height - rect4.y;
                Text.Font    = GameFont.Medium;
                Rect rect5 = new Rect((float)(rect4.x + 15.0), (float)(rect4.y - 40.0), 9999f, 40f);
                Widgets.Label(rect5, chosenStoryteller.label);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                selectedStorytellerInfoListing.Begin(rect4);
                selectedStorytellerInfoListing.Label(chosenStoryteller.description, 120f);
                selectedStorytellerInfoListing.Gap(6f);
                foreach (DifficultyDef allDef in DefDatabase <DifficultyDef> .AllDefs)
                {
                    Rect rect6 = selectedStorytellerInfoListing.GetRect(30f);
                    if (Mouse.IsOver(rect6))
                    {
                        Widgets.DrawHighlight(rect6);
                    }
                    TooltipHandler.TipRegion(rect6, allDef.description);
                    if (Widgets.RadioButtonLabeled(rect6, allDef.LabelCap, difficulty == allDef))
                    {
                        difficulty = allDef;
                    }
                }
                selectedStorytellerInfoListing.Gap(30f);
                if (Current.ProgramState == ProgramState.Entry)
                {
                    selectedStorytellerInfoListing.CheckboxLabeled("PermadeathMode".Translate(), ref Find.GameInitData.permadeath, "PermadeathModeInfo".Translate());
                }
                selectedStorytellerInfoListing.End();
            }
            GUI.EndGroup();
        }
예제 #23
0
 public static void Notify_Event(string eventTag, IntVec3 cell)
 {
     TutorSystem.Notify_Event(new EventPack(eventTag, cell));
 }
예제 #24
0
        public override void DesignateMultiCell(IEnumerable <IntVec3> cells)
        {
            List <IntVec3> list = cells.ToList();
            bool           flag = false;

            if (list.Count == 1)
            {
                Zone zone = base.Map.zoneManager.ZoneAt(list[0]);
                if (zone != null)
                {
                    if (zone.GetType() == this.zoneTypeToPlace)
                    {
                        this.SelectedZone = zone;
                    }
                    return;
                }
            }
            if (this.SelectedZone == null)
            {
                Zone zone2 = null;
                foreach (IntVec3 cell in cells)
                {
                    Zone zone3 = base.Map.zoneManager.ZoneAt(cell);
                    if (zone3 != null && zone3.GetType() == this.zoneTypeToPlace)
                    {
                        if (zone2 == null)
                        {
                            zone2 = zone3;
                        }
                        else if (zone3 != zone2)
                        {
                            zone2 = null;
                            break;
                        }
                    }
                }
                this.SelectedZone = zone2;
            }
            list.RemoveAll((IntVec3 c) => base.Map.zoneManager.ZoneAt(c) != null);
            if (list.Count != 0 && (!TutorSystem.TutorialMode || TutorSystem.AllowAction(new EventPack(base.TutorTagDesignate, list))))
            {
                if (this.SelectedZone == null)
                {
                    this.SelectedZone = this.MakeNewZone();
                    this.SelectedZone.AddCell(list[0]);
                    list.RemoveAt(0);
                }
                while (true)
                {
                    flag = true;
                    int count = list.Count;
                    for (int num = list.Count - 1; num >= 0; num--)
                    {
                        bool flag2 = false;
                        for (int i = 0; i < 4; i++)
                        {
                            IntVec3 c2 = list[num] + GenAdj.CardinalDirections[i];
                            if (c2.InBounds(base.Map) && base.Map.zoneManager.ZoneAt(c2) == this.SelectedZone)
                            {
                                flag2 = true;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            this.SelectedZone.AddCell(list[num]);
                            list.RemoveAt(num);
                        }
                    }
                    if (list.Count != 0)
                    {
                        if (list.Count == count)
                        {
                            this.SelectedZone = this.MakeNewZone();
                            this.SelectedZone.AddCell(list[0]);
                            list.RemoveAt(0);
                        }
                        continue;
                    }
                    break;
                }
                this.SelectedZone.CheckContiguous();
                base.Finalize(flag);
                TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, list));
            }
        }
예제 #25
0
        internal static void DrawStorytellerSelectionInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard selectedStorytellerInfoListing)
        {
            GUI.BeginGroup(rect);
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                Rect position = new Rect(390f, rect.height - Storyteller.PortraitSizeLarge.y - 1f, Storyteller.PortraitSizeLarge.x, Storyteller.PortraitSizeLarge.y);
                GUI.DrawTexture(position, chosenStoryteller.portraitLargeTex);
                Widgets.DrawLineHorizontal(0f, rect.height, rect.width);
            }
            Rect outRect  = new Rect(0f, 0f, Storyteller.PortraitSizeTiny.x + 16f, rect.height);
            Rect viewRect = new Rect(0f, 0f, Storyteller.PortraitSizeTiny.x, (float)DefDatabase <StorytellerDef> .AllDefs.Count <StorytellerDef>() * (Storyteller.PortraitSizeTiny.y + 10f));

            Widgets.BeginScrollView(outRect, ref StorytellerUI.scrollPosition, viewRect, true);
            Rect rect2 = new Rect(0f, 0f, Storyteller.PortraitSizeTiny.x, Storyteller.PortraitSizeTiny.y);

            foreach (StorytellerDef current in from tel in DefDatabase <StorytellerDef> .AllDefs
                     orderby tel.listOrder
                     select tel)
            {
                if (current.listVisible)
                {
                    if (Widgets.ButtonImage(rect2, current.portraitTinyTex))
                    {
                        TutorSystem.Notify_Event("ChooseStoryteller");
                        chosenStoryteller = current;
                    }
                    if (chosenStoryteller == current)
                    {
                        GUI.DrawTexture(rect2, StorytellerUI.StorytellerHighlightTex);
                    }
                    rect2.y += rect2.height + 8f;
                }
            }
            Widgets.EndScrollView();
            Text.Font = GameFont.Small;
            Rect rect3 = new Rect(outRect.xMax + 8f, 0f, 240f, 999f);

            Widgets.Label(rect3, "HowStorytellersWork".Translate());
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                Rect rect4 = new Rect(outRect.xMax + 8f, outRect.yMin + 200f, 290f, 0f);
                rect4.height = rect.height - rect4.y;
                Text.Font    = GameFont.Medium;
                Rect rect5 = new Rect(rect4.x + 15f, rect4.y - 40f, 9999f, 40f);
                Widgets.Label(rect5, chosenStoryteller.label);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                selectedStorytellerInfoListing.Begin(rect4);
                selectedStorytellerInfoListing.Label(chosenStoryteller.description, 120f);
                selectedStorytellerInfoListing.Gap(6f);
                foreach (DifficultyDef current2 in DefDatabase <DifficultyDef> .AllDefs)
                {
                    Rect rect6 = selectedStorytellerInfoListing.GetRect(30f);
                    if (Mouse.IsOver(rect6))
                    {
                        Widgets.DrawHighlight(rect6);
                    }
                    TooltipHandler.TipRegion(rect6, current2.description);
                    if (Widgets.RadioButtonLabeled(rect6, current2.LabelCap, difficulty == current2))
                    {
                        difficulty = current2;
                    }
                }
                selectedStorytellerInfoListing.Gap(30f);
                if (Current.ProgramState == ProgramState.Entry)
                {
                    selectedStorytellerInfoListing.CheckboxLabeled("PermadeathMode".Translate(), ref Find.GameInitData.permadeath, "PermadeathModeInfo".Translate());
                }
                selectedStorytellerInfoListing.End();
            }
            GUI.EndGroup();
        }
예제 #26
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            //    this.defaultDesc = this.ability.def.GetTooltip(this.ability.pawn);
            var rect        = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            var isMouseOver = false;

            if (Mouse.IsOver(rect))
            {
                isMouseOver = true;
                GUI.color   = GenUI.MouseoverColor;
            }
            var badTex = icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }

            GUI.DrawTexture(rect, BGTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            GUI.color = IconDrawColor;
            Widgets.DrawTextureFitted(new Rect(rect), badTex, iconDrawScale * 0.85f, iconProportions, iconTexCoords);
            GUI.color = Color.white;
            var isUsed = false;
            //Rect rectFil = new Rect(topLeft.x, topLeft.y, this.Width, this.Width);

            var keyCode = hotKey != null ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                var rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    isUsed = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                isUsed = true;
            }
            var labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                var num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                var rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + StringsToTranslate.AU_DISABLED + ": " + disabledReason + "\n" + ability.CooldownTicksLeft.ToStringSecondsFromTicks();
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (ability.CooldownTicksLeft != -1 && ability.CooldownTicksLeft < ability.MaxCastingTicks)
            {
                var math = ability.CooldownTicksLeft / (float)ability.MaxCastingTicks;
                FillableBar(rect, math, AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (isUsed)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            if (isMouseOver)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
예제 #27
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize);

            if (BillUtility.Clipboard == null)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow || !BillUtility.Clipboard.recipe.AvailableOnNow(SelTable))
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere");
            }
            else if (SelTable.billStack.Count >= 15)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f);
                GUI.color = Color.white;
                if (Mouse.IsOver(rect2))
                {
                    TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")");
                }
            }
            else
            {
                if (Widgets.ButtonImageFitted(rect2, TexButton.Paste, Color.white))
                {
                    Bill bill = BillUtility.Clipboard.Clone();
                    bill.InitializeAfterClone();
                    SelTable.billStack.AddBill(bill);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect2, "PasteBillTip");
            }
            Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list      = new List <FloatMenuOption>();
                ITab_Bills             tab_Bills = default(ITab_Bills);
                RecipeDef recipe = default(RecipeDef);
                for (int i = 0; i < SelTable.def.AllRecipes.Count; i++)
                {
                    tab_Bills = this;
                    if (SelTable.def.AllRecipes[i].AvailableNow && SelTable.def.AllRecipes[i].AvailableOnNow(SelTable))
                    {
                        recipe = SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill2 = recipe.MakeNewBill();
                            tab_Bills.SelTable.billStack.AddBill(bill2);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
                            }
                        }, recipe.ProducedThingDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null));
                }
                return(list);
            };

            mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
        }
예제 #28
0
        private void DrawPawnList(Rect rect)
        {
            Rect rect2 = rect;

            rect2.height = 60f;
            rect2        = rect2.ContractedBy(4f);
            int groupID = ReorderableWidget.NewGroup(delegate(int from, int to)
            {
                if (TutorSystem.AllowAction("ReorderPawn"))
                {
                    Pawn item = Find.GameInitData.startingPawns[from];
                    Find.GameInitData.startingPawns.RemoveAt(from);
                    Find.GameInitData.startingPawns.Insert(to, item);
                    TutorSystem.Notify_Event("ReorderPawn");
                }
            });

            rect2.y += 15f;
            this.DrawPawnListLabelAbove(rect2, "StartingPawnsSelected".Translate());
            for (int i = 0; i < Find.GameInitData.startingPawns.Count; i++)
            {
                if (i == Find.GameInitData.startingPawnCount)
                {
                    rect2.y += 30f;
                    this.DrawPawnListLabelAbove(rect2, "StartingPawnsLeftBehind".Translate());
                }
                Pawn pawn = Find.GameInitData.startingPawns[i];
                GUI.BeginGroup(rect2);
                Rect rect3 = new Rect(Vector2.zero, rect2.size);
                Widgets.DrawOptionBackground(rect3, this.curPawn == pawn);
                MouseoverSounds.DoRegion(rect3);
                GUI.color = new Color(1f, 1f, 1f, 0.2f);
                Vector2 pawnSelectorPortraitSize = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                double  x = 110.0 - pawnSelectorPortraitSize.x / 2.0;
                Vector2 pawnSelectorPortraitSize2 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                double  y = 40.0 - pawnSelectorPortraitSize2.y / 2.0;
                Vector2 pawnSelectorPortraitSize3 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                float   x2 = pawnSelectorPortraitSize3.x;
                Vector2 pawnSelectorPortraitSize4 = Page_ConfigureStartingPawns.PawnSelectorPortraitSize;
                GUI.DrawTexture(new Rect((float)x, (float)y, x2, pawnSelectorPortraitSize4.y), PortraitsCache.Get(pawn, Page_ConfigureStartingPawns.PawnSelectorPortraitSize, default(Vector3), 1f));
                GUI.color = Color.white;
                Rect       rect4      = rect3.ContractedBy(4f).Rounded();
                NameTriple nameTriple = pawn.Name as NameTriple;
                string     label      = (nameTriple == null) ? pawn.LabelShort : ((!string.IsNullOrEmpty(nameTriple.Nick)) ? nameTriple.Nick : nameTriple.First);
                Widgets.Label(rect4.TopPart(0.5f).Rounded(), label);
                Vector2 vector = Text.CalcSize(pawn.story.Title);
                if (vector.x > rect4.width)
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.TitleShort);
                }
                else
                {
                    Widgets.Label(rect4.BottomPart(0.5f).Rounded(), pawn.story.Title);
                }
                if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
                {
                    this.curPawn = pawn;
                    SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                }
                GUI.EndGroup();
                if (ReorderableWidget.Reorderable(groupID, rect2.ExpandedBy(4f)))
                {
                    Widgets.DrawRectFast(rect2, Widgets.WindowBGFillColor * new Color(1f, 1f, 1f, 0.5f), null);
                }
                TooltipHandler.TipRegion(rect2, new TipSignal("DragToReorder".Translate(), pawn.GetHashCode() * 3499));
                rect2.y += 60f;
            }
        }
예제 #29
0
 public override void PostOpen()
 {
     base.PostOpen();
     TutorSystem.Notify_Event("PageStart-CreateWorldParams");
 }
예제 #30
0
        public override void PostOpen()
        {
            base.PostOpen();
            Find.GameInitData.ChooseRandomStartingTile();
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.WorldCameraMovement, OpportunityType.Important);
            TutorSystem.Notify_Event("PageStart-SelectStartingSite");
            tutorialStartTilePatch = null;
            if (!TutorSystem.TutorialMode || Find.Tutor.activeLesson == null || Find.Tutor.activeLesson.Current == null || Find.Tutor.activeLesson.Current.Instruction != InstructionDefOf.ChooseLandingSite)
            {
                return;
            }
            Find.WorldCameraDriver.ResetAltitude();
            Find.WorldCameraDriver.Update();
            List <int> list = new List <int>();

            float[]   array     = new float[Find.WorldGrid.TilesCount];
            WorldGrid worldGrid = Find.WorldGrid;
            Vector2   a         = new Vector2((float)Screen.width / 2f, (float)Screen.height / 2f);
            float     num       = Vector2.Distance(a, Vector2.zero);

            for (int i = 0; i < worldGrid.TilesCount; i++)
            {
                Tile tile = worldGrid[i];
                if (TutorSystem.AllowAction("ChooseBiome-" + tile.biome.defName + "-" + tile.hilliness.ToString()))
                {
                    tmpTileVertices.Clear();
                    worldGrid.GetTileVertices(i, tmpTileVertices);
                    Vector3 zero = Vector3.zero;
                    for (int j = 0; j < tmpTileVertices.Count; j++)
                    {
                        zero += tmpTileVertices[j];
                    }
                    zero /= (float)tmpTileVertices.Count;
                    Vector3 v = Find.WorldCamera.WorldToScreenPoint(zero) / Prefs.UIScale;
                    v.y = (float)UI.screenHeight - v.y;
                    v.x = Mathf.Clamp(v.x, 0f, UI.screenWidth);
                    v.y = Mathf.Clamp(v.y, 0f, UI.screenHeight);
                    float   num2       = 1f - Vector2.Distance(a, v) / num;
                    Vector3 normalized = (zero - Find.WorldCamera.transform.position).normalized;
                    float   num3       = Vector3.Dot(Find.WorldCamera.transform.forward, normalized);
                    array[i] = num2 * num3;
                }
                else
                {
                    array[i] = float.NegativeInfinity;
                }
            }
            for (int k = 0; k < 16; k++)
            {
                for (int l = 0; l < array.Length; l++)
                {
                    list.Clear();
                    worldGrid.GetTileNeighbors(l, list);
                    float num4 = array[l];
                    if (num4 < 0f)
                    {
                        continue;
                    }
                    for (int m = 0; m < list.Count; m++)
                    {
                        float num5 = array[list[m]];
                        if (!(num5 < 0f))
                        {
                            num4 += num5;
                        }
                    }
                    array[l] = num4 / (float)list.Count;
                }
            }
            float num6 = float.NegativeInfinity;
            int   num7 = -1;

            for (int n = 0; n < array.Length; n++)
            {
                if (array[n] > 0f && num6 < array[n])
                {
                    num6 = array[n];
                    num7 = n;
                }
            }
            if (num7 != -1)
            {
                tutorialStartTilePatch = num7;
            }
        }