Ejemplo n.º 1
0
    public override void UpdateHoverElements(List <KSelectable> selected)
    {
        int num = Grid.PosToCell(Camera.main.ScreenToWorldPoint(KInputManager.GetMousePos()));

        if (Grid.IsValidCell(num))
        {
            HoverTextScreen instance        = HoverTextScreen.Instance;
            HoverTextDrawer hoverTextDrawer = instance.BeginDrawing();
            hoverTextDrawer.BeginShadowBar(false);
            if (Grid.IsVisible(num))
            {
                DrawTitle(instance, hoverTextDrawer);
                DrawInstructions(HoverTextScreen.Instance, hoverTextDrawer);
                Element element = Grid.Element[num];
                bool    flag    = false;
                if (Grid.Solid[num] && Diggable.IsDiggable(num))
                {
                    flag = true;
                }
                if (flag)
                {
                    hoverTextDrawer.NewLine(26);
                    hoverTextDrawer.DrawText(element.nameUpperCase, Styles_Title.Standard);
                    hoverTextDrawer.NewLine(26);
                    hoverTextDrawer.DrawIcon(instance.GetSprite("dash"), 18);
                    hoverTextDrawer.DrawText(element.GetMaterialCategoryTag().ProperName(), Styles_BodyText.Standard);
                    hoverTextDrawer.NewLine(26);
                    hoverTextDrawer.DrawIcon(instance.GetSprite("dash"), 18);
                    string[] array = WorldInspector.MassStringsReadOnly(num);
                    hoverTextDrawer.DrawText(array[0], Styles_Values.Property.Standard);
                    hoverTextDrawer.DrawText(array[1], Styles_Values.Property_Decimal.Standard);
                    hoverTextDrawer.DrawText(array[2], Styles_Values.Property.Standard);
                    hoverTextDrawer.DrawText(array[3], Styles_Values.Property.Standard);
                    hoverTextDrawer.NewLine(26);
                    hoverTextDrawer.DrawIcon(instance.GetSprite("dash"), 18);
                    hoverTextDrawer.DrawText(GameUtil.GetHardnessString(Grid.Element[num], true), Styles_BodyText.Standard);
                }
            }
            else
            {
                hoverTextDrawer.DrawIcon(instance.GetSprite("iconWarning"), 18);
                hoverTextDrawer.DrawText(UI.TOOLS.GENERIC.UNKNOWN, Styles_BodyText.Standard);
            }
            hoverTextDrawer.EndShadowBar();
            hoverTextDrawer.EndDrawing();
        }
    }
Ejemplo n.º 2
0
        public override void OnMouseMove(Vector3 cursorPos)
        {
            base.OnMouseMove(cursorPos);

            if (!Dragging)
            {
                return;
            }

            var selectedCells = new List <int>();

            Grid.PosToXY(downPos, out int x, out int y);
            Grid.PosToXY(cursorPos, out int x2, out int y2);

            if (x2 < x)
            {
                Util.Swap(ref x, ref x2);
            }
            if (y2 < y)
            {
                Util.Swap(ref y, ref y2);
            }
            for (int i = y; i <= y2; i++)
            {
                for (int j = x; j <= x2; j++)
                {
                    int cell = Grid.XYToCell(j, i);
                    if (Grid.IsValidCell(cell) &&
                        Grid.IsVisible(cell) &&
                        (Diggable.IsDiggable(cell) || Grid.IsLiquid(cell) || Grid.IsGas(cell)) /* && Grid.IsSolidCell(cell)*/)
                    {
                        selectedCells.Add(cell);
                    }
                }
            }

            ElementInspector.UpdateElementData(selectedCells);
        }
