///<summary>Set list of phones to display. Get/Set accessor won't work here because we require 2 seperate fields in order to update the control properly.</summary> public void SetPhoneList(List <PhoneEmpDefault> peds, List <Phone> phones) { //create a new list so our sorting doesn't affect this list elsewhere _listPhones = new List <Phone>(); _listMapAreas = MapAreas.Refresh(); if (_listRooms == null) { UpdateComboRooms(); //Only call this once from here otherwise it gets called too often and causes strange flickering. } if (_mapAreaContainerNum < 1) { _listPhones.AddRange(phones); } else //A specific room was selected so we only want to show those extensions. //Find all the map areas that correspond to the selected map area container. { List <MapArea> listMapAreas = _listMapAreas.FindAll(x => x.MapAreaContainerNum == _mapAreaContainerNum); //Get all phones that correspond to the map areas found. _listPhones = phones.FindAll(x => listMapAreas.Exists(y => y.Extension == x.Extension)); } //We always want to sort the list of phones so that they display in a predictable fashion. _listPhones.Sort(new Phones.PhoneComparer(Phones.PhoneComparer.SortBy.ext)); _listPhoneEmpDefaults = peds; Invalidate(); }
private void FillMap() { mapAreaPanel.Clear(false); //fill the panel List <MapArea> clinicMapItems = MapAreas.Refresh(); for (int i = 0; i < clinicMapItems.Count; i++) { if (clinicMapItems[i].MapAreaContainerNum != _mapCur.MapAreaContainerNum) { continue; } if (clinicMapItems[i].ItemType == MapItemType.Room) { mapAreaPanel.AddCubicle(clinicMapItems[i], false); } else if (clinicMapItems[i].ItemType == MapItemType.DisplayLabel) { mapAreaPanel.AddDisplayLabel(clinicMapItems[i]); } } mapAreaPanel.ShowGrid = _mapCur.ShowGrid; mapAreaPanel.ShowOutline = _mapCur.ShowOutline; mapAreaPanel.FloorWidthFeet = (int)_mapCur.FloorWidthFeet; mapAreaPanel.FloorHeightFeet = (int)_mapCur.FloorHeightFeet; mapAreaPanel.PixelsPerFoot = (int)_mapCur.PixelsPerFoot; textDescription.Text = _mapCur.Description; }
public void Update(RawMasterInfo rpInfo) { Ships.UpdateRawData(rpInfo.Ships, r => new ShipInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); ShipTypes.UpdateRawData(rpInfo.ShipTypes, r => new ShipTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); Equipment.UpdateRawData(rpInfo.Equipment, r => new EquipmentInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); EquipmentTypes.UpdateRawData(rpInfo.EquipmentTypes, r => new EquipmentTypeInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); Items.UpdateRawData(rpInfo.Items, r => new ItemInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); MapAreas.UpdateRawData(rpInfo.MapAreas, r => new MapAreaInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); Maps.UpdateRawData(rpInfo.Maps, r => new MapMasterInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); Expeditions.UpdateRawData(rpInfo.Expeditions, r => new ExpeditionInfo(r), (rpData, rpRawData) => rpData.Update(rpRawData)); EventMapCount = (from rArea in MapAreas.Values where rArea.IsEventArea join rMap in Maps.Values on rArea.ID equals rMap.AreaID select rMap).Count(); if (r_InitializationLock != null) { r_InitializationLock.Set(); r_InitializationLock.Dispose(); r_InitializationLock = null; } }
///<summary>Setup the map panel with the cubicles and labels before filling with real-time data. Call this on load or anytime the cubicle layout has changed.</summary> private void FillMapAreaPanel() { mapAreaPanelHQ.Controls.Clear(); mapAreaPanelHQ.FloorHeightFeet = Math.Max(_mapCur.FloorHeightFeet, 55); //Should at least fill the space set in the designer. mapAreaPanelHQ.FloorWidthFeet = Math.Max(_mapCur.FloorWidthFeet, 89); //Should at least fill the space set in the designer. //fill the panel List <MapArea> clinicMapItems = MapAreas.Refresh(_listMaps[comboRoom.SelectedIndex].MapAreaContainerNum); clinicMapItems = clinicMapItems.OrderByDescending(x => (int)(x.ItemType)).ToList(); for (int i = 0; i < clinicMapItems.Count; i++) { if (clinicMapItems[i].MapAreaContainerNum != _listMaps[comboRoom.SelectedIndex].MapAreaContainerNum) { continue; } if (clinicMapItems[i].ItemType == MapItemType.Room) { mapAreaPanelHQ.AddCubicle(clinicMapItems[i]); } else if (clinicMapItems[i].ItemType == MapItemType.DisplayLabel) { mapAreaPanelHQ.AddDisplayLabel(clinicMapItems[i]); } } }
///<summary>Handle the Cubicle.DragDone event</summary> void mapAreaControl_DragDone(object sender, EventArgs e) { if (sender == null) { return; } Control asControl = null; MapArea clinicMapItem = null; if (sender is MapAreaRoomControl) { asControl = (Control)sender; clinicMapItem = ((MapAreaRoomControl)sender).MapAreaItem; } else if (sender is MapAreaDisplayLabelControl) { asControl = (Control)sender; clinicMapItem = ((MapAreaDisplayLabelControl)sender).MapAreaItem; } else { return; } //recalculate XPos and YPos based on new location in the panel PointF xy = ConvertScreenLocationToXY(asControl.Location, PixelsPerFoot); clinicMapItem.XPos = Math.Round(xy.X, 3); clinicMapItem.YPos = Math.Round(xy.Y, 3); //save new cubicle location to db MapAreas.Update(clinicMapItem); //alert the parent mapAreaControl_Changed(sender, new EventArgs()); }
private void butOK_Click(object sender, EventArgs e) { try { if (PIn.Double(textBoxXPos.Text) < 0) { textBoxXPos.Focus(); MessageBox.Show(Lan.g(this, "Invalid XPos")); return; } if (PIn.Double(textBoxYPos.Text) < 0) { textBoxYPos.Focus(); MessageBox.Show(Lan.g(this, "Invalid YPos")); return; } if (PIn.Double(textBoxWidthFeet.Text) <= 0) { textBoxWidthFeet.Focus(); MessageBox.Show(Lan.g(this, "Invalid Width")); return; } if (PIn.Double(textBoxHeightFeet.Text) <= 0) { textBoxHeightFeet.Focus(); MessageBox.Show(Lan.g(this, "Invalid Height")); return; } if (PIn.Int(textBoxExtension.Text) < 0) { textBoxExtension.Focus(); MessageBox.Show(Lan.g(this, "Invalid Extension")); return; } if (MapItem.ItemType == MapItemType.DisplayLabel && PIn.String(textBoxDescription.Text) == "") { textBoxDescription.Focus(); MessageBox.Show(Lan.g(this, "Invalid Text")); return; } MapItem.Extension = PIn.Int(textBoxExtension.Text); MapItem.XPos = PIn.Double(textBoxXPos.Text); MapItem.YPos = PIn.Double(textBoxYPos.Text); MapItem.Width = PIn.Double(textBoxWidthFeet.Text); MapItem.Height = PIn.Double(textBoxHeightFeet.Text); MapItem.Description = PIn.String(textBoxDescription.Text); if (MapItem.IsNew) { MapAreas.Insert(MapItem); } else { MapAreas.Update(MapItem); } DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void ZoomToAreas() { // Calculate full extent of all areas. Envelope fullExtent = GeometryEngine.CombineExtents(MapAreas.Select(area => area.MapArea.AreaOfInterest)); // Zoom to the areas with a buffer. await _mapViewService.SetViewpointGeometryAsync(fullExtent, 20); }
private static MapAreasState DeserializeMapAreasState(BinaryReader Reader, MapAreas areas) { MapAreasState state = new MapAreasState(areas); for (int i = 0; i < areas.Areas.Count; i++) { state.Areas[i] = DeserializeMapAreaState(Reader, areas.Areas[i]); } return(state); }
private async void QueryMapAreas() { try { // Clear existing overlays _mapViewService.ClearOverlays(); // Clear existing areas (in case user wants to refresh results) MapAreas.Clear(); // Create new task to var offlineMapTask = await OfflineMapTask.CreateAsync(Map); // Get list of areas IReadOnlyList <PreplannedMapArea> preplannedMapAreas = await offlineMapTask.GetPreplannedMapAreasAsync(); // Create UI from the areas foreach (var preplannedMapArea in preplannedMapAreas.OrderBy(x => x.PortalItem.Title)) { // Load area to get the metadata await preplannedMapArea.LoadAsync(); // Using a custom model for easier visualization var model = new MapAreaModel(preplannedMapArea); MapAreas.Add(model); // Graphic that shows the area in the map var graphic = new Graphic(preplannedMapArea.AreaOfInterest, GetSymbolForColor(model.DisplayColor)); graphic.Attributes.Add("Name", preplannedMapArea.PortalItem.Title); _areasOverlay.Graphics.Add(graphic); } if (!preplannedMapAreas.Any()) { await _windowService.ShowAlertAsync("No preplanned map areas available."); } else { // Show the overlays on the map _mapViewService.AddGraphicsOverlay(_areasOverlay); // Zoom to the offline areas await _mapViewService.SetViewpointGeometryAsync(_areasOverlay.Extent, 20); } // Refresh commands RefreshCommands(); } catch (Exception ex) { await _windowService.ShowAlertAsync(ex.Message, "Couldn't query map areas"); } }
private void butDelete_Click(object sender, EventArgs e) { if (MapItem.IsNew) { DialogResult = System.Windows.Forms.DialogResult.Cancel; return; } if (!MsgBox.Show(this, true, "Remove Map Area?")) { return; } MapAreas.Delete(MapItem.MapAreaNum); DialogResult = System.Windows.Forms.DialogResult.OK; }
///<summary>Clear the form. Optionally delete the records from the database. Use this option sparingly (if ever).</summary> public void Clear(bool deleteFromDatabase) { if (deleteFromDatabase) { for (int i = 0; i < this.Controls.Count; i++) { if (!(this.Controls[i] is MapAreaRoomControl)) { return; } MapAreas.Delete(((MapAreaRoomControl)this.Controls[i]).MapAreaItem.MapAreaNum); } } this.Controls.Clear(); }
private void butBuildFromPhoneTable_Click(object sender, EventArgs e) { if (MessageBox.Show("This action will clear all information from clinicmapitem table and recreated it from current phone table rows. Would you like to continue?", "", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) { return; } mapAreaPanel.Clear(true); List <Phone> phones = Phones.GetPhoneList(); int defaultSizeFeet = 6; int row = 1; int column = 0; for (int i = 0; i < 78; i++) { if (row >= 7) { if (++column > 8) { column = 3; row++; } } else { if (++column > 10) { column = 1; row++; } if (row == 7) { column = 3; //row=8; } } //Phone phone=phones[i]; MapArea clinicMapItem = new MapArea(); clinicMapItem.Description = ""; clinicMapItem.Extension = i; //phone.Extension; clinicMapItem.Width = defaultSizeFeet; clinicMapItem.Height = defaultSizeFeet; clinicMapItem.XPos = (1 * column) + ((column - 1) * defaultSizeFeet); clinicMapItem.YPos = 1 + ((row - 1) * defaultSizeFeet); mapAreaPanel.AddCubicle(clinicMapItem); MapAreas.Insert(clinicMapItem); } }
///<summary>Setup the map panel with the cubicles and labels before filling with real-time data. Call this on load or anytime the cubicle layout has changed.</summary> private void FillMapAreaPanel() { mapAreaPanelHQ.Controls.Clear(); //fill the panel List <MapArea> clinicMapItems = MapAreas.Refresh(); for (int i = 0; i < clinicMapItems.Count; i++) { if (clinicMapItems[i].ItemType == MapItemType.Room) { mapAreaPanelHQ.AddCubicle(clinicMapItems[i]); } else if (clinicMapItems[i].ItemType == MapItemType.DisplayLabel) { mapAreaPanelHQ.AddDisplayLabel(clinicMapItems[i]); } } }
private void mapAreaPanel_MapAreaChanged(object sender, EventArgs e) { mapAreaPanel.Clear(false); //All prefs are hard-coded for now. We will likely create a parent table which will hold these values in the event that we release this feature to customers. /* * //Load clinic panel values from database. * bool showGrid=false; * if(bool.TryParse(PrefC.GetRaw("clinicMapPanelHQ.ShowGrid"),out showGrid)) { * checkShowGrid.Checked=showGrid; * } * bool showOutline=false; * if(bool.TryParse(PrefC.GetRaw("clinicMapPanelHQ.ShowOutline"),out showOutline)) { * checkShowOutline.Checked=showOutline; * } * int floorWidthFeet=0; * if(int.TryParse(PrefC.GetRaw("clinicMapPanelHQ.FloorWidthFeet"),out floorWidthFeet)) { * numFloorWidthFeet.Value=floorWidthFeet; * } * int floorHeightFeet=0; * if(int.TryParse(PrefC.GetRaw("clinicMapPanelHQ.FloorHeightFeet"),out floorHeightFeet)) { * numFloorHeightFeet.Value=floorHeightFeet; * } * int pixelsPerFoot=0; * if(int.TryParse(PrefC.GetRaw("clinicMapPanelHQ.PixelsPerFoot"),out pixelsPerFoot)) { * numPixelsPerFoot.Value=pixelsPerFoot; * } */ //fill the panel List <MapArea> clinicMapItems = MapAreas.Refresh(); for (int i = 0; i < clinicMapItems.Count; i++) { if (clinicMapItems[i].ItemType == MapItemType.Room) { mapAreaPanel.AddCubicle(clinicMapItems[i]); } else if (clinicMapItems[i].ItemType == MapItemType.DisplayLabel) { mapAreaPanel.AddDisplayLabel(clinicMapItems[i]); } } }
public static void SerializeMapAreas(BinaryWriter Writer, MapAreas MapAreas) { SerializeLength(Writer, MapAreas.Areas); List <MapAreaTransitionPoint> transitionPoints = new List <MapAreaTransitionPoint>(); foreach (MapArea area in MapAreas.Areas) { if (area.TransitionPoints != null) { transitionPoints.AddRange(area.TransitionPoints); } SerializeMapArea(Writer, area); } SerializeLength(Writer, transitionPoints); if (transitionPoints != null) { foreach (MapAreaTransitionPoint transitionPoint in transitionPoints) { SerializeMapAreaTransitionPoint(Writer, transitionPoint); } } }
private static MapAreas DeserializeMapAreas(BinaryReader Reader) { int areasLength = DeserializeLength(Reader); MapAreas areas = new MapAreas(); Dictionary <Guid, MapArea> areasDict = new Dictionary <Guid, MapArea>(); for (int i = 0; i < areasLength; i++) { MapArea area = DeserializeMapObject(Reader) as MapArea; areas.Areas.Add(area); areasDict[area.Id] = area; } int transitionPointsLength = DeserializeLength(Reader); for (int i = 0; i < transitionPointsLength; i++) { MapAreaTransitionPoint transitionPoint = DeserializeMapObject(Reader, null, areasDict) as MapAreaTransitionPoint; transitionPoint.From.TransitionPoints.Add(transitionPoint); } return(areas); }
///<summary>Setup the map panel with the cubicles and labels before filling with real-time data. Call this on load or anytime the cubicle layout has changed.</summary> private void FillMapAreaPanel() { mapAreaPanelHQ.Controls.Clear(); mapAreaPanelHQ.FloorHeightFeet = _mapCur.FloorHeightFeet; mapAreaPanelHQ.FloorWidthFeet = _mapCur.FloorWidthFeet; //fill the panel List <MapArea> clinicMapItems = MapAreas.Refresh(); for (int i = 0; i < clinicMapItems.Count; i++) { if (clinicMapItems[i].MapAreaContainerNum != _listMaps[comboRoom.SelectedIndex].MapAreaContainerNum) { continue; } if (clinicMapItems[i].ItemType == MapItemType.Room) { mapAreaPanelHQ.AddCubicle(clinicMapItems[i]); } else if (clinicMapItems[i].ItemType == MapItemType.DisplayLabel) { mapAreaPanelHQ.AddDisplayLabel(clinicMapItems[i]); } } }
private static MapAreasState DeserializeMapAreasState(BinaryReader Reader, MapAreas areas) { MapAreasState state = new MapAreasState(areas); for (int i = 0; i < areas.Areas.Count; i++) { state.Areas[i] = DeserializeMapAreaState(Reader, areas.Areas[i]); } return state; }
public static void PathTest() { GameMap game; Map map; Random rand = new Random(); try { MapImage image = new MapImage(MapImageType.Bmp, null); MapPlace place = new MapPlace(image, (float)0.8) { Name = "1" }; //MapWall destroyedWall = new MapWall("2", image, MapDirection.North, 200); MapWall wall = new MapWall(image, MapDirection.North, 200) { Name = "3" }; Dictionary <MapDirection, MapWall> walls = new Dictionary <MapDirection, MapWall>(); map = new Map(1, new MapSize(16, 16)) { Name = "Map" }; for (int z = 0; z < map.LevelsCount; z++) { for (int x = 0; x < map.Size.Width; x++) { for (int y = 0; y < map.Size.Height; y++) { map.Levels[z].Cells[x, y] = new MapCell(place, null); } } } MapAreas areas = new MapAreas(); // MapAreaTransitionPoint pnt1=new MapAreaTransitionPoint("", "", areas.Areas.Add(new MapArea(new MapPoint(0, 0, 0), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 4, 0), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 8, 0), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 12, 0), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 0, 4), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 4, 4), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 8, 4), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 12, 4), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 0, 8), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 4, 8), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 8, 8), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 12, 8), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 0, 12), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 4, 12), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 8, 12), new MapSize(4, 4))); areas.Areas.Add(new MapArea(new MapPoint(0, 12, 12), new MapSize(4, 4))); MapAreaTransitionPoint[] tr0 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[0], areas.Areas[1], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[0], areas.Areas[5], new MapPoint(0, 1, 1), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr1 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[1], areas.Areas[0], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr5 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[5], areas.Areas[0], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[5], areas.Areas[2], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr2 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[2], areas.Areas[5], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[2], areas.Areas[7], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr3 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[3], areas.Areas[6], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr4 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[4], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr6 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[6], areas.Areas[3], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[6], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr7 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[7], areas.Areas[2], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[7], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr8 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[4], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[9], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[8], areas.Areas[12], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr13 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[9], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[14], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[13], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr9 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[9], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[9], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr12 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[12], areas.Areas[8], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr14 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[14], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr15 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[15], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr11 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[11], areas.Areas[10], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; MapAreaTransitionPoint[] tr10 = new MapAreaTransitionPoint[] { new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[6], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[7], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[11], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[15], new MapPoint(0, 0, 0), new MapSize(1, 1)), new MapAreaTransitionPoint(areas.Areas[10], areas.Areas[13], new MapPoint(0, 0, 0), new MapSize(1, 1)) }; areas.Areas[0].TransitionPoints.AddRange(tr0); areas.Areas[1].TransitionPoints.AddRange(tr1); areas.Areas[2].TransitionPoints.AddRange(tr2); areas.Areas[3].TransitionPoints.AddRange(tr3); areas.Areas[4].TransitionPoints.AddRange(tr4); areas.Areas[5].TransitionPoints.AddRange(tr5); areas.Areas[6].TransitionPoints.AddRange(tr6); areas.Areas[7].TransitionPoints.AddRange(tr7); areas.Areas[8].TransitionPoints.AddRange(tr8); areas.Areas[9].TransitionPoints.AddRange(tr9); areas.Areas[10].TransitionPoints.AddRange(tr10); areas.Areas[11].TransitionPoints.AddRange(tr11); areas.Areas[12].TransitionPoints.AddRange(tr12); areas.Areas[13].TransitionPoints.AddRange(tr13); areas.Areas[14].TransitionPoints.AddRange(tr14); areas.Areas[15].TransitionPoints.AddRange(tr15); map.Areas = areas; MapState state = new MapState(map); game = new GameMap(new MapState(map)); } catch { } Int64 memory = GC.GetTotalMemory(false); map = null; game = null; GC.Collect(); }
public static void SerializeMapAreas(BinaryWriter Writer, MapAreas MapAreas) { SerializeLength(Writer, MapAreas.Areas); List<MapAreaTransitionPoint> transitionPoints = new List<MapAreaTransitionPoint>(); foreach (MapArea area in MapAreas.Areas) { if (area.TransitionPoints != null) transitionPoints.AddRange(area.TransitionPoints); SerializeMapArea(Writer, area); } SerializeLength(Writer, transitionPoints); if (transitionPoints != null) { foreach (MapAreaTransitionPoint transitionPoint in transitionPoints) SerializeMapAreaTransitionPoint(Writer, transitionPoint); } }
private static MapAreas DeserializeMapAreas(BinaryReader Reader) { int areasLength = DeserializeLength(Reader); MapAreas areas = new MapAreas(); Dictionary<Guid, MapArea> areasDict = new Dictionary<Guid, MapArea>(); for (int i = 0; i < areasLength; i++) { MapArea area = DeserializeMapObject(Reader) as MapArea; areas.Areas.Add(area); areasDict[area.Id] = area; } int transitionPointsLength = DeserializeLength(Reader); for (int i = 0; i < transitionPointsLength; i++) { MapAreaTransitionPoint transitionPoint = DeserializeMapObject(Reader, null, areasDict) as MapAreaTransitionPoint; transitionPoint.From.TransitionPoints.Add(transitionPoint); } return areas; }
private void InitializeGeneric() { SpaceAreas = new MapAreas(this, TileType.Nothing); }
/// <summary> /// Initializes a new instance of the <see cref="WorldLOD"/> class. /// </summary> /// <param name="inData">The input data.</param> public WorldLOD(byte[] inData) { using (var ms = new MemoryStream(inData)) { using (var br = new BinaryReader(ms)) { // Set up the two area lists with default values for (var i = 0; i < 4096; ++i) { MapAreas.Add(null); MapAreaHoles.Add(null); } Version = br.ReadIFFChunk <TerrainVersion>(); if (br.PeekChunkSignature() == TerrainWorldModelObjects.Signature) { WorldModelObjects = br.ReadIFFChunk <TerrainWorldModelObjects>(); } if (br.PeekChunkSignature() == TerrainWorldModelObjectIndices.Signature) { WorldModelObjectIndices = br.ReadIFFChunk <TerrainWorldModelObjectIndices>(); } if (br.PeekChunkSignature() == TerrainWorldModelObjectPlacementInfo.Signature) { WorldModelObjectPlacementInfo = br.ReadIFFChunk <TerrainWorldModelObjectPlacementInfo>(); } MapAreaOffsets = br.ReadIFFChunk <WorldLODMapAreaOffsets>(); // Read the map areas and their holes for (var y = 0; y < 64; ++y) { for (var x = 0; x < 64; ++x) { var mapAreaOffsetIndex = (y * 64) + x; var mapAreaOffset = MapAreaOffsets.MapAreaOffsets[mapAreaOffsetIndex]; if (mapAreaOffset > 0) { br.BaseStream.Position = mapAreaOffset; MapAreas[mapAreaOffsetIndex] = br.ReadIFFChunk <WorldLODMapArea>(); if (br.PeekChunkSignature() == WorldLODMapAreaHoles.Signature) { MapAreaHoles[mapAreaOffsetIndex] = br.ReadIFFChunk <WorldLODMapAreaHoles>(); } else { MapAreaHoles[mapAreaOffsetIndex] = WorldLODMapAreaHoles.CreateEmpty(); } } else { MapAreas[mapAreaOffsetIndex] = null; MapAreaHoles[mapAreaOffsetIndex] = null; } } } } } }