public void UpdateHud(bool showMyself = false) { if ((!Game.IsDedicated && !MyHud.MinimalHud) && !MyHud.CutsceneHud) { this.Clear(); foreach (MyDataBroadcaster broadcaster in MyAntennaSystem.Static.GetAllRelayedBroadcasters(this, MySession.Static.LocalPlayerId, false, null)) { bool allowBlink = broadcaster.CanBeUsedByPlayer(MySession.Static.LocalPlayerId); MyCubeGrid topMostParent = broadcaster.Entity.GetTopMostParent(null) as MyCubeGrid; if (topMostParent != null) { MyGroups <MyCubeGrid, MyGridLogicalGroupData> .Group group = MyCubeGridGroups.Static.Logical.GetGroup(topMostParent); if (group != null) { MyGridLogicalGroupData groupData = group.GroupData; this.m_broadcastersInRange_TopGrids.Add(groupData); } } if (broadcaster.ShowOnHud) { foreach (MyHudEntityParams @params in broadcaster.GetHudParams(allowBlink)) { if (this.m_entitiesOnHud.Contains(@params.EntityId)) { continue; } this.m_entitiesOnHud.Add(@params.EntityId); if (@params.BlinkingTime > 0f) { MyHud.HackingMarkers.RegisterMarker(@params.EntityId, @params); continue; } if (!MyHud.HackingMarkers.MarkerEntities.ContainsKey(@params.EntityId)) { MyHud.LocationMarkers.RegisterMarker(@params.EntityId, @params); } } } } if (MySession.Static.AdminSettings.HasFlag(AdminSettingsEnum.ShowPlayers)) { using (IEnumerator <MyPlayer> enumerator3 = MySession.Static.Players.GetOnlinePlayers().GetEnumerator()) { while (enumerator3.MoveNext()) { MyCharacter character = enumerator3.Current.Character; if (character != null) { foreach (MyHudEntityParams params2 in character.GetHudParams(false)) { if (!this.m_entitiesOnHud.Contains(params2.EntityId)) { this.m_entitiesOnHud.Add(params2.EntityId); MyHud.LocationMarkers.RegisterMarker(params2.EntityId, params2); } } } } } } } }
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); } } } }