Ejemplo n.º 1
0
        public virtual void DesignateMultiCell(IEnumerable <IntVec3> cells)
        {
            if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(new EventPack(this.TutorTagDesignate, cells)))
            {
                return;
            }
            bool somethingSucceeded = false;
            bool flag = false;

            foreach (IntVec3 current in cells)
            {
                if (this.CanDesignateCell(current).Accepted)
                {
                    this.DesignateSingleCell(current);
                    somethingSucceeded = true;
                    if (!flag)
                    {
                        flag = this.ShowWarningForCell(current);
                    }
                }
            }
            this.Finalize(somethingSucceeded);
            if (TutorSystem.TutorialMode)
            {
                TutorSystem.Notify_Event(new EventPack(this.TutorTagDesignate, cells));
            }
        }
        private void RandomizeCurPawn()
        {
            if (!TutorSystem.AllowAction("RandomizePawn"))
            {
                return;
            }
            int num = 0;

            while (true)
            {
                this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
                num++;
                if (num > 15)
                {
                    break;
                }
                if (StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    goto Block_3;
                }
            }
            return;

Block_3:
            TutorSystem.Notify_Event("RandomizePawn");
        }
Ejemplo n.º 3
0
        protected override bool CanDoNext()
        {
            if (!base.CanDoNext())
            {
                return(false);
            }
            int selectedTile = Find.WorldInterface.SelectedTile;

            if (selectedTile < 0)
            {
                Messages.Message("MustSelectLandingSite".Translate(), MessageSound.RejectInput);
                return(false);
            }
            StringBuilder stringBuilder = new StringBuilder();

            if (!TileFinder.IsValidTileForNewSettlement(selectedTile, stringBuilder))
            {
                Messages.Message(stringBuilder.ToString(), MessageSound.RejectInput);
                return(false);
            }
            Tile item = Find.WorldGrid[selectedTile];

            if (!TutorSystem.AllowAction(string.Concat("ChooseBiome-", item.biome.defName, "-", item.hilliness.ToString())))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (settables == null)
            {
                settables = new List <IPlantToGrowSettable>();
            }
            if (!settables.Contains(settable))
            {
                settables.Add(settable);
            }
            tmpAvailablePlants.Clear();
            foreach (ThingDef item in PlantUtility.ValidPlantTypesForGrowers(settables))
            {
                if (IsPlantAvailable(item, settable.Map))
                {
                    tmpAvailablePlants.Add(item);
                }
            }
            tmpAvailablePlants.SortBy((ThingDef x) => 0f - GetPlantListPriority(x), (ThingDef x) => x.label);
            for (int i = 0; i < tmpAvailablePlants.Count; i++)
            {
                ThingDef plantDef = tmpAvailablePlants[i];
                string   text     = plantDef.LabelCap;
                if (plantDef.plant.sowMinSkill > 0)
                {
                    text = text + (string)(" (" + "MinSkill".Translate() + ": ") + plantDef.plant.sowMinSkill + ")";
                }
                list.Add(new FloatMenuOption(text, delegate
                {
                    string s = tutorTag + "-" + plantDef.defName;
                    if (TutorSystem.AllowAction(s))
                    {
                        bool flag = true;
                        for (int j = 0; j < settables.Count; j++)
                        {
                            settables[j].SetPlantDefToGrow(plantDef);
                            if (flag && plantDef.plant.interferesWithRoof)
                            {
                                foreach (IntVec3 cell in settables[j].Cells)
                                {
                                    if (cell.Roofed(settables[j].Map))
                                    {
                                        Messages.Message("MessagePlantIncompatibleWithRoof".Translate(Find.ActiveLanguageWorker.Pluralize(plantDef.LabelCap)), MessageTypeDefOf.CautionInput, historical: false);
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                        }
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total);
                        WarnAsAppropriate(plantDef);
                        TutorSystem.Notify_Event(s);
                    }
                }, plantDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, plantDef)));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Ejemplo n.º 5
0
            internal void <> m__0()
            {
                string s = this.$this.tutorTag + "-" + this.plantDef.defName;

                if (TutorSystem.AllowAction(s))
                {
                    bool flag = true;
                    for (int i = 0; i < this.$this.settables.Count; i++)
                    {
                        this.$this.settables[i].SetPlantDefToGrow(this.plantDef);
                        if (flag && this.plantDef.plant.interferesWithRoof)
                        {
                            foreach (IntVec3 c in this.$this.settables[i].Cells)
                            {
                                if (c.Roofed(this.$this.settables[i].Map))
                                {
                                    Messages.Message("MessagePlantIncompatibleWithRoof".Translate(new object[]
                                    {
                                        Find.ActiveLanguageWorker.Pluralize(this.plantDef.LabelCap, -1)
                                    }), MessageTypeDefOf.CautionInput, false);
                                    flag = false;
                                    break;
                                }
                            }
                        }
                    }
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total);
                    this.$this.WarnAsAppropriate(this.plantDef);
                    TutorSystem.Notify_Event(s);
                }
            }
Ejemplo n.º 6
0
 public virtual void DesignateMultiCell(IEnumerable <IntVec3> cells)
 {
     if (!TutorSystem.TutorialMode || TutorSystem.AllowAction(new EventPack(TutorTagDesignate, cells)))
     {
         bool somethingSucceeded = false;
         bool flag = false;
         foreach (IntVec3 cell in cells)
         {
             if (CanDesignateCell(cell).Accepted)
             {
                 DesignateSingleCell(cell);
                 somethingSucceeded = true;
                 if (!flag)
                 {
                     flag = ShowWarningForCell(cell);
                 }
             }
         }
         Finalize(somethingSucceeded);
         if (TutorSystem.TutorialMode)
         {
             TutorSystem.Notify_Event(new EventPack(TutorTagDesignate, cells));
         }
     }
 }
Ejemplo n.º 7
0
        public GizmoResult DoGUI_Logic(bool mouseIsOver, bool commandIsTriggered)
        {
            if (commandIsTriggered)
            {
                if (gizmo.disabled)
                {
                    if (!gizmo.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(gizmo.disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(gizmo.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                TutorSystem.Notify_Event(gizmo.TutorTagSelect);
                return(new GizmoResult(GizmoState.Interacted, Event.current));
            }

            if (mouseIsOver)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }

            return(new GizmoResult(GizmoState.Clear, null));
        }
Ejemplo n.º 8
0
 public override void PostOpen()
 {
     base.PostOpen();
     Find.GameInitData.ChooseRandomStartingTile();
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.WorldCameraMovement, OpportunityType.Important);
     TutorSystem.Notify_Event("PageStart-SelectLandingSite");
 }
Ejemplo n.º 9
0
        protected void displayInspectActions()
        {
            //Since InspectGizmoGrid is internal(you gotta love that vanilla codebase...) lets redo the entire code for the inspect toolbar
            List <Gizmo>  gizmoList       = new List <Gizmo>();
            List <object> selectedObjects = Find.Selector.SelectedObjectsListForReading;

            if (selectedObjects.NullOrEmpty())
            {
                return;
            }
            for (int i = 0; i < selectedObjects.Count; i++)
            {
                ISelectable selectable = selectedObjects[i] as ISelectable;
                if (selectable != null)
                {
                    foreach (Gizmo current in selectable.GetGizmos())
                    {
                        gizmoList.Add(current);
                    }
                }
            }
            for (int j = 0; j < selectedObjects.Count; j++)
            {
                Thing t = selectedObjects[j] as Thing;
                if (t != null)
                {
                    IEnumerable <Designator> allDesignators = Find.ReverseDesignatorDatabase.AllDesignators.Concat(designatorDebugDestroy);
                    foreach (Designator des in allDesignators)
                    {
                        if (des.CanDesignateThing(t).Accepted)
                        {
                            Command_Action command_Action = new Command_Action();
                            command_Action.defaultLabel = des.LabelCapReverseDesignating(t);
                            float   iconAngle;
                            Vector2 iconOffset;
                            command_Action.icon        = des.IconReverseDesignating(t, out iconAngle, out iconOffset);
                            command_Action.iconAngle   = iconAngle;
                            command_Action.iconOffset  = iconOffset;
                            command_Action.defaultDesc = des.DescReverseDesignating(t);
                            command_Action.action      = delegate
                            {
                                if (!TutorSystem.AllowAction(des.TutorTagDesignate))
                                {
                                    return;
                                }
                                des.DesignateThing(t);
                                des.Finalize(true);
                            };
                            command_Action.hotKey   = des.hotKey;
                            command_Action.groupKey = des.groupKey;
                            gizmoList.Add(command_Action);
                        }
                    }
                }
            }

            Gizmo mouseoverGizmo;

            GizmoGridDrawer.DrawGizmoGrid(gizmoList, 20f + windowRect.width, out mouseoverGizmo);
        }
Ejemplo n.º 10
0
        public override void PostOpen()
        {
            base.PostOpen();
            TutorSystem.Notify_Event("PageStart-ConfigureStartingPawns");

            // Set initial Cards
            PopulateCards();
        }
Ejemplo n.º 11
0
 protected bool CheckCanInteract()
 {
     if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(TutorTagSelect))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 12
0
        private static void InterfaceToggleTab(InspectTabBase tab, IInspectPane pane)
        {
            if (TutorSystem.TutorialMode && !IsOpen(tab, pane) &&
                !TutorSystem.AllowAction("ITab-" + tab.tutorTag + "-Open"))
            {
                return;
            }

            ToggleTab(tab, pane);
        }
        public void ProcessInputEvents()
        {
            if (this.CheckSelectedDesignatorValid())
            {
                if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
                {
                    if (this.selectedDesignator.DraggableDimensions == 0)
                    {
                        Designator       designator       = this.selectedDesignator;
                        AcceptanceReport acceptanceReport = this.selectedDesignator.CanDesignateCell(UI.MouseCell());
                        if (acceptanceReport.Accepted)
                        {
                            designator.DesignateSingleCell(UI.MouseCell());
                            designator.Finalize(true);
                        }
                        else
                        {
                            Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput);
                            this.selectedDesignator.Finalize(false);
                        }
                    }
                    else
                    {
                        this.dragger.StartDrag();
                    }
                    Event.current.Use();
                }
                if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
                {
                    goto IL_00ec;
                }
                if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
                {
                    goto IL_00ec;
                }
                goto IL_0121;
            }
            return;

IL_00ec:
            SoundDefOf.CancelMode.PlayOneShotOnCamera(null);
            this.Deselect();
            this.dragger.EndDrag();
            Event.current.Use();
            TutorSystem.Notify_Event("ClearDesignatorSelection");
            goto IL_0121;
IL_0121:
            if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && this.dragger.Dragging)
            {
                this.selectedDesignator.DesignateMultiCell(this.dragger.DragCells);
                this.dragger.EndDrag();
                Event.current.Use();
            }
        }
 private void RandomizeCurPawn()
 {
     if (!TutorSystem.AllowAction("RandomizePawn"))
     {
         return;
     }
     do
     {
         this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
     }while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
     TutorSystem.Notify_Event("RandomizePawn");
 }
Ejemplo n.º 15
0
 public static bool Prefix()
 {
     Find.MusicManagerPlay.disabled = true;
     Find.WindowStack.Notify_GameStartDialogOpened();
     LongEventHandler.ExecuteWhenFinished(() =>
     {
         Find.MusicManagerPlay.disabled = false;
         Find.WindowStack.Notify_GameStartDialogClosed();
         Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
         TutorSystem.Notify_Event("GameStartDialogClosed");
     });
     return(false);
 }
Ejemplo n.º 16
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (this.settables == null)
            {
                this.settables = new List <IPlantToGrowSettable>();
            }
            if (!this.settables.Contains(this.settable))
            {
                this.settables.Add(this.settable);
            }
            foreach (ThingDef current in GenPlant.ValidPlantTypesForGrowers(this.settables))
            {
                if (this.IsPlantAvailable(current))
                {
                    ThingDef localPlantDef = current;
                    string   text          = current.LabelCap;
                    if (current.plant.sowMinSkill > 0)
                    {
                        string text2 = text;
                        text = string.Concat(new object[]
                        {
                            text2,
                            " (",
                            "MinSkill".Translate(),
                            ": ",
                            current.plant.sowMinSkill,
                            ")"
                        });
                    }
                    list.Add(new FloatMenuOption(text, delegate
                    {
                        string s = this.tutorTag + "-" + localPlantDef.defName;
                        if (!TutorSystem.AllowAction(s))
                        {
                            return;
                        }
                        for (int i = 0; i < this.settables.Count; i++)
                        {
                            this.settables[i].SetPlantDefToGrow(localPlantDef);
                        }
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total);
                        this.WarnAsAppropriate(localPlantDef);
                        TutorSystem.Notify_Event(s);
                    }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, localPlantDef), null));
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Ejemplo n.º 17
0
 protected override void DoNext()
 {
     if (next != null)
     {
         Find.WindowStack.Add(this.next);
     }
     if (nextAct != null)
     {
         ESStartingItems.LoadESItemsToScenario();
         nextAct();
     }
     TutorSystem.Notify_Event("PageClosed");
     TutorSystem.Notify_Event("GoToNextPage");
     Close(true);
 }
Ejemplo n.º 18
0
        public static void EnqueueRange(IEnumerable <ResearchNode> nodes, bool add)
        {
            TutorSystem.Notify_Event("StartResearchProject");

            // clear current Queue if not adding
            if (!add)
            {
                _instance._queue.Clear();
                Find.ResearchManager.currentProj = null;
            }

            // sorting by depth ensures prereqs are met - cost is just a bonus thingy.
            foreach (var node in nodes.OrderBy(node => node.X).ThenBy(node => node.Research.CostApparent))
            {
                Enqueue(node, true);
            }
        }
Ejemplo n.º 19
0
 public void ProcessInputEvents()
 {
     if (!CheckSelectedDesignatorValid())
     {
         return;
     }
     if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
     {
         if (selectedDesignator.DraggableDimensions == 0)
         {
             Designator       designator       = selectedDesignator;
             AcceptanceReport acceptanceReport = selectedDesignator.CanDesignateCell(UI.MouseCell());
             if (acceptanceReport.Accepted)
             {
                 designator.DesignateSingleCell(UI.MouseCell());
                 designator.Finalize(somethingSucceeded: true);
             }
             else
             {
                 Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.SilentInput, historical: false);
                 selectedDesignator.Finalize(somethingSucceeded: false);
             }
         }
         else
         {
             dragger.StartDrag();
         }
         Event.current.Use();
     }
     if ((Event.current.type == EventType.MouseDown && Event.current.button == 1) || KeyBindingDefOf.Cancel.KeyDownEvent)
     {
         SoundDefOf.CancelMode.PlayOneShotOnCamera();
         Deselect();
         dragger.EndDrag();
         Event.current.Use();
         TutorSystem.Notify_Event("ClearDesignatorSelection");
     }
     if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && dragger.Dragging)
     {
         selectedDesignator.DesignateMultiCell(dragger.DragCells);
         dragger.EndDrag();
         Event.current.Use();
     }
 }
 // Performs the logic from the Page.DoNext() method in the base Page class instead of calling the override
 // in Page_ConfigureStartingPawns.  We want to prevent the missing required work type dialog from appearing
 // in the context of the configure pawns page.  We're adding our own version here.
 public void DoNextInBasePage()
 {
     if (OriginalPage != null)
     {
         Page   next       = OriginalPage.next;
         Action nextAction = OriginalPage.nextAct;
         if (next != null)
         {
             Verse.Find.WindowStack.Add(next);
         }
         if (nextAction != null)
         {
             nextAction();
         }
         TutorSystem.Notify_Event("PageClosed");
         TutorSystem.Notify_Event("GoToNextPage");
         OriginalPage.Close(true);
     }
 }
