public void DrawPath(Vector2[] points, StrokeStyle strokeStyle, bool closePath)
        {
            if (points.Length < 2)
            {
                Debug.LogError("DrawPath() needs at least two points to draw");
                return;
            }
            else if (points.Length == 2)
            {
                DrawLine(points[0], points[1], strokeStyle);
                if (closePath)
                {
                    Debug.LogWarning("DrawPath() can't close a path with only two points. 'closePath' parameter ignored.");
                }
                return;
            }

            float relativeThickness = strokeStyle.scaleMode == StrokeScaleMode.Absolute ?
                                      strokeStyle.thickness / rectTransform.rect.width :
                                      strokeStyle.thickness;

//			Debug.Log(String.Join(", ", PUIUtils.GetPathPoints(points, closePath, relativeThickness, aspectRatio).Select(x => x.ToString("f5")).ToArray()));
            elements.Add(new PUIStrokeElement(points,
                                              PUIUtils.GetPathPoints(points, closePath, relativeThickness, aspectRatio),
                                              strokeStyle,
                                              closePath));

            if (setDirtyOnDraw)
            {
                SetVerticesDirty();
            }
        }
示例#2
0
 public static void Postfix()
 {
     if (SweepyConfigChecker.UseCustomSliders)
     {
         PUIUtils.AddSideScreenContent <SweepBotStationSideScreen>((GameObject)null);
     }
 }
        protected override void OnRectTransformDimensionsChange()
        {
            base.OnRectTransformDimensionsChange();

            PUIStrokeElement current;

            foreach (PUIElement el in elements)
            {
                if (el.GetType() == typeof(PUIStrokeElement))
                {
                    current = (PUIStrokeElement)el;

                    if (current.strokeStyle.scaleMode == StrokeScaleMode.Absolute)
                    {
                        float relativeThickness = current.strokeStyle.thickness / rectTransform.rect.width;

                        if (current.rawPoints.Length == 2)
                        {
                            current.UpdatePoints(PUIUtils.GetLinePoints(current.rawPoints[0], current.rawPoints[1],
                                                                        relativeThickness,
                                                                        aspectRatio));
                        }
                        else
                        {
                            current.UpdatePoints(PUIUtils.GetPathPoints(current.rawPoints,
                                                                        current.isClosedPath,
                                                                        relativeThickness,
                                                                        aspectRatio));
                        }
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Loads the specified sprite.
        /// </summary>
        /// <param name="name">The sprite file name without the extension.</param>
        private static Sprite LoadSprite(string name)
        {
            var sprite = PUIUtils.LoadSprite(BASE_PATH + name + ".png");

            sprite.name = name;
            return(sprite);
        }
示例#5
0
        /// <summary>
        /// Fired when a key is pressed.
        /// </summary>
        /// <param name="e">The event that occurred.</param>
        public void OnKeyDown(KButtonEvent e)
        {
            var es = UnityEngine.EventSystems.EventSystem.current;

            if (e.TryConsume(snapshotAction) && es != null)
            {
                var results = ListPool <RaycastResult, DebugHandler> .Allocate();

                es.RaycastAll(new PointerEventData(es)
                {
                    position = Input.mousePosition
                },
                              results);
                GameObject obj;
                foreach (var hit in results)
                {
                    if (hit.isValid && (obj = hit.gameObject) != null)
                    {
                        // Found it!
                        PUIUtils.DebugObjectTree(obj);
                        PUIUtils.DebugObjectHierarchy(obj);
                    }
                }
                results.Recycle();
            }
        }
示例#6
0
        /// <summary>
        /// Fills in the mod info screen, assuming that infoAttr is non-null.
        /// </summary>
        /// <param name="dialog">The dialog to populate.</param>
        private void AddModInfoScreen(PDialog dialog)
        {
            string image = displayInfo.Image;
            var    body  = dialog.Body;

            // Try to load the mod image sprite if possible
            if (modImage == null && !string.IsNullOrEmpty(image))
            {
                string rootDir = PUtil.GetModPath(optionsType.Assembly);
                modImage = PUIUtils.LoadSpriteFile(rootDir == null ? image : Path.Combine(
                                                       rootDir, image));
            }
            var websiteButton = new PButton("ModSite")
            {
                Text    = PLibStrings.MOD_HOMEPAGE, ToolTip = PLibStrings.TOOLTIP_HOMEPAGE,
                OnClick = VisitModHomepage, Margin = PDialog.BUTTON_MARGIN
            }.SetKleiBlueStyle();
            var versionLabel = new PLabel("ModVersion")
            {
                Text      = displayInfo.Version, ToolTip = PLibStrings.TOOLTIP_VERSION,
                TextStyle = PUITuning.Fonts.UILightStyle, Margin = new RectOffset(0, 0,
                                                                                  OUTER_MARGIN, 0)
            };
            // Find mod URL
            string modURL = displayInfo.URL;

            if (modImage != null)
            {
                // 2 rows and 1 column
                if (optionCategories.Count > 0)
                {
                    body.Direction = PanelDirection.Horizontal;
                }
                var infoPanel = new PPanel("ModInfo")
                {
                    FlexSize  = Vector2.up, Direction = PanelDirection.Vertical,
                    Alignment = TextAnchor.UpperCenter
                }.AddChild(new PLabel("ModImage")
                {
                    SpriteSize = MOD_IMAGE_SIZE, TextAlignment = TextAnchor.UpperLeft,
                    Margin     = new RectOffset(0, OUTER_MARGIN, 0, OUTER_MARGIN),
                    Sprite     = modImage
                });
                if (!string.IsNullOrEmpty(modURL))
                {
                    infoPanel.AddChild(websiteButton);
                }
                body.AddChild(infoPanel.AddChild(versionLabel));
            }
            else
            {
                if (!string.IsNullOrEmpty(modURL))
                {
                    body.AddChild(websiteButton);
                }
                body.AddChild(versionLabel);
            }
        }
示例#7
0
        /// <summary>
        /// Initializes and computes horizontal sizes for the components in this relative
        /// layout.
        /// </summary>
        /// <param name="children">The location to store information about these components.</param>
        /// <param name="all">The components to lay out.</param>
        /// <param name="constraints">The constraints defined for these components.</param>
        internal static void CalcX(this ICollection <RelativeLayoutResults> children,
                                   RectTransform all, IDictionary <GameObject, RelativeLayoutParams> constraints)
        {
            var comps = ListPool <Component, RelativeLayoutGroup> .Allocate();

            var paramMap = DictionaryPool <GameObject, RelativeLayoutResults,
                                           RelativeLayoutGroup> .Allocate();

            int n = all.childCount;

            children.Clear();
            for (int i = 0; i < n; i++)
            {
                var child = all.GetChild(i)?.gameObject;
                if (child != null)
                {
                    comps.Clear();
                    // Calculate the preferred size using all layout components
                    child.GetComponents(comps);
                    var horiz = PUIUtils.CalcSizes(child, PanelDirection.Horizontal, comps);
                    if (!horiz.ignore)
                    {
                        RelativeLayoutResults ip;
                        float w = horiz.preferred;
                        if (constraints.TryGetValue(child, out RelativeLayoutParams cons))
                        {
                            ip = new RelativeLayoutResults(child.rectTransform(), cons);
                            // Set override size by axis if necessary
                            var overrideSize = ip.OverrideSize;
                            if (overrideSize.x > 0.0f)
                            {
                                w = overrideSize.x;
                            }
                            paramMap[child] = ip;
                        }
                        else
                        {
                            // Default its layout to fill all
                            ip = new RelativeLayoutResults(child.rectTransform(), null);
                        }
                        ip.PreferredWidth = w;
                        children.Add(ip);
                    }
                }
            }
            // Resolve object references to other children
            foreach (var ip in children)
            {
                ip.TopParams    = InitResolve(ip.TopEdge, paramMap);
                ip.BottomParams = InitResolve(ip.BottomEdge, paramMap);
                ip.LeftParams   = InitResolve(ip.LeftEdge, paramMap);
                ip.RightParams  = InitResolve(ip.RightEdge, paramMap);
                // All of these will die simultaneously when the list is recycled
            }
            paramMap.Recycle();
            comps.Recycle();
        }
            public static void Postfix()
            {
                SideScreenContent scn = Traverse.Create(DetailsScreen.Instance).Field("currentSideScreen").GetValue <SideScreenContent>();

                if (scn != null)
                {
                    PUIUtils.DebugObjectTree(scn.gameObject);
                }
            }
示例#9
0
 /// <summary>
 /// Called each frame by Unity, checks to see if the user clicks/scrolls outside of
 /// the dropdown while open, and closes it if so.
 /// </summary>
 internal void Update()
 {
     if (actionsScreen != null && (PUIUtils.GetMouseButton(0) || PUIUtils.GetInputAxis(
                                       "Mouse ScrollWheel") != 0.0f) && !actionsScreen.IsOver &&
         (callingButton == null || !callingButton.GetMouseOver))
     {
         HidePopup();
     }
 }
 /// <summary>
 /// Loads a sprite and adds it to the master sprite list.
 /// </summary>
 /// <param name="sprite">The sprite to load.</param>
 private static void LoadAndAddSprite(string sprite)
 {
     try {
         Assets.Sprites.Add(sprite, PUIUtils.LoadSprite(BASE_PATH + sprite + ".png",
                                                        log: false));
     } catch (System.ArgumentException) {
         PUtil.LogWarning("Unable to load image " + sprite + "!");
     }
 }
示例#11
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             TOOL_ICON      = PUIUtils.LoadSprite("PeterHan.SweepByType.Sweep.png");
             TOOL_ICON.name = SweepByTypeStrings.TOOL_ICON_NAME;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }
示例#12
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             TOOL_ICON      = PUIUtils.LoadSprite("PeterHan.SandboxTools.Destroy.png");
             TOOL_ICON.name = SandboxToolsStrings.TOOL_DESTROY_ICON;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }
示例#13
0
        /// <summary>
        /// Loads the specified sprite into the assets.
        /// </summary>
        /// <param name="path">The image file name.</param>
        /// <param name="name">The desired sprite name.</param>
        private static void LoadImage(string path, string name)
        {
            var sprite = PUIUtils.LoadSprite("PeterHan.Resculpt." + path);

            if (sprite == null)
            {
                sprite = Assets.GetSprite(DEFAULT_SPRITE);
            }
            if (sprite != null)
            {
                sprite.name = name;
            }
            Assets.Sprites.Add(name, sprite);
        }
示例#14
0
        internal static void InitStrings()
        {
            Strings.Add(WORLD_NAME, Challenge100KStrings.NAME);
            Strings.Add("STRINGS.WORLDS.ONEHUNDREDK.DESCRIPTION", Challenge100KStrings.
                        DESCRIPTION);
            Strings.Add("STRINGS.CLUSTER_NAMES.ONEHUNDREDK.NAME", Challenge100KStrings.NAME);
            Strings.Add("STRINGS.CLUSTER_NAMES.ONEHUNDREDK.DESCRIPTION", Challenge100KStrings.
                        DESCRIPTION);
            var sprite = PUIUtils.LoadSprite("PeterHan.Challenge100K." + SPRITE + ".png");

            if (sprite != null)
            {
                Assets.Sprites.Add(SPRITE, sprite);
            }
        }
        public void DrawLine(Vector2 point1, Vector2 point2, StrokeStyle strokeStyle)
        {
            float relativeThickness = strokeStyle.scaleMode == StrokeScaleMode.Absolute ?
                                      strokeStyle.thickness / rectTransform.rect.width :
                                      strokeStyle.thickness;

            elements.Add(new PUIStrokeElement(new Vector2[] { point1, point2 },
                                              PUIUtils.GetLinePoints(point1, point2, relativeThickness, aspectRatio),
                                              strokeStyle,
                                              false));

            if (setDirtyOnDraw)
            {
                SetVerticesDirty();
            }
        }
示例#16
0
 /// <summary>
 /// Loads the sprites if they are not already loaded.
 /// </summary>
 private static void LoadSprites()
 {
     if (!spritesLoaded)
     {
         try {
             PLACE_ICON      = PUIUtils.LoadSprite("PeterHan.BulkSettingsChange.Placer.png");
             PLACE_ICON.name = BulkChangeStrings.PLACE_ICON_NAME;
             TOOL_ICON       = PUIUtils.LoadSprite("PeterHan.BulkSettingsChange.Toggle.png");
             TOOL_ICON.name  = BulkChangeStrings.TOOL_ICON_NAME;
         } catch (ArgumentException e) {
             // Could not load the icons, but better this than crashing
             PUtil.LogException(e);
         }
         spritesLoaded = true;
     }
 }
            public static void Postfix()
            {
                List <DetailsScreen.SideScreenRef> sideScreens = Traverse.Create(DetailsScreen.Instance).Field("sideScreens").GetValue <List <DetailsScreen.SideScreenRef> >();
                GameObject               sideScreenContentBody = Traverse.Create(DetailsScreen.Instance).Field("sideScreenContentBody").GetValue <GameObject>();
                GridFilterableControl    gridSelectControl     = new GridFilterableControl();
                GridFilterableSideScreen screen = gridSelectControl.RootPanel.AddComponent <GridFilterableSideScreen>();

                screen.gameObject.transform.parent = sideScreenContentBody.transform;
                PUIUtils.DebugObjectTree(sideScreenContentBody);
                DetailsScreen.SideScreenRef myRef = new DetailsScreen.SideScreenRef {
                    name           = "bob",
                    screenPrefab   = screen,
                    offset         = new Vector2(0f, 0f),
                    screenInstance = screen
                };
                sideScreens.Add(myRef);
                Console.WriteLine("Postfix patch was called and added in the side screen");
            }
示例#18
0
        /// <summary>
        /// Computes vertical sizes for the components in this relative layout.
        /// </summary>
        /// <param name="children">The location to store information about these components.</param>
        internal static void CalcY(this ICollection <RelativeLayoutResults> children)
        {
            var comps = ListPool <Component, RelativeLayout> .Allocate();

            foreach (var ip in children)
            {
                var child        = ip.Transform.gameObject;
                var overrideSize = ip.OverrideSize;
                comps.Clear();
                // Calculate the preferred size using all layout components
                child.gameObject.GetComponents(comps);
                float h = PUIUtils.CalcSizes(child, PanelDirection.Vertical, comps).preferred;
                // Set override size by axis if necessary
                if (overrideSize.y > 0.0f)
                {
                    h = overrideSize.y;
                }
                ip.PreferredHeight = h;
            }
            comps.Recycle();
        }
 private static void Postfix()
 {
     PUIUtils.AddSideScreenContent <ButcherStationSideScreen>();
 }
示例#20
0
 public static void Instantiate(MeterScreen parentScreen)
 {
     Instance = new Clock();
     PUIUtils.AddTo(Instance, parentScreen.gameObject);
 }
示例#21
0
文件: Patch.cs 项目: romen-h/ONI-Mods
 internal static void Postfix()
 {
     PUIUtils.AddSideScreenContent <LogicScheduleSensorSideScreen>();
 }
        public void DrawPolygon(Vector2[] points, Color fillColor, StrokeStyle strokeStyle)
        {
            if (points.Length < 3)
            {
                Debug.LogError("DrawPolygon() requires at least 3 vertices");
                return;
            }
            else if (points.Length == 3)
            {
                points = new Vector2[] { points[0], points[1], points[2] };
                elements.Add(new PUIFillElement(points, new int[] { 0, 1, 2 }, fillColor));
            }
            else if (points.Length == 4)
            {
                elements.Add(new PUIFillElement(points, new int[] { 0, 1, 2, 2, 3, 0 }, fillColor));
            }
            else
            {
                //fill into tris
                int[] triangles            = new int[(points.Length - 2) * 3];
                int   currentTriangleIndex = 0;

                LinkedList <Vector2>             allVertices    = new LinkedList <Vector2>(points);
                List <LinkedListNode <Vector2> > ears           = new List <LinkedListNode <Vector2> >();
                List <LinkedListNode <Vector2> > convexVertices = new List <LinkedListNode <Vector2> >();
                List <LinkedListNode <Vector2> > reflexVertices = new List <LinkedListNode <Vector2> >();

                LinkedListNode <Vector2> currentVertex = allVertices.First;
                LinkedListNode <Vector2> previousVertex;
                LinkedListNode <Vector2> nextVertex;
                LinkedListNode <Vector2> adjPreviousVertex;            //adjacent
                LinkedListNode <Vector2> adjNextVertex;                //adjacent
                LinkedListNode <Vector2> leftMostVertex = allVertices.First;

                //find left-most vertex to determine vertex order direction (CW or CCW)
                while (currentVertex.Next != null)
                {
                    currentVertex = currentVertex.Next;
                    if (currentVertex.Value.x < leftMostVertex.Value.x)
                    {
                        leftMostVertex = currentVertex;
                    }
                }

                previousVertex = leftMostVertex.Previous ?? leftMostVertex.List.Last;
                nextVertex     = leftMostVertex.Next ?? leftMostVertex.List.First;

                bool clockwise = nextVertex.Value.y > previousVertex.Value.y;

                //set up direction-specifics
                Func <Vector2, Vector2, Vector2, bool> IsConvex;                 //prev, cur, next
                if (clockwise)
                {
                    IsConvex = (prev, cur, next) => {
                        Vector2 edge1 = cur - prev;
                        Vector2 edge2 = next - cur;
                        return(Vector2.Dot(new Vector2(-edge1.y, edge1.x), edge2) < 0);                        //right turn
                    };
                }
                else
                {
                    IsConvex = (prev, cur, next) => {
                        Vector2 edge1 = cur - prev;
                        Vector2 edge2 = next - cur;
                        return(Vector2.Dot(new Vector2(-edge1.y, edge1.x), edge2) > 0);                        //left turn
                    };
                }

                //initialize initial convex, concave and ear lists
                currentVertex = allVertices.First;
                for (int i = 0; i < allVertices.Count; i++)
                {
                    previousVertex = currentVertex.Previous ?? currentVertex.List.Last;
                    nextVertex     = currentVertex.Next ?? currentVertex.List.First;

                    if (IsConvex(previousVertex.Value, currentVertex.Value, nextVertex.Value))
                    {
                        convexVertices.Add(currentVertex);

                        float triArea = PUIUtils.GetTriangleArea(previousVertex.Value, currentVertex.Value, nextVertex.Value);
                        bool  isEar   = true;
                        foreach (LinkedListNode <Vector2> vert in reflexVertices)
                        {
                            if (PUIUtils.PointInTriangle(vert.Value, previousVertex.Value, currentVertex.Value, nextVertex.Value, triArea))
                            {
                                isEar = false;
                                break;
                            }
                        }
                        if (isEar)
                        {
                            ears.Add(currentVertex);
                        }
                    }
                    else
                    {
                        reflexVertices.Add(currentVertex);
                    }

                    currentVertex = currentVertex.Next;
                }

                while (allVertices.Count > 3)
                {
                    currentVertex  = ears[0];
                    previousVertex = currentVertex.Previous ?? currentVertex.List.Last;
                    nextVertex     = currentVertex.Next ?? currentVertex.List.First;

                    triangles[currentTriangleIndex]     = Array.IndexOf(points, previousVertex.Value);
                    triangles[currentTriangleIndex + 1] = Array.IndexOf(points, currentVertex.Value);
                    triangles[currentTriangleIndex + 2] = Array.IndexOf(points, nextVertex.Value);
                    currentTriangleIndex += 3;

                    ears.Remove(currentVertex);
                    allVertices.Remove(currentVertex);

                    LinkedListNode <Vector2>[] adjacentVerts = new LinkedListNode <Vector2>[] { previousVertex, nextVertex };
                    foreach (LinkedListNode <Vector2> adjacentVert in adjacentVerts)
                    {
                        adjPreviousVertex = adjacentVert.Previous ?? adjacentVert.List.Last;
                        adjNextVertex     = adjacentVert.Next ?? adjacentVert.List.First;

                        if (IsConvex(adjPreviousVertex.Value, adjacentVert.Value, adjNextVertex.Value))
                        {
                            if (reflexVertices.Contains(adjacentVert))
                            {
                                reflexVertices.Remove(adjacentVert);
                                convexVertices.Add(adjacentVert);
                            }

                            //check earness
                            float triArea = PUIUtils.GetTriangleArea(adjPreviousVertex.Value, adjacentVert.Value, adjNextVertex.Value);
                            bool  isEar   = true;
                            foreach (LinkedListNode <Vector2> vert in reflexVertices)
                            {
                                if (PUIUtils.PointInTriangle(vert.Value, adjPreviousVertex.Value, adjacentVert.Value, adjNextVertex.Value, triArea))
                                {
                                    isEar = false;
                                    break;
                                }
                            }
                            if (isEar && !ears.Contains(adjacentVert))
                            {
                                ears.Add(adjacentVert);
                            }
                            else if (!isEar && ears.Contains(adjacentVert))
                            {
                                ears.Remove(adjacentVert);
                            }
                        }
                        else                          //reflex
                        {
                            convexVertices.Remove(adjacentVert);
                            reflexVertices.Add(adjacentVert);
                        }
                    }
                }

                triangles[currentTriangleIndex]     = Array.IndexOf(points, allVertices.First.Value);
                triangles[currentTriangleIndex + 1] = Array.IndexOf(points, allVertices.First.Next.Value);
                triangles[currentTriangleIndex + 2] = Array.IndexOf(points, allVertices.First.Next.Next.Value);

                elements.Add(new PUIFillElement(points, triangles, fillColor));
            }

            if (strokeStyle != null)
            {
                DrawPath(points, strokeStyle, true);
            }

            if (setDirtyOnDraw)
            {
                SetVerticesDirty();
            }
        }
示例#23
0
 internal static void Postfix()
 {
     PUIUtils.AddSideScreenContent <SimpleCurtainSidescreen>();
 }
示例#24
0
 public static void Postfix()
 {
     Strings.Add("STRINGS.UI.UISIDESCREENS.UNCATEGORIZED_FILTERABLE_SIDE_SCREEN.TITLE", "Automated Storage Capacity");
     PUIUtils.AddSideScreenContentWithOrdering <UncategorizedFilterableSideScreen>(typeof(CapacityControlSideScreen).FullName);
 }
            public static Vector2[] GetPathPoints(Vector2[] points, bool closePath, float strokeThickness, float aspectRatio)
            {
                //	For-loop points map:
                //	count - 8	inner 1 start		count - 5	inner 1 end
                //	count - 1	inner 2 start		count - 4	inner 2 end
                //	count - 7	outer 1 start		count - 6	outer 1 end
                //	count - 3	outer 2 start		count - 2	outer 2 end

                Vector2 evenThickness = new Vector2(strokeThickness, strokeThickness * aspectRatio);

                Vector2 dir = (points[1] - points[0]).normalized;
                Vector2 orthogonalOffset = new Vector2(-dir.y * evenThickness.x, dir.x * evenThickness.y);
                Vector2?intersectionInner;
                Vector2?intersectionOuter;
                Vector2 intersection;

                List <Vector2> _points = new List <Vector2>();

                _points.Add(points[0] - orthogonalOffset);
                _points.Add(points[0] + orthogonalOffset);
                _points.Add(points[1] + orthogonalOffset);
                _points.Add(points[1] - orthogonalOffset);

                for (int i = 1; i < points.Length - 1; i++)
                {
                    dir = (points[i + 1] - points[i]).normalized;
                    orthogonalOffset = new Vector2(-dir.y * evenThickness.x, dir.x * evenThickness.y);

                    _points.Add(points[i] - orthogonalOffset);
                    _points.Add(points[i] + orthogonalOffset);
                    _points.Add(points[i + 1] + orthogonalOffset);
                    _points.Add(points[i + 1] - orthogonalOffset);

                    intersectionInner = PUIUtils.GetLineIntersection(_points[_points.Count - 8], _points[_points.Count - 5],
                                                                     _points[_points.Count - 4], _points[_points.Count - 1]);
                    intersectionOuter = PUIUtils.GetLineIntersection(_points[_points.Count - 7], _points[_points.Count - 6],
                                                                     _points[_points.Count - 3], _points[_points.Count - 2]);

                    if (intersectionInner != null)
                    {
                        intersection = intersectionInner.Value;
                        _points[_points.Count - 5] = _points[_points.Count - 4] = intersection;
                    }

                    if (intersectionOuter != null)
                    {
                        intersection = intersectionOuter.Value;

                        _points[_points.Count - 6] = _points[_points.Count - 3] = intersection;
                    }
                }

                if (closePath)
                {
                    dir = (points[points.Length - 1] - points[0]).normalized;
                    orthogonalOffset = new Vector2(-dir.y * evenThickness.x, dir.x * evenThickness.y);

                    _points.Add(points[points.Length - 1] - orthogonalOffset);
                    _points.Add(points[points.Length - 1] + orthogonalOffset);
                    _points.Add(points[0] + orthogonalOffset);
                    _points.Add(points[0] - orthogonalOffset);

                    //last -> closing
                    intersectionInner = PUIUtils.GetLineIntersection(_points[_points.Count - 8], _points[_points.Count - 5],
                                                                     _points[_points.Count - 3], _points[_points.Count - 2]);
                    intersectionOuter = PUIUtils.GetLineIntersection(_points[_points.Count - 7], _points[_points.Count - 6],
                                                                     _points[_points.Count - 4], _points[_points.Count - 1]);

                    if (intersectionInner != null)
                    {
                        intersection = intersectionInner.Value;
                        _points[_points.Count - 5] = _points[_points.Count - 3] = intersection;
                    }
//
                    if (intersectionOuter != null)
                    {
                        intersection = intersectionOuter.Value;
                        _points[_points.Count - 6] = _points[_points.Count - 4] = intersection;
                    }

                    //closing -> first
                    intersectionInner = PUIUtils.GetLineIntersection(_points[3], _points[0],
                                                                     _points[_points.Count - 3], _points[_points.Count - 2]);
                    intersectionOuter = PUIUtils.GetLineIntersection(_points[2], _points[1],
                                                                     _points[_points.Count - 4], _points[_points.Count - 1]);

                    if (intersectionInner != null)
                    {
                        intersection = intersectionInner.Value;
                        _points[0]   = _points[_points.Count - 2] = intersection;
                    }

                    if (intersectionOuter != null)
                    {
                        intersection = intersectionOuter.Value;
                        _points[1]   = _points[_points.Count - 1] = intersection;
                    }
                }

                return(_points.ToArray());
            }
示例#26
0
 public static void Postfix()
 {
     PUIUtils.AddSideScreenContent <WirelessPowerReceiverSideScreen>((GameObject)null);
     PUIUtils.AddSideScreenContent <WirelessPowerSenderSideScreen>((GameObject)null);
 }