public void UpdateHud(bool showMyself = false)
        {
            if (MySandboxGame.IsDedicated || MyHud.MinimalHud)
            {
                return;
            }

            Clear();

            foreach (var broadcaster in m_relayedBroadcasters)
            {
                MyEntity entity = (MyEntity)broadcaster.Entity;
                if (entity != null)
                {
                    if (!showMyself && entity == Entity)
                    {
                        continue; //do not show myself
                    }
                    bool friendly = true;
                    if (broadcaster.Entity is IMyComponentOwner <MyIDModule> )
                    {
                        MyIDModule broadcasterId;
                        if ((broadcaster.Entity as IMyComponentOwner <MyIDModule>).GetComponent(out broadcasterId))
                        {
                            VRage.Game.MyRelationsBetweenPlayerAndBlock relation = broadcasterId.GetUserRelationToOwner(MySession.Static.LocalPlayerId);
                            if (relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies || relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Neutral)
                            {
                                friendly = false;
                            }
                        }
                    }

                    MyLaserAntenna la = broadcaster.Entity as MyLaserAntenna;
                    if (la != null && la.ShowOnHUD == false)
                    {
                        continue;
                    }

                    foreach (var hudParams in entity.GetHudParams(friendly))
                    {
                        MyEntity hudParamsEntity = hudParams.Entity as MyEntity;
                        if (!m_entitiesOnHud.Contains(hudParamsEntity))
                        {
                            m_entitiesOnHud.Add(hudParamsEntity);
                            if (hudParams.BlinkingTime > 0)
                            {
                                MyHud.HackingMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                            else
                            if (!MyHud.HackingMarkers.MarkerEntities.ContainsKey(hudParamsEntity))
                            {
                                MyHud.LocationMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void UpdateHud(bool showMyself = false)
        {
            if (MySandboxGame.IsDedicated || MyHud.MinimalHud || MyHud.CutsceneHud)
            {
                return;
            }

            Clear();

            foreach (var broadcaster in m_relayedBroadcasters)
            {
                MyEntity entity = (MyEntity)broadcaster.Entity;
                if (entity != null)
                {
                    //Also ignore entity if it is preview entity or else it will update hud
                    if (entity.GetTopMostParent() is MyCubeGrid && entity.GetTopMostParent().IsPreview)
                    {
                        continue;
                    }

                    if (!showMyself && entity == Entity)
                    {
                        continue; //do not show myself
                    }
                    bool friendly = true;
                    if (broadcaster.Entity is IMyComponentOwner <MyIDModule> )
                    {
                        MyIDModule broadcasterId;
                        if ((broadcaster.Entity as IMyComponentOwner <MyIDModule>).GetComponent(out broadcasterId))
                        {
                            VRage.Game.MyRelationsBetweenPlayerAndBlock relation = broadcasterId.GetUserRelationToOwner(MySession.Static.LocalPlayerId);
                            if (relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Enemies || relation == VRage.Game.MyRelationsBetweenPlayerAndBlock.Neutral)
                            {
                                friendly = false;
                            }
                        }
                    }

                    MyLaserAntenna la = broadcaster.Entity as MyLaserAntenna;
                    if (la != null && la.ShowOnHUD == false)
                    {
                        continue;
                    }

                    foreach (var hudParams in entity.GetHudParams(friendly))
                    {
                        MyEntity hudParamsEntity = hudParams.Entity as MyEntity;
                        if (!m_entitiesOnHud.Contains(hudParamsEntity))
                        {
                            m_entitiesOnHud.Add(hudParamsEntity);
                            if (hudParams.BlinkingTime > 0)
                            {
                                MyHud.HackingMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                            else
                            if (!MyHud.HackingMarkers.MarkerEntities.ContainsKey(hudParamsEntity))
                            {
                                MyHud.LocationMarkers.RegisterMarker(hudParamsEntity, hudParams);
                            }
                        }
                    }
                }
            }

            //manually draw markers for players that are out of range or have broadcasting turned off
            if (MySession.Static.AdminSettings.HasFlag(AdminSettingsEnum.ShowPlayers))
            {
                foreach (var player in MySession.Static.Players.GetOnlinePlayers())
                {
                    MyCharacter character = player.Character;
                    if (character == null)
                    {
                        continue;
                    }

                    var hudParams = character.GetHudParams(false);
                    foreach (var param in hudParams)
                    {
                        MyEntity hudEntity = (MyEntity)param.Entity;
                        if (m_entitiesOnHud.Contains(hudEntity))
                        {
                            continue;
                        }

                        m_entitiesOnHud.Add(hudEntity);

                        MyHud.LocationMarkers.RegisterMarker(hudEntity, param);
                    }
                }
            }
        }