Ejemplo n.º 21
0
 public static FloatMenuOption RecipeFloatMenuOption(Building_WorkTable SelTable, RecipeDef recipe)
 {
     return(new FloatMenuOption(recipe.LabelCap, delegate
     {
         if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
         {
             Bill.CreateNoPawnsWithSkillDialog(recipe);
         }
         Bill bill2 = recipe.MakeNewBill();
         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.UIIconThing, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
 }
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (this.settables == null)
            {
                this.settables = new List <IPrisonerToSacrificeSettable>();
            }
            if (!this.settables.Contains(this.settable))
            {
                this.settables.Add(this.settable);
            }
            Map map = Find.VisibleMap;

            foreach (Pawn current in map.mapPawns.PrisonersOfColonySpawned)
            {
                if (!current.Dead)
                {
                    string text = current.LabelCap;
                    List <FloatMenuOption> arg_121_0      = list;
                    Func <Rect, bool>      extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, localPlantDef);
                    arg_121_0.Add(new FloatMenuOption(text, delegate
                    {
                        string s = this.tutorTag + "-" + localPlantDef.defName;
                        if (!TutorSystem.AllowAction(s))
                        {
                            return;
                        }
                        for (int i = 0; i < this.settables.Count; i++)
                        {
                            this.settables[i].SetPlantDefToGrow(localPlantDef);
                        }
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total);
                        this.WarnAsAppropriate(localPlantDef);
                        TutorSystem.Notify_Event(s);
                    }, MenuOptionPriority.Default, null, null, 29f, extraPartOnGUI, null));
                }
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
Ejemplo n.º 23
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                for (int i = 0; i < SelTable.def.AllRecipes.Count; i++)
                {
                    if (SelTable.def.AllRecipes[i].AvailableNow)
                    {
                        RecipeDef recipe = SelTable.def.AllRecipes[i];
                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill = recipe.MakeNewBill();
                            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 r) => Widgets.InfoCardButton(r.x + 5f, r.y + (r.height - 24f) / 2f, recipe), null));
                    }
                }
                if (!list.Any())
                {
                    list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                return(list);
            };

            mouseoverBill = SelTable.billStack.DoListing(rect, recipeOptionsMaker, ref scrollPosition, ref viewHeight);
        }
