Пример #1
0
        public override 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;

                double distance = (entity.WorldMatrix.Translation - MyHudMarkerRender.ActiveWorldMatrix.Translation).LengthSquared();

                // Do not show entities if entity is beyond the limit set by the info tab sliders
                switch (entityMarker.TargetMode)
                {
                    case MyRelationsBetweenPlayerAndBlock.Owner:
                        if (distance > (m_ownerAntennaRange * m_ownerAntennaRange))
                            continue;
                        break;
                    case MyRelationsBetweenPlayerAndBlock.NoOwnership:
                    case MyRelationsBetweenPlayerAndBlock.FactionShare:
                        if (distance > (m_friendAntennaRange * m_friendAntennaRange))
                            continue;
                        break;
                    case MyRelationsBetweenPlayerAndBlock.Neutral:
                    case MyRelationsBetweenPlayerAndBlock.Enemies:
                        if (distance > (m_enemyAntennaRange * m_enemyAntennaRange))
                            continue;
                        break;
                }

                AddEntity(entity, entityMarker.TargetMode, entityMarker.Text);
            }

            m_hudScreen.DrawTexts();

            ProfilerShort.End();
        }