Ejemplo n.º 1
0
        private static void DrawIcon(
            MyHudMarkerRender renderer,
            string centerIconSprite,
            Vector2 screenPosition,
            Color markerColor,
            float sizeScale = 1f)
        {
            Vector2 vector2 = new Vector2(8f, 8f) * sizeScale;

            renderer.AddTexturedQuad(centerIconSprite, screenPosition, -Vector2.UnitY, markerColor, vector2.X, vector2.Y);
        }
Ejemplo n.º 2
0
        private static void DrawIcon(
            MyHudMarkerRender renderer,
            EnergySignatureType poiType,
            MyRelationsBetweenPlayerAndBlock relationship,
            Vector2 screenPosition,
            Color markerColor,
            float sizeScale = 1f)
        {
            string  empty     = string.Empty;
            Vector2 vector2_1 = new Vector2(12f, 12f);
            string  texture;

            switch (poiType)
            {
            case EnergySignatureType.Single:
                string iconForRelationship = EnergySignature.GetIconForRelationship(relationship);
                EnergySignature.DrawIcon(renderer, iconForRelationship, screenPosition, markerColor, sizeScale);
                return;

            case EnergySignatureType.Group:
                return;

            default:
                return;
            }

            if (!string.IsNullOrWhiteSpace(empty))
            {
                Vector2 vector2_2 = vector2_1 * sizeScale;
                renderer.AddTexturedQuad(empty, screenPosition, -Vector2.UnitY, markerColor, vector2_2.X, vector2_2.Y);
            }
            else
            {
                float num = 0.0053336f * sizeScale;
                renderer.AddTexturedQuad(texture, screenPosition, -Vector2.UnitY, markerColor, num, num);
            }
        }