Ejemplo n.º 24
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            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);
                }
            }
        }
Ejemplo n.º 25
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!this.disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            Material material = (!this.disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect outerRect = rect;

            outerRect.position += new Vector2(this.iconOffset.x * outerRect.size.x, this.iconOffset.y * outerRect.size.y);
            GUI.color           = this.IconDrawColor;
            Widgets.DrawTextureFitted(outerRect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  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 (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        this.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result;
                if (Event.current.button == 1)
                {
                    result = new GizmoResult(GizmoState.OpenedFloatMenu, Event.current);
                }
                else
                {
                    if (!TutorSystem.AllowAction(this.TutorTagSelect))
                    {
                        return(new GizmoResult(GizmoState.Mouseover, null));
                    }
                    result = new GizmoResult(GizmoState.Interacted, Event.current);
                    TutorSystem.Notify_Event(this.TutorTagSelect);
                }
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        public static void Detour(IEnumerable <object> selectedObjects, ref Gizmo mouseoverGizmo)
        {
            var DoRebuild = !(Analyzer.Settings.OptimizeDrawInspectGizmoGrid && Event.current.type != EventType.Repaint);

            Profiler prof = null;

            if (DoRebuild)
            {
                mouseoverGizmo = null;
                try
                {
                    InspectGizmoGrid.objList.Clear();
                    InspectGizmoGrid.objList.AddRange(selectedObjects);
                    InspectGizmoGrid.gizmoList.Clear();
                    var slam = InspectGizmoGrid.objList.Count;
                    for (var i = 0; i < slam; i++)
                    {
                        if (InspectGizmoGrid.objList[i] is ISelectable selectable)
                        {
                            if (Active)
                            {
                                var me = string.Intern($"{selectable.GetType()} Gizmos");
                                prof = Analyzer.Start(me);
                                InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos());
                                prof.Stop();
                            }
                            else
                            {
                                InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos());
                            }
                        }
                    }
                    for (var j = 0; j < InspectGizmoGrid.objList.Count; j++)
                    {
                        if (InspectGizmoGrid.objList[j] is Thing t)
                        {
                            var allDesignators = Find.ReverseDesignatorDatabase.AllDesignators;
                            var coo            = allDesignators.Count;
                            for (var k = 0; k < coo; k++)
                            {
                                Designator des = allDesignators[k];
                                if (des.CanDesignateThing(t).Accepted)
                                {
                                    var command_Action = new Command_Action
                                    {
                                        defaultLabel = des.LabelCapReverseDesignating(t),
                                        icon         = des.IconReverseDesignating(t, out var iconAngle, out var iconOffset),
                                        iconAngle    = iconAngle,
                                        iconOffset   = iconOffset,
                                        defaultDesc  = des.DescReverseDesignating(t),
                                        order        = (!(des is Designator_Uninstall) ? -20f : -11f),
                                        action       = delegate
                                        {
                                            if (!TutorSystem.AllowAction(des.TutorTagDesignate))
                                            {
                                                return;
                                            }

                                            des.DesignateThing(t);
                                            des.Finalize(true);
                                        },
                                        hotKey   = des.hotKey,
                                        groupKey = des.groupKey
                                    };
                                    InspectGizmoGrid.gizmoList.Add(command_Action);
                                }
                            }
                        }
                    }
                    InspectGizmoGrid.objList.Clear();
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce(ex.ToString(), 3427734);
                }
            }

            if (Active)
            {
                prof = Analyzer.Start(str);
            }
            GizmoGridDrawer.DrawGizmoGrid(InspectGizmoGrid.gizmoList, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo);
            if (Active)
            {
                prof.Stop();
            }
        }
Ejemplo n.º 27
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = LockUtility.GetData(parent).WantedState.locked ? lockTexture : unlockTexture;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, BGTex);
            GUI.DrawTexture(rect, badTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect 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)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  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())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (flag2)
            {
                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));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        public virtual bool DoGUI(Rect rect, bool colonistOrdering, FloatMenu floatMenu)
        {
            Rect rect2 = rect;

            rect2.height--;
            bool flag  = !Disabled && Mouse.IsOver(rect2);
            bool flag2 = false;

            Text.Font = CurrentFont;
            Rect rect3 = rect;

            rect3.xMin += 4f;
            rect3.xMax  = rect.x + 27f;
            rect3.yMin += 4f;
            rect3.yMax  = rect.y + 27f;
            if (flag)
            {
                rect3.x += 4f;
            }
            Rect rect4 = rect;

            rect4.xMin += HorizontalMargin;
            rect4.xMax -= HorizontalMargin;
            rect4.xMax -= 4f;
            rect4.xMax -= extraPartWidth + IconOffset;
            rect4.x    += IconOffset;
            if (flag)
            {
                rect4.x += 4f;
            }
            Rect rect5 = default(Rect);

            if (extraPartWidth != 0f)
            {
                float num = Mathf.Min(Text.CalcSize(Label).x, rect4.width - 4f);
                rect5 = new Rect(rect4.xMin + num, rect4.yMin, extraPartWidth, 30f);
                flag2 = Mouse.IsOver(rect5);
            }
            if (!Disabled)
            {
                MouseoverSounds.DoRegion(rect2);
            }
            Color color = GUI.color;

            if (Disabled)
            {
                GUI.color = ColorBGDisabled * color;
            }
            else if (flag && !flag2)
            {
                GUI.color = ColorBGActiveMouseover * color;
            }
            else
            {
                GUI.color = ColorBGActive * color;
            }
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = ((!Disabled) ? ColorTextActive : ColorTextDisabled) * color;
            if (sizeMode == FloatMenuSizeMode.Tiny)
            {
                rect4.y += 1f;
            }
            Widgets.DrawAtlas(rect, TexUI.FloatMenuOptionBG);
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect4, Label);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = iconColor;
            if (shownItem != null || drawPlaceHolderIcon)
            {
                Widgets.DefIcon(rect3, shownItem, null, 1f, drawPlaceHolderIcon);
            }
            else if ((bool)itemIcon)
            {
                GUI.DrawTexture(rect3, itemIcon);
            }
            GUI.color = color;
            if (extraPartOnGUI != null)
            {
                bool num2 = extraPartOnGUI(rect5);
                GUI.color = color;
                if (num2)
                {
                    return(true);
                }
            }
            if (flag && mouseoverGuiAction != null)
            {
                mouseoverGuiAction();
            }
            if (tutorTag != null)
            {
                UIHighlighter.HighlightOpportunity(rect, tutorTag);
            }
            if (Widgets.ButtonInvisible(rect2))
            {
                if (tutorTag != null && !TutorSystem.AllowAction(tutorTag))
                {
                    return(false);
                }
                Chosen(colonistOrdering, floatMenu);
                if (tutorTag != null)
                {
                    TutorSystem.Notify_Event(tutorTag);
                }
                return(true);
            }
            return(false);
        }
Ejemplo n.º 29
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.Width, 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = this.icon;

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

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

            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

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

            if (!labelCap.NullOrEmpty())
            {
                float num = Text.CalcHeight(labelCap, rect.width);
                num -= 2f;
                Rect 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 (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "\n\nDISABLED: " + this.disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            float x    = compPsyker.TicksToCast;
            float y    = compPsyker.TicksToCastMax;
            float fill = x / y;

            Widgets.FillableBar(rect, fill, FullTex, EmptyTex, false);
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageSound.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
        //public override bool GroupsWith(Gizmo other)
        //{
        //    if (other is Command_PawnAbility p && p.pawnAbility.Def.abilityClass == this.pawnAbility.Def.abilityClass)
        //        return true;
        //    return false;
        //}

        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            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 + "\n" + StringsToTranslate.AU_DISABLED + ": " + disabledReason;
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (pawnAbility.CooldownTicksLeft != -1 && pawnAbility.CooldownTicksLeft < pawnAbility.MaxCastingTicks)
            {
                var math = curTicks / (float)pawnAbility.MaxCastingTicks;
                Widgets.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));
        }