public IEnumerable <WorldObject> SelectableObjectsUnderMouse(out bool clickedDirectlyOnCaravan, out bool usedColonistBar)
        {
            Vector2 mousePositionOnUIInverted = UI.MousePositionOnUIInverted;

            if (Current.ProgramState == ProgramState.Playing)
            {
                Caravan caravan = Find.ColonistBar.CaravanMemberCaravanAt(mousePositionOnUIInverted);
                if (caravan != null)
                {
                    clickedDirectlyOnCaravan = true;
                    usedColonistBar          = true;
                    return(Gen.YieldSingle((WorldObject)caravan));
                }
            }
            List <WorldObject> list = GenWorldUI.WorldObjectsUnderMouse(UI.MousePositionOnUI);

            clickedDirectlyOnCaravan = false;
            if (list.Count > 0 && list[0] is Caravan && list[0].DistanceToMouse(UI.MousePositionOnUI) < GenWorldUI.CaravanDirectClickRadius)
            {
                clickedDirectlyOnCaravan = true;
                for (int num = list.Count - 1; num >= 0; num--)
                {
                    WorldObject worldObject = list[num];
                    if (worldObject is Caravan && worldObject.DistanceToMouse(UI.MousePositionOnUI) > GenWorldUI.CaravanDirectClickRadius)
                    {
                        list.Remove(worldObject);
                    }
                }
            }
            usedColonistBar = false;
            return(list);
        }
 public static void ExpandableWorldObjectsOnGUI()
 {
     if (TransitionPct != 0f)
     {
         tmpWorldObjects.Clear();
         tmpWorldObjects.AddRange(Find.WorldObjects.AllWorldObjects);
         SortByExpandingIconPriority(tmpWorldObjects);
         WorldTargeter      worldTargeter          = Find.WorldTargeter;
         List <WorldObject> worldObjectsUnderMouse = null;
         if (worldTargeter.IsTargeting)
         {
             worldObjectsUnderMouse = GenWorldUI.WorldObjectsUnderMouse(UI.MousePositionOnUI);
         }
         for (int i = 0; i < tmpWorldObjects.Count; i++)
         {
             WorldObject worldObject = tmpWorldObjects[i];
             if (worldObject.def.expandingIcon && !worldObject.HiddenBehindTerrainNow())
             {
                 Color expandingIconColor = worldObject.ExpandingIconColor;
                 expandingIconColor.a = TransitionPct;
                 if (worldTargeter.IsTargetedNow(worldObject, worldObjectsUnderMouse))
                 {
                     float num = GenMath.LerpDouble(-1f, 1f, 0.7f, 1f, Mathf.Sin(Time.time * 8f));
                     expandingIconColor.r *= num;
                     expandingIconColor.g *= num;
                     expandingIconColor.b *= num;
                 }
                 GUI.color = expandingIconColor;
                 GUI.DrawTexture(ExpandedIconScreenRect(worldObject), worldObject.ExpandingIcon);
             }
         }
         tmpWorldObjects.Clear();
         GUI.color = Color.white;
     }
 }
Example #3
0
        public static List <FloatMenuOption> ChoicesAtFor(Vector2 mousePos, Caravan caravan)
        {
            List <FloatMenuOption> list  = new List <FloatMenuOption>();
            List <WorldObject>     list2 = GenWorldUI.WorldObjectsUnderMouse(mousePos);

            for (int i = 0; i < list2.Count; i++)
            {
                list.AddRange(list2[i].GetFloatMenuOptions(caravan));
            }
            return(list);
        }
        public static void ExpandableWorldObjectsOnGUI()
        {
            if (TransitionPct == 0f)
            {
                return;
            }
            tmpWorldObjects.Clear();
            tmpWorldObjects.AddRange(Find.WorldObjects.AllWorldObjects);
            SortByExpandingIconPriority(tmpWorldObjects);
            WorldTargeter      worldTargeter          = Find.WorldTargeter;
            List <WorldObject> worldObjectsUnderMouse = null;

            if (worldTargeter.IsTargeting)
            {
                worldObjectsUnderMouse = GenWorldUI.WorldObjectsUnderMouse(UI.MousePositionOnUI);
            }
            for (int i = 0; i < tmpWorldObjects.Count; i++)
            {
                try
                {
                    WorldObject worldObject = tmpWorldObjects[i];
                    if (worldObject.def.expandingIcon && !worldObject.HiddenBehindTerrainNow())
                    {
                        Color expandingIconColor = worldObject.ExpandingIconColor;
                        expandingIconColor.a = TransitionPct;
                        if (worldTargeter.IsTargetedNow(worldObject, worldObjectsUnderMouse))
                        {
                            float num = GenMath.LerpDouble(-1f, 1f, 0.7f, 1f, Mathf.Sin(Time.time * 8f));
                            expandingIconColor.r *= num;
                            expandingIconColor.g *= num;
                            expandingIconColor.b *= num;
                        }
                        GUI.color = expandingIconColor;
                        Rect rect = ExpandedIconScreenRect(worldObject);
                        if (worldObject.ExpandingIconFlipHorizontal)
                        {
                            rect.x      = rect.xMax;
                            rect.width *= -1f;
                        }
                        Widgets.DrawTextureRotated(rect, worldObject.ExpandingIcon, worldObject.ExpandingIconRotation);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Error while drawing " + tmpWorldObjects[i].ToStringSafe() + ": " + ex);
                }
            }
            tmpWorldObjects.Clear();
            GUI.color = Color.white;
        }
Example #5
0
 public static Vector2 ScreenPos(this WorldObject o)
 {
     return(GenWorldUI.WorldToUIPosition(o.DrawPos));
 }
Example #6
0
        public void WorldCameraDriverOnGUI()
        {
            mouseCoveredByUI = false;
            if (Find.WindowStack.GetWindowAt(UI.MousePositionOnUIInverted) != null)
            {
                mouseCoveredByUI = true;
            }
            if (AnythingPreventsCameraMotion)
            {
                return;
            }
            if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
            {
                Vector2 currentEventDelta = UnityGUIBugsFixer.CurrentEventDelta;
                Event.current.Use();
                if (currentEventDelta != Vector2.zero)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.FrameInteraction);
                    currentEventDelta.x *= -1f;
                    desiredRotationRaw  += currentEventDelta / GenWorldUI.CurUITileSize() * 0.273f * Prefs.MapDragSensitivity;
                }
            }
            float num = 0f;

            if (Event.current.type == EventType.ScrollWheel)
            {
                num -= Event.current.delta.y * 0.1f;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            if (KeyBindingDefOf.MapZoom_In.KeyDownEvent)
            {
                num += 2f;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            if (KeyBindingDefOf.MapZoom_Out.KeyDownEvent)
            {
                num -= 2f;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            desiredAltitude -= num * config.zoomSpeed * altitude / 12f;
            desiredAltitude  = Mathf.Clamp(desiredAltitude, 125f, 1100f);
            desiredRotation  = Vector2.zero;
            if (KeyBindingDefOf.MapDolly_Left.IsDown)
            {
                desiredRotation.x = 0f - config.dollyRateKeys;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            if (KeyBindingDefOf.MapDolly_Right.IsDown)
            {
                desiredRotation.x = config.dollyRateKeys;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            if (KeyBindingDefOf.MapDolly_Up.IsDown)
            {
                desiredRotation.y = config.dollyRateKeys;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            if (KeyBindingDefOf.MapDolly_Down.IsDown)
            {
                desiredRotation.y = 0f - config.dollyRateKeys;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
            }
            config.ConfigOnGUI();
        }