public void DrawLocationMarkers(MyHudLocationMarkers locationMarkers) { ProfilerShort.Begin("MyHudMarkerRender.DrawLocationMarkers"); m_sortedMarkers.Clear(); foreach (var entityMarker in locationMarkers.MarkerEntities) { m_sortedMarkers.Add(entityMarker.Value); } m_sortedMarkers.Sort(m_distanceComparer); foreach (var entityMarker in m_sortedMarkers) { MyEntity entity = entityMarker.Entity; if (entityMarker.ShouldDraw != null && !entityMarker.ShouldDraw()) { continue; } float distance = (float)(MySector.MainCamera.Position - entity.PositionComp.WorldVolume.Center).Length(); if ((entityMarker.TargetMode == MyRelationsBetweenPlayerAndBlock.NoOwnership || entityMarker.TargetMode == MyRelationsBetweenPlayerAndBlock.FactionShare) && m_friendAntennaRange < distance) { continue; } if ((entityMarker.TargetMode == MyRelationsBetweenPlayerAndBlock.Neutral || entityMarker.TargetMode == MyRelationsBetweenPlayerAndBlock.Enemies) && m_enemyAntennaRange < distance) { continue; } if (entityMarker.TargetMode == MyRelationsBetweenPlayerAndBlock.Owner && m_ownerAntennaRange < distance) { continue; } if (entityMarker.MustBeDirectlyVisible) { LineD raycast = new LineD(MySector.MainCamera.Position, (Vector3)entity.PositionComp.WorldVolume.Center); raycast.From += raycast.Direction; var result = MyEntities.GetIntersectionWithLine(ref raycast, entity, MySession.ControlledEntity as MyEntity); if (result.HasValue && !(result.Value.Entity == entity || result.Value.Entity.Parent == entity || result.Value.Entity == entity.Parent)) { continue; } } DrawLocationMarker( GetStyleForRelation(entityMarker.TargetMode), entity.LocationForHudMarker, entityMarker, 0, 0); } m_hudScreen.DrawTexts(); ProfilerShort.End(); }
public virtual void DrawLocationMarkers(MyHudLocationMarkers locationMarkers) { ProfilerShort.Begin("MyHudMarkerRender.DrawLocationMarkers"); m_sortedMarkers.Clear(); foreach (var entityMarker in locationMarkers.MarkerEntities) { if (entityMarker.Value.Entity.PositionComp == null) //to draw marker entity must have position { continue; } m_sortedMarkers.Add(entityMarker.Value); } m_sortedMarkers.Sort(m_distanceComparer); foreach (var entityMarker in m_sortedMarkers) { MyEntity entity = entityMarker.Entity as MyEntity; if (entityMarker.ShouldDraw != null && !entityMarker.ShouldDraw()) { continue; } if (entityMarker.MustBeDirectlyVisible) { LineD raycast = new LineD(MySector.MainCamera.Position, (Vector3)entity.PositionComp.WorldVolume.Center); raycast.From += raycast.Direction; var result = MyEntities.GetIntersectionWithLine(ref raycast, entity, MySession.Static.ControlledEntity as MyEntity); if (result.HasValue && !(result.Value.Entity == entity || result.Value.Entity.Parent == entity || result.Value.Entity == entity.Parent)) { continue; } } DrawLocationMarker( GetStyleForRelation(entityMarker.TargetMode), entity.LocationForHudMarker, entityMarker, 0, 0); } m_hudScreen.DrawTexts(); ProfilerShort.End(); }