private int ComparePointOfInterest( EnergySignature poiA, EnergySignature poiB) { int num1 = this.IsPoiAtHighAlert(poiA).CompareTo(this.IsPoiAtHighAlert(poiB)); if (num1 != 0) { return(num1); } if (poiA.POIType >= EnergySignatureType.Single && poiB.POIType >= EnergySignatureType.Single) { int num2 = poiA.POIType.CompareTo((object)poiB.POIType); if (num2 != 0) { return(num2); } } if (poiA.IsGrid() && poiB.IsGrid()) { MyCubeBlock entity1 = poiA.Entity as MyCubeBlock; MyCubeBlock entity2 = poiB.Entity as MyCubeBlock; if (entity1 != null && entity2 != null) { int num2 = entity1.CubeGrid.BlocksCount.CompareTo(entity2.CubeGrid.BlocksCount); if (num2 != 0) { return(num2); } } } return(poiB.Distance.CompareTo(poiA.Distance)); }
private Dictionary <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> > GetSignificantGroupPOIs() { Dictionary <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> > dictionary = new Dictionary <MyRelationsBetweenPlayerAndBlock, List <EnergySignature> >(); if (this.m_group == null || this.m_group.Count == 0) { return(dictionary); } bool flag = true; MyRelationsBetweenPlayerAndBlock relationship = this.m_group[0].Relationship; for (int index = 1; index < this.m_group.Count; ++index) { if (this.m_group[index].Relationship != relationship) { flag = false; break; } } if (flag) { this.m_group.Sort(new Comparison <EnergySignature>(this.ComparePointOfInterest)); dictionary[relationship] = new List <EnergySignature>(); for (int index = this.m_group.Count - 1; index >= 0; --index) { dictionary[relationship].Add(this.m_group[index]); if (dictionary[relationship].Count >= 4) { break; } } } else { for (int index = 0; index < this.m_group.Count; ++index) { EnergySignature poiA = this.m_group[index]; MyRelationsBetweenPlayerAndBlock key = poiA.Relationship; if (key == MyRelationsBetweenPlayerAndBlock.NoOwnership) { key = MyRelationsBetweenPlayerAndBlock.Neutral; } if (dictionary.ContainsKey(key)) { if (this.ComparePointOfInterest(poiA, dictionary[key][0]) > 0) { dictionary[key].Clear(); dictionary[key].Add(poiA); } } else { dictionary[key] = new List <EnergySignature>(); dictionary[key].Add(poiA); } } } return(dictionary); }
public bool IsPOINearby(EnergySignature poi, Vector3D cameraPosition, double angle = 10.0) { Vector3D vector3D = 0.5 * (this.WorldPosition - poi.WorldPosition); double num1 = vector3D.LengthSquared(); double num2 = (cameraPosition - (poi.WorldPosition + vector3D)).Length(); double num3 = Math.Sin(angle * (Math.PI / 360.0)) * num2; double num4 = num3 * num3; return(num1 <= num4); }
private bool IsPoiAtHighAlert(EnergySignature poi) { if (poi.Relationship == MyRelationsBetweenPlayerAndBlock.Neutral) { return(false); } foreach (EnergySignature pointOfInterest in this.m_group) { if (this.IsRelationHostile(poi.Relationship, pointOfInterest.Relationship) && (double)((Vector3)(pointOfInterest.WorldPosition - poi.WorldPosition)).LengthSquared() < 1000000.0) { return(true); } } return(false); }
public bool AddPOI(EnergySignature poi) { if (this.POIType != EnergySignatureType.Group) { return(false); } Vector3D vector3D = this.WorldPosition * (double)this.m_group.Count; this.m_group.Add(poi); this.Text.Clear(); this.Text.Append(this.m_group.Count); switch (this.GetGroupRelation()) { case MyRelationsBetweenPlayerAndBlock.NoOwnership: this.Text.AppendStringBuilder(MyTexts.Get(MyStringId.GetOrCompute("Signal_Mixed"))); break; case MyRelationsBetweenPlayerAndBlock.Owner: this.Text.AppendStringBuilder(MyTexts.Get(MyStringId.GetOrCompute("Signal_Own"))); break; case MyRelationsBetweenPlayerAndBlock.FactionShare: this.Text.AppendStringBuilder(MyTexts.Get(MyStringId.GetOrCompute("Signal_Friendly"))); break; case MyRelationsBetweenPlayerAndBlock.Neutral: this.Text.AppendStringBuilder(MyTexts.Get(MyStringId.GetOrCompute("Signal_Neutral"))); break; case MyRelationsBetweenPlayerAndBlock.Enemies: this.Text.AppendStringBuilder(MyTexts.Get(MyStringId.GetOrCompute("Signal_Enemy"))); break; } this.WorldPosition = (vector3D + poi.WorldPosition) / (double)this.m_group.Count; this.Distance = (this.WorldPosition - this.GetDistanceMeasuringMatrix().Translation).Length(); this.DistanceToCam = (this.WorldPosition - MyAPIGateway.Session.Camera.WorldMatrix.Translation).Length(); if (poi.Relationship > this.Relationship) { this.Relationship = poi.Relationship; } return(true); }
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); } }
private bool ShouldDrawHighAlertMark(EnergySignature poi) { return(this.IsPoiAtHighAlert(poi)); }
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); } }