Exemplo n.º 1
0
        public static void GetExpandedWorldObjectUnderMouse(Vector2 mousePos, List <WorldObject> outList)
        {
            outList.Clear();
            Vector2 point = mousePos;

            point.y = (float)UI.screenHeight - point.y;
            List <WorldObject> allWorldObjects = Find.WorldObjects.AllWorldObjects;

            for (int i = 0; i < allWorldObjects.Count; i++)
            {
                WorldObject worldObject = allWorldObjects[i];
                if (ExpandableWorldObjectsUtility.IsExpanded(worldObject))
                {
                    if (ExpandableWorldObjectsUtility.ExpandedIconScreenRect(worldObject).Contains(point))
                    {
                        if (!worldObject.HiddenBehindTerrainNow())
                        {
                            outList.Add(worldObject);
                        }
                    }
                }
            }
            ExpandableWorldObjectsUtility.SortByExpandingIconPriority(outList);
            outList.Reverse();
        }
 public static void ExpandableWorldObjectsOnGUI()
 {
     if (ExpandableWorldObjectsUtility.TransitionPct != 0.0)
     {
         ExpandableWorldObjectsUtility.tmpWorldObjects.Clear();
         ExpandableWorldObjectsUtility.tmpWorldObjects.AddRange(Find.WorldObjects.AllWorldObjects);
         ExpandableWorldObjectsUtility.SortByExpandingIconPriority(ExpandableWorldObjectsUtility.tmpWorldObjects);
         WorldTargeter      worldTargeter          = Find.WorldTargeter;
         List <WorldObject> worldObjectsUnderMouse = null;
         if (worldTargeter.IsTargeting)
         {
             worldObjectsUnderMouse = GenWorldUI.WorldObjectsUnderMouse(UI.MousePositionOnUI);
         }
         for (int i = 0; i < ExpandableWorldObjectsUtility.tmpWorldObjects.Count; i++)
         {
             WorldObject worldObject = ExpandableWorldObjectsUtility.tmpWorldObjects[i];
             if (worldObject.def.expandingIcon && !worldObject.HiddenBehindTerrainNow())
             {
                 Color expandingIconColor = worldObject.ExpandingIconColor;
                 expandingIconColor.a = ExpandableWorldObjectsUtility.TransitionPct;
                 if (worldTargeter.IsTargetedNow(worldObject, worldObjectsUnderMouse))
                 {
                     float num = GenMath.LerpDouble(-1f, 1f, 0.7f, 1f, Mathf.Sin((float)(Time.time * 8.0)));
                     expandingIconColor.r *= num;
                     expandingIconColor.g *= num;
                     expandingIconColor.b *= num;
                 }
                 GUI.color = expandingIconColor;
                 GUI.DrawTexture(ExpandableWorldObjectsUtility.ExpandedIconScreenRect(worldObject), worldObject.ExpandingIcon);
             }
         }
         ExpandableWorldObjectsUtility.tmpWorldObjects.Clear();
         GUI.color = Color.white;
     }
 }