Ejemplo n.º 3
0
        private void DrawTextCard()
        {
            int cell = Grid.PosToCell(Camera.main.ScreenToWorldPoint(KInputManager.GetMousePos()));

            if (!Grid.IsValidCell(cell))
            {
                return;
            }

            HoverTextScreen screen = HoverTextScreen.Instance;
            Sprite          dash   = screen.GetSprite("dash");

            HoverTextDrawer txt = screen.BeginDrawing();

            txt.BeginShadowBar();

            if (!Grid.IsVisible(cell))
            {
                txt.DrawIcon(screen.GetSprite("iconWarning"));
                txt.DrawText(UI.TOOLS.GENERIC.UNKNOWN, Styles_BodyText.Standard);
            }
            else
            {
                DrawTitle(screen, txt);
                DrawInstructions(screen, txt);

                var standard = Styles_BodyText.Standard;
                if (!InspectTool.Instance.Dragging)
                {
                    var element = ElementInfo.FromCellNumber(cell);

                    txt.NewLine();
                    txt.DrawText(element.NameUppercase, ToolTitleTextStyle);

                    txt.NewLine();
                    txt.DrawIcon(dash);
                    txt.DrawText(element.Category, standard);

                    txt.NewLine();
                    txt.DrawIcon(dash);
                    string[] array = WorldInspector.MassStringsReadOnly(cell);
                    txt.DrawText(array[0], Styles_Values.Property.Standard);
                    txt.DrawText(array[1], Styles_Values.Property_Decimal.Standard);
                    txt.DrawText(array[2], Styles_Values.Property.Standard);
                    txt.DrawText(array[3], Styles_Values.Property.Standard);

                    txt.NewLine();
                    txt.DrawIcon(dash);
                    txt.DrawText(GameUtil.GetFormattedTemperature(element.Temperature), standard);

                    txt.NewLine();
                    txt.DrawIcon(dash);
                    txt.DrawText(element.GetFormattedTotalRelativeHeat(InspectToolSettings.Instance.RelativeTemp), standard);

                    if (Grid.Solid[cell] && Diggable.IsDiggable(cell))
                    {
                        txt.NewLine();
                        txt.DrawIcon(dash);
                        txt.DrawText(GameUtil.GetHardnessString(Grid.Element[cell]), standard);
                    }
                }
                else
                {
                    txt.NewLine();
                    txt.DrawText(((string)InspectToolStrings.HOVER_TEXT_TITLE).ToUpper(), ToolTitleTextStyle);

                    var elements = ElementInspector.ElementData;
                    if (elements != null && elements.Length > 0)
                    {
                        foreach (var e in elements)
                        {
                            txt.NewLine();
                            txt.DrawIcon(dash);
                            txt.DrawText(e, standard);
                        }
                    }
                    else
                    {
                        txt.NewLine();
                        txt.DrawText(InspectToolStrings.HOVER_TEXT_NO_ELEMENTS, standard);
                    }
                }
            }

            txt.EndShadowBar();
            txt.EndDrawing();
        }
Ejemplo n.º 4
0
 private void PlaceDiggables()
 {
     if (waitForFetchesBeforeDigging && fetchList != null && !hasLadderNearby)
     {
         OnDiggableReachabilityChanged(null);
     }
     else
     {
         bool digs_complete = true;
         if (!solidPartitionerEntry.IsValid())
         {
             Extents validPlacementExtents = building.GetValidPlacementExtents();
             solidPartitionerEntry = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.solidChangedLayer, OnSolidChangedOrDigDestroyed);
             digPartitionerEntry   = GameScenePartitioner.Instance.Add("Constructable.OnFetchListComplete", base.gameObject, validPlacementExtents, GameScenePartitioner.Instance.digDestroyedLayer, OnSolidChangedOrDigDestroyed);
         }
         if (!IsReplacementTile)
         {
             building.RunOnArea(delegate(int offset_cell)
             {
                 PrioritySetting masterPriority = GetComponent <Prioritizable>().GetMasterPriority();
                 if (Diggable.IsDiggable(offset_cell))
                 {
                     digs_complete     = false;
                     Diggable diggable = Diggable.GetDiggable(offset_cell);
                     if ((UnityEngine.Object)diggable == (UnityEngine.Object)null)
                     {
                         diggable = GameUtil.KInstantiate(Assets.GetPrefab(new Tag("DigPlacer")), Grid.SceneLayer.Move, null, 0).GetComponent <Diggable>();
                         diggable.gameObject.SetActive(true);
                         diggable.transform.SetPosition(Grid.CellToPosCBC(offset_cell, Grid.SceneLayer.Move));
                         diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged);
                         Grid.Objects[offset_cell, 7] = diggable.gameObject;
                     }
                     else
                     {
                         diggable.Unsubscribe(-1432940121, OnDiggableReachabilityChanged);
                         diggable.Subscribe(-1432940121, OnDiggableReachabilityChanged);
                     }
                     diggable.choreTypeIdHash = Db.Get().ChoreTypes.BuildDig.IdHash;
                     diggable.GetComponent <Prioritizable>().SetMasterPriority(masterPriority);
                     RenderUtil.EnableRenderer(diggable.transform, false);
                     SaveLoadRoot component = diggable.GetComponent <SaveLoadRoot>();
                     if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                     {
                         UnityEngine.Object.Destroy(component);
                     }
                 }
             });
             OnDiggableReachabilityChanged(null);
         }
         bool flag = building.Def.IsValidBuildLocation(base.gameObject, base.transform.GetPosition(), building.Orientation);
         if (flag)
         {
             notifier.Remove(invalidLocation);
         }
         else
         {
             notifier.Add(invalidLocation, string.Empty);
         }
         GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.InvalidBuildingLocation, !flag, this);
         bool flag2 = digs_complete && flag && fetchList == null;
         if (flag2 && buildChore == null)
         {
             buildChore = new WorkChore <Constructable>(Db.Get().ChoreTypes.Build, this, null, true, UpdateBuildState, UpdateBuildState, UpdateBuildState, true, null, false, true, null, true, true, true, PriorityScreen.PriorityClass.basic, 5, false, true);
             UpdateBuildState(buildChore);
         }
         else if (!flag2 && buildChore != null)
         {
             buildChore.Cancel("Need to dig");
             buildChore = null;
         }
     }
 }