private void DrawThreatIndicator(Vector3 vesselPos, Vector3 targetPos, Color Teamcolor)
        {
            if (Event.current.type.Equals(EventType.Repaint))
            {
                Vector3 screenPos  = BDGUIUtils.GetMainCamera().WorldToViewportPoint(vesselPos);
                Vector3 screenTPos = BDGUIUtils.GetMainCamera().WorldToViewportPoint(targetPos);
                if (screenTPos.z > 0)
                {
                    float xPos  = (screenPos.x * Screen.width);
                    float yPos  = ((1 - screenPos.y) * Screen.height);
                    float xtPos = (screenTPos.x * Screen.width);
                    float ytPos = ((1 - screenTPos.y) * Screen.height);

                    Vector2 head;
                    Vector2 tail;

                    head.x = xPos;
                    head.y = yPos;
                    tail.x = xtPos;
                    tail.y = ytPos;
                    float angle = Vector2.Angle(Vector3.up, tail - head);
                    if (tail.x < head.x)
                    {
                        angle = -angle;
                    }
                    DrawPointer(tail, (angle - 180), 2, Teamcolor);
                }
            }
        }
        private void DrawOnScreenIcon(Vector3 worldPos, Texture texture, Vector2 size, Color Teamcolor, bool ShowPointer)
        {
            if (Event.current.type.Equals(EventType.Repaint))
            {
                bool    offscreen = false;
                Vector3 screenPos = BDGUIUtils.GetMainCamera().WorldToViewportPoint(worldPos);
                if (screenPos.z < 0)
                {
                    offscreen    = true;
                    screenPos.x *= -1;
                    screenPos.y *= -1;
                }
                if (screenPos.x != Mathf.Clamp01(screenPos.x))
                {
                    offscreen = true;
                }
                if (screenPos.y != Mathf.Clamp01(screenPos.y))
                {
                    offscreen = true;
                }
                float xPos  = (screenPos.x * Screen.width) - (0.5f * size.x);
                float yPos  = ((1 - screenPos.y) * Screen.height) - (0.5f * size.y);
                float xtPos = 1 * (Screen.width / 2);
                float ytPos = 1 * (Screen.height / 2);

                if (!offscreen)
                {
                    IconMat.SetColor("_TintColor", Teamcolor);
                    IconMat.mainTexture = texture;
                    Rect iconRect = new Rect(xPos, yPos, size.x, size.y);
                    Graphics.DrawTexture(iconRect, texture, IconMat);
                }
                else
                {
                    if (BDTISettings.POINTERS)
                    {
                        Vector2 head;
                        Vector2 tail;

                        head.x = xPos;
                        head.y = yPos;
                        tail.x = xtPos;
                        tail.y = ytPos;
                        float angle = Vector2.Angle(Vector3.up, tail - head);
                        if (tail.x < head.x)
                        {
                            angle = -angle;
                        }
                        if (ShowPointer && BDTISettings.POINTERS)
                        {
                            DrawPointer(calculateRadialCoords(head, tail, angle, 0.75f), angle, 4, Teamcolor);
                        }
                    }
                }
            }
        }
        public static void DrawPointer(Vector2 Pointer, float angle, float width, Color color)
        {
            Camera cam = BDGUIUtils.GetMainCamera();

            if (cam == null)
            {
                return;
            }

            GUI.matrix = Matrix4x4.identity;
            float length = 60;

            Rect upRect = new Rect(Pointer.x - (width / 2), Pointer.y - length, width, length);

            GUIUtility.RotateAroundPivot(-angle + 180, Pointer);
            BDGUIUtils.DrawRectangle(upRect, color);
            GUI.matrix = Matrix4x4.identity;
        }