protected void AddEntity(IMyEntity RadarEntity, Vector3D?Hit) { Ingame.MyDetectedEntityInfo RadarInfo = MyDetectedEntityInfoHelper.Create(RadarEntity as MyEntity, RadarBlock.OwnerId, Hit); bool AddMarker = DetectedEntities.Add(RadarInfo) & MarkerModule.ShouldMarkerExist(RadarInfo); if (!AddMarker || MarkerModule.RadarMarkers.ContainsKey(RadarInfo.EntityId)) { return; } IMyVoxelMap voxel; if (RadarEntity is IMyCubeGrid) { string GridName = (RadarEntity as IMyCubeGrid).CustomName; MarkerModule.AddGPSMarker(RadarInfo.Rename(GridName), GridName); } else if (RadarEntity.IsOfType(out voxel)) { string VoxelName = (!voxel.StorageName.StartsWith("Asteroid_") ? voxel.StorageName : "Asteroid"); MarkerModule.AddGPSMarker(RadarInfo, VoxelName); } else { MarkerModule.AddGPSMarker(RadarInfo, RadarEntity.DisplayName); } }
void OnMarkForClose(IMyEntity Entity) { try { RadarCore.SaveUnregister(PersistenceModule.Save); MarkerModule.RemoveGPSMarkers(true); RadarBlock.AppendingCustomInfo -= RadarBlock_AppendingCustomInfo; RadarBlock.OnMarkForClose -= OnMarkForClose; } catch { } }
public DialogImportMarkers() { InitializeComponent(); PreviewMap.VisibilityManager = _visibilityManager; // Load saved markers file var openFileDialog = new OpenFileDialog() { AddExtension = true, DefaultExt = "txt", FileName = "MarkerExport.txt" }; if (openFileDialog.ShowDialog() == true) { using (var sw = new StreamReader(openFileDialog.FileName)) using (var writer = new JsonTextReader(sw)) { MarkerModule.DeserializeMarkers(writer); } } var xList = MarkerModule.markers.Values.GroupBy(x => x.channel).Select(grp => grp.ToList()).ToList(); xList.ForEach(x => { if (x.Count == 0) { return; } var channel = (MarkerChannel)x.First().channel; MarkerList.Add(new CheckableMarkerListItem { Value = channel.ToString(), Children = new ObservableCollection <CheckableMarkerListItem>(x.Select(y => { var item = new CheckableMarkerListItem { Marker = y, Value = $"{y.text} ({y.id})" }; item.PropertyChanged += MarkerItemChanged; return(item); })) }); }); }
public UIMarkerSlot(MarkerModule module, int index) { this.module = module; this.index = index; PreviewItem = new Item(); if (((FilteredItemsMode)module.Mode).whitelist[index] > 0) { PreviewItem.SetDefaults(((FilteredItemsMode)module.Mode).whitelist[index]); } Width.Pixels = Height.Pixels = SlotSize; }
public override void UpdateBeforeSimulation10() { try { scanx++; if (scanx == 6) { scanx = 0; MarkerModule.RemoveGPSMarkers(); DetectedEntities.Clear(); if (RadarBlock.CubeGrid.Physics == null) { return; } //System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); //watch.Start(); PowerModule.MyRadarPowerSink.Update(); if (IsWorking()) { OwnerPlayer = GetOwnerPlayer(); FindOwnerInRelayNetwork(); CalculateTotalPower(); RadarBlock.RefreshCustomInfo(); PerformScan(); } else { HasOwnerInRelay = false; //if (RadarCore.Debug) TestNote.Hide(); } //watch.Stop(); //MyAPIGateway.Utilities.ShowMessage(RadarBlock.CustomName, $"Scan took {(Math.Round(watch.ElapsedTicks * 1000f / System.Diagnostics.Stopwatch.Frequency, 2))}"); } } catch (Exception Scrap) { RadarCore.LogError(RadarBlock.CustomName, Scrap); } }