Ejemplo n.º 3
0
        public void Draw(MyHudMarkerRender renderer, float alphaMultiplierMarker = 1f, float alphaMultiplierText = 1f, float scale = 1f, bool drawBox = true)
        {
            Vector2 projectedPoint2D = Vector2.Zero;
            bool    isBehind         = false;

            if (!EnergySignature.TryComputeScreenPoint(this.WorldPosition, out projectedPoint2D, out isBehind))
            {
                return;
            }



            Vector2 vector2_1   = new Vector2(screenWidth, screenHeight);
            Vector2 hudSize     = new Vector2(1f, screenHeight / screenWidth);
            Vector2 hudSizeHalf = hudSize / 2f;
            float   num1        = vector2_1.Y / 1080f;
            Vector2 vector2_2   = projectedPoint2D * hudSize;
            Color   white1      = Color.White;
            Color   fontColor   = Color.White;
            string  font        = "White";

            this.GetPOIColorAndFontInformation(out white1, out fontColor, out font);
            Vector2  upVector = vector2_2 - hudSizeHalf;
            Vector3D vector3D = Vector3D.Transform(this.WorldPosition, MyAPIGateway.Session.Camera.ViewMatrix);
            float    num2     = 0.04f;

            if ((double)vector2_2.X < (double)num2 || (double)vector2_2.X > (double)hudSize.X - (double)num2 || ((double)vector2_2.Y < (double)num2 || (double)vector2_2.Y > (double)hudSize.Y - (double)num2) || vector3D.Z > 0.0)
            {
                Vector2 vector2_3 = Vector2.Normalize(upVector);
                Vector2 position  = hudSizeHalf + hudSizeHalf * vector2_3 * 0.77f;
                upVector = position - hudSizeHalf;
                if ((double)upVector.LengthSquared() > 9.99999943962493E-11)
                {
                    upVector.Normalize();
                }
                else
                {
                    upVector = new Vector2(1f, 0.0f);
                }
                float num3 = 0.0053336f / num1 / num1;
                renderer.AddTexturedQuad("HudAtlas0.dds_DirectionIndicator", position, upVector, white1, num3, num3);
                vector2_2 = position - upVector * 0.006667f * 2f;
            }
            else
            {
                float num3 = scale * 0.006667f / num1 / num1;
                if (drawBox)
                {
                    renderer.AddTexturedQuad("HudAtlas0.dds_Target_neutral", vector2_2, -Vector2.UnitY, white1, num3, num3);
                }
            }
            float num4 = 0.03f;
            float num5 = 0.07f;
            float num6 = 0.15f;
            float num7 = upVector.Length();
            float val;
            float num8;
            int   num9;

            if ((double)num7 <= (double)num4)
            {
                val  = 1f;
                num8 = 1f;
                num9 = 0;
            }
            else if ((double)num7 > (double)num4 && (double)num7 < (double)num5)
            {
                float num3  = num6 - num4;
                float num10 = (float)(1.0 - ((double)num7 - (double)num4) / (double)num3);
                val = num10 * num10;
                float num11 = num5 - num4;
                float num12 = (float)(1.0 - ((double)num7 - (double)num4) / (double)num11);
                num8 = num12 * num12;
                num9 = 1;
            }
            else if ((double)num7 >= (double)num5 && (double)num7 < (double)num6)
            {
                float num3  = num6 - num4;
                float num10 = (float)(1.0 - ((double)num7 - (double)num4) / (double)num3);
                val = num10 * num10;
                float num11 = num6 - num5;
                float num12 = (float)(1.0 - ((double)num7 - (double)num5) / (double)num11);
                num8 = num12 * num12;
                num9 = 2;
            }
            else
            {
                val  = 0.0f;
                num8 = 0.0f;
                num9 = 2;
            }
            float num13 = MathHelper.Clamp((float)(((double)num7 - 0.200000002980232) / 0.5), 0.0f, 1f);
            float num14 = MyMath.Clamp(val, 0.0f, 1f);
            //if (MyHudMarkerRender.m_disableFading || MyHudMarkerRender.SignalDisplayMode == MyHudMarkerRender.SignalMode.FullDisplay || this.AlwaysVisible)
            {
                num14 = 1f;
                num8  = 1f;
                num13 = 1f;
                num9  = 0;
            }

            Vector2 vector2_4 = new Vector2(0.0f, (float)((double)scale * (double)num1 * 24.0) / (float)screenWidth);

            //if ((MyHudMarkerRender.SignalDisplayMode != MyHudMarkerRender.SignalMode.NoNames || this.POIType == EnergySignatureType.ButtonMarker || (MyHudMarkerRender.m_disableFading || this.AlwaysVisible)) && ((double)num14 > 1.40129846432482E-45 && this.Text.Length > 0))
            if ((double)num14 > 1.40129846432482E-45 && this.Text.Length > 0)
            {
                MyHudText myHudText = renderer.m_hudScreen.AllocateText();
                if (myHudText != null)
                {
                    fontColor.A = (byte)((double)byte.MaxValue * (double)alphaMultiplierText * (double)num14);
                    myHudText.Start(font, vector2_2 - vector2_4, fontColor, 0.7f / num1, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                    myHudText.Append(this.Text);
                }
            }

            if (this.POIType != EnergySignatureType.Group)
            {
                byte a = white1.A;
                white1.A = (byte)((double)byte.MaxValue * (double)alphaMultiplierMarker * (double)num13);
                EnergySignature.DrawIcon(renderer, this.POIType, this.Relationship, vector2_2, white1, scale);
                white1.A = a;
                MyHudText myHudText1 = renderer.m_hudScreen.AllocateText();
                if (myHudText1 != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    MyHudMarkerRender.AppendDistance(stringBuilder, this.Distance);
                    fontColor.A = (byte)((double)alphaMultiplierText * (double)byte.MaxValue);
                    myHudText1.Start(font, vector2_2 + vector2_4 * (float)(0.699999988079071 + 0.300000011920929 * (double)num14), fontColor, (float)(0.5 + 0.200000002980232 * (double)num14) / num1, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                    myHudText1.Append(stringBuilder);
                }
                if (string.IsNullOrEmpty(this.ContainerRemainingTime))
                {
                    return;
                }

                MyHudText myHudText2 = renderer.m_hudScreen.AllocateText();
                myHudText2.Start(font, vector2_2 + vector2_4 * (float)(1.60000002384186 + 0.300000011920929 * (double)num14), fontColor, (float)(0.5 + 0.200000002980232 * (double)num14) / num1, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                myHudText2.Append(this.ContainerRemainingTime);
            }
            else
            {
                Dictionary <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> > significantGroupPoIs = this.GetSignificantGroupPOIs();
                Vector2[] vector2Array1 = new Vector2[5]
                {
                    new Vector2(-6f, -4f),
                    new Vector2(6f, -4f),
                    new Vector2(-6f, 4f),
                    new Vector2(6f, 4f),
                    new Vector2(0.0f, 12f)
                };
                Vector2[] vector2Array2 = new Vector2[5]
                {
                    new Vector2(16f, -4f),
                    new Vector2(16f, 4f),
                    new Vector2(16f, 12f),
                    new Vector2(16f, 20f),
                    new Vector2(16f, 28f)
                };
                for (int index = 0; index < vector2Array1.Length; ++index)
                {
                    float num3 = num9 < 2 ? 1f : num8;
                    float y1   = vector2Array1[index].Y;
                    vector2Array1[index].X = (vector2Array1[index].X + 22f * num3) / (float)screenWidth;
                    vector2Array1[index].Y = y1 / 1080f / num1;

                    //can't support triplehead
                    //if (MyVideoSettingsManager.IsTripleHead())
                    //    vector2Array1[index].X /= 0.33f;
                    if ((double)vector2Array1[index].Y <= 1.40129846432482E-45)
                    {
                        vector2Array1[index].Y = y1 / 1080f;
                    }
                    float y2 = vector2Array2[index].Y;
                    vector2Array2[index].X = vector2Array2[index].X / (float)screenWidth / num1;
                    vector2Array2[index].Y = y2 / 1080f / num1;
                    //can't support triplehead
                    //if (MyVideoSettingsManager.IsTripleHead())
                    //    vector2Array2[index].X /= 0.33f;
                    if ((double)vector2Array2[index].Y <= 1.40129846432482E-45)
                    {
                        vector2Array2[index].Y = y2 / 1080f;
                    }
                }
                int index1 = 0;
                if (significantGroupPoIs.Count > 1)
                {
                    MyRelationsBetweenPlayerAndBlock[] betweenPlayerAndBlockArray = new MyRelationsBetweenPlayerAndBlock[4]
                    {
                        MyRelationsBetweenPlayerAndBlock.Owner,
                        MyRelationsBetweenPlayerAndBlock.FactionShare,
                        MyRelationsBetweenPlayerAndBlock.Neutral,
                        MyRelationsBetweenPlayerAndBlock.Enemies
                    };
                    foreach (MyRelationsBetweenPlayerAndBlock index2 in betweenPlayerAndBlockArray)
                    {
                        if (significantGroupPoIs.ContainsKey(index2))
                        {
                            List <EnergySignature> pointOfInterestList = significantGroupPoIs[index2];
                            if (pointOfInterestList.Count != 0)
                            {
                                EnergySignature poi = pointOfInterestList[0];
                                if (poi != null)
                                {
                                    this.GetColorAndFontForRelationship(index2, out white1, out fontColor, out font);
                                    float amount = num9 == 0 ? 1f : num8;
                                    if (num9 >= 2)
                                    {
                                        amount = 0.0f;
                                    }
                                    Vector2 vector2_3           = Vector2.Lerp(vector2Array1[index1], vector2Array2[index1], amount);
                                    string  iconForRelationship = EnergySignature.GetIconForRelationship(index2);
                                    white1.A = (byte)((double)alphaMultiplierMarker * (double)white1.A);
                                    EnergySignature.DrawIcon(renderer, iconForRelationship, vector2_2 + vector2_3, white1, 0.75f / num1);
                                    if (this.IsPoiAtHighAlert(poi))
                                    {
                                        Color white2 = Color.White;
                                        white2.A = (byte)((double)alphaMultiplierMarker * (double)byte.MaxValue);
                                        EnergySignature.DrawIcon(renderer, "Textures\\HUD\\marker_alert.dds", vector2_2 + vector2_3, white2, 0.75f / num1);
                                    }
                                    //if ((MyHudMarkerRender.SignalDisplayMode != MyHudMarkerRender.SignalMode.NoNames || MyHudMarkerRender.m_disableFading || this.AlwaysVisible) && poi.Text.Length > 0)
                                    if (poi.Text.Length > 0)
                                    {
                                        MyHudText myHudText = renderer.m_hudScreen.AllocateText();
                                        if (myHudText != null)
                                        {
                                            float num3 = 1f;
                                            if (num9 == 1)
                                            {
                                                num3 = num8;
                                            }
                                            else if (num9 > 1)
                                            {
                                                num3 = 0.0f;
                                            }
                                            fontColor.A = (byte)((double)byte.MaxValue * (double)alphaMultiplierText * (double)num3);
                                            Vector2 vector2_5 = new Vector2(8f / (float)screenWidth, 0.0f);
                                            vector2_5.X /= num1;
                                            myHudText.Start(font, vector2_2 + vector2_3 + vector2_5, fontColor, 0.55f / num1, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                                            myHudText.Append(poi.Text);
                                        }
                                    }
                                    ++index1;
                                }
                            }
                        }
                    }
                }
                else
                {
                    using (Dictionary <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> > .Enumerator enumerator = significantGroupPoIs.GetEnumerator())
                    {
label_86:
                        while (enumerator.MoveNext())
                        {
                            KeyValuePair <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> > current = enumerator.Current;
                            MyRelationsBetweenPlayerAndBlock key = current.Key;
                            if (significantGroupPoIs.ContainsKey(key))
                            {
                                List <EnergySignature> pointOfInterestList = current.Value;
                                int index2 = 0;
                                while (true)
                                {
                                    if (index2 < 4 && index2 < pointOfInterestList.Count)
                                    {
                                        EnergySignature poi = pointOfInterestList[index2];
                                        if (poi != null)
                                        {
                                            this.GetColorAndFontForRelationship(key, out white1, out fontColor, out font);
                                            float amount = num9 == 0 ? 1f : num8;
                                            if (num9 >= 2)
                                            {
                                                amount = 0.0f;
                                            }
                                            Vector2 vector2_3        = Vector2.Lerp(vector2Array1[index1], vector2Array2[index1], amount);
                                            string  centerIconSprite = EnergySignature.GetIconForRelationship(key);
                                            white1.A = (byte)((double)alphaMultiplierMarker * (double)white1.A);
                                            EnergySignature.DrawIcon(renderer, centerIconSprite, vector2_2 + vector2_3, white1, 0.75f / num1);
                                            if (this.ShouldDrawHighAlertMark(poi))
                                            {
                                                Color white2 = Color.White;
                                                white2.A = (byte)((double)alphaMultiplierMarker * (double)byte.MaxValue);
                                                EnergySignature.DrawIcon(renderer, "Textures\\HUD\\marker_alert.dds", vector2_2 + vector2_3, white2, 0.75f / num1);
                                            }

                                            //if ((MyHudMarkerRender.SignalDisplayMode != MyHudMarkerRender.SignalMode.NoNames || MyHudMarkerRender.m_disableFading || this.AlwaysVisible) && poi.Text.Length > 0)
                                            if (poi.Text.Length > 0)
                                            {
                                                MyHudText myHudText = renderer.m_hudScreen.AllocateText();
                                                if (myHudText != null)
                                                {
                                                    float num3 = 1f;
                                                    if (num9 == 1)
                                                    {
                                                        num3 = num8;
                                                    }
                                                    else if (num9 > 1)
                                                    {
                                                        num3 = 0.0f;
                                                    }
                                                    fontColor.A = (byte)((double)byte.MaxValue * (double)alphaMultiplierText * (double)num3);
                                                    Vector2 vector2_5 = new Vector2(8f / (float)screenWidth, 0.0f);
                                                    vector2_5.X /= num1;
                                                    myHudText.Start(font, vector2_2 + vector2_3 + vector2_5, fontColor, 0.55f / num1, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
                                                    myHudText.Append(poi.Text);
                                                }
                                            }
                                            ++index1;
                                        }
                                        ++index2;
                                    }
                                    else
                                    {
                                        goto label_86;
                                    }
                                }
                            }
                        }
                    }
                }
                this.GetPOIColorAndFontInformation(out white1, out fontColor, out font);
                float amount1 = num9 == 0 ? 1f : num8;
                if (num9 >= 2)
                {
                    amount1 = 0.0f;
                }
                Vector2   vector2_6  = Vector2.Lerp(vector2Array1[4], vector2Array2[index1], amount1);
                Vector2   vector2_7  = Vector2.Lerp(Vector2.Zero, new Vector2(0.02222222f / num1, 1f / 270f / num1), amount1);
                MyHudText myHudText1 = renderer.m_hudScreen.AllocateText();
                if (myHudText1 == null)
                {
                    return;
                }
                StringBuilder stringBuilder = new StringBuilder();
                MyHudMarkerRender.AppendDistance(stringBuilder, this.Distance);
                fontColor.A = (byte)((double)alphaMultiplierText * (double)byte.MaxValue);
                myHudText1.Start(font, vector2_2 + vector2_6 + vector2_7, fontColor, (float)(0.5 + 0.200000002980232 * (double)num14) / num1, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
                myHudText1.Append(stringBuilder);
            }
        }