public HexSectorSelector(ResourceManager resourceManager, Sector sector, Hex coords, int jump) { if (resourceManager == null) throw new ArgumentNullException("resourceManager"); if (sector == null) throw new ArgumentNullException("sector"); this.sector = sector; this.resourceManager = resourceManager; this.coords = coords; this.jump = jump; }
public HexSectorSelector(ResourceManager resourceManager, Sector sector, Point coords, int jump) { if (resourceManager == null) throw new ArgumentNullException("resourceManager"); if (sector == null) throw new ArgumentNullException("sector"); m_sector = sector; m_resourceManager = resourceManager; m_coords = coords; m_jump = jump; }
public void Resolve(SectorMap sectorMap, ResourceManager resourceManager, out Sector sector, out World world) { if (sectorMap == null) throw new ArgumentNullException("sectorMap"); sector = null; world = null; sector = sectorMap.FromLocation(Sector.X, Sector.Y); if (sector == null) return; WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: true); if (worlds != null) world = worlds[World.X, World.Y]; }
public WorldLocation(Sector sector, World world) { if (sector == null) throw new ArgumentNullException("sector"); if (world == null) throw new ArgumentNullException("world"); Sector = sector.Location; World = world.Location; }
public void Resolve(SectorMap sectorMap, out Sector sector, out Subsector subsector) { if (sectorMap == null) throw new ArgumentNullException("sectorMap"); sector = null; subsector = null; sector = sectorMap.FromLocation(SectorLocation.X, SectorLocation.Y); if (sector != null) subsector = sector[Index]; }
public SubsectorLocation(Sector sector, Subsector subsector) { if (sector == null) throw new ArgumentNullException("sector"); if (subsector == null) throw new ArgumentNullException("subsector"); SectorLocation = sector.Location; Index = subsector.Index[0]; }
public SectorLocation(Sector sector) { if (sector == null) throw new ArgumentNullException("sector"); SectorCoords = sector.Location; }
public void Merge(Sector metadataSource) { if (metadataSource == null) throw new ArgumentNullException("metadataSource"); // TODO: This is very fragile; if a new type is added to Sector we need to add more code here. if (metadataSource.Names.Any()) { Names.Clear(); Names.AddRange(metadataSource.Names); } if (metadataSource.DataFile != null && DataFile != null && (metadataSource.DataFile.FileName != DataFile.FileName || metadataSource.DataFile.Type != DataFile.Type)) { throw new Exception(string.Format("Mismatching DataFile entries for {0}", this.Names[0].Text)); } if (metadataSource.DataFile != null) DataFile = metadataSource.DataFile; Subsectors.AddRange(metadataSource.Subsectors); Allegiances.AddRange(metadataSource.Allegiances); Borders.AddRange(metadataSource.Borders); Routes.AddRange(metadataSource.Routes); Labels.AddRange(metadataSource.Labels); Credits = metadataSource.Credits; Products.AddRange(metadataSource.Products); StylesheetText = metadataSource.StylesheetText; }
internal BorderPath ComputeGraphicsPath(Sector sector, PathUtil.PathType type) { lock (this) { if (borderPathsCache[(int)type] == null) borderPathsCache[(int)type] = new BorderPath(this, sector, type); } return borderPathsCache[(int)type]; }
public string GetLabel(Sector sector) { if (!ShowLabel) return null; if (!string.IsNullOrEmpty(Label)) return Label; Allegiance alleg = sector.GetAllegianceFromCode(Allegiance); if (alleg == null) return null; return alleg.Name; }
public ClipPath(Sector sector, PathUtil.PathType borderPathType) { float[] edgex, edgey; RenderUtil.HexEdges(borderPathType, out edgex, out edgey); IEnumerable<Hex> hexes = Util.Sequence(1, Astrometrics.SectorWidth).Select(x => new Hex((byte)x, 1)) .Concat(Util.Sequence(2, Astrometrics.SectorHeight).Select(y => new Hex(Astrometrics.SectorWidth, (byte)y))) .Concat(Util.Sequence(Astrometrics.SectorWidth - 1, 1).Select(x => new Hex((byte)x, Astrometrics.SectorHeight))) .Concat(Util.Sequence(Astrometrics.SectorHeight - 1, 1).Select(y => new Hex(1, (byte)y))); Rectangle bounds = sector.Bounds; IEnumerable<Point> points = (from hex in hexes select new Point(hex.X + bounds.X, hex.Y + bounds.Y)).ToList(); PathUtil.ComputeBorderPath(points, edgex, edgey, out clipPathPoints, out clipPathPointTypes); PointF min = clipPathPoints[0]; PointF max = clipPathPoints[0]; for (int i = 1; i < clipPathPoints.Length; ++i) { PointF pt = clipPathPoints[i]; if (pt.X < min.X) min.X = pt.X; if (pt.Y < min.Y) min.Y = pt.Y; if (pt.X > max.X) max.X = pt.X; if (pt.Y > max.Y) max.Y = pt.Y; } this.bounds = new RectangleF(min, new SizeF(max.X - min.X, max.Y - min.Y)); }
public QuadrantSelector(ResourceManager resourceManager, Sector sector, int index) { if (resourceManager == null) throw new ArgumentNullException("resourceManager"); if (sector == null) throw new ArgumentNullException("sector"); if (index < 0 || index >= 4) throw new ArgumentOutOfRangeException("index", "index must be 0...3"); this.sector = sector; this.index = index; this.resourceManager = resourceManager; }
public void MSECWriterTest() { Sector sector = new Sector(); sector.Names.Add(new Name("Sector Name")); sector.Allegiances.Add(new Allegiance("X7", "Seven Evil Exes")); sector.Borders.Add(new Border("0001 0002 0003 0004")); sector.Borders.Add(new Border("0000 0001 0002 0003 0004 0005 0006", "blue")); sector.Routes.Add(new Route(start: 0101, end: 0202)); sector.Routes.Add(new Route(new Point(-1, -1), 3240, new Point(1, 1), 0101, "red")); sector.Labels.Add(new Label(0123, "Your text here")); StringWriter writer = new StringWriter(); MSECSerializer msec = new MSECSerializer(); msec.Serialize(writer, sector); string expected = String.Join("\r\n", new string[] { "# Generated by http://www.travellermap.com", "# <DATETIME>", "", "sector Sector Name", "", "", "# Other", "#", "border 0001 0002 0003 0004 red", "border 0000 0001 0002 0003 0004 0005 0006 blue", "label 0123 Your text here", "", "# Third Imperium", "#", "route -1 -1 3240 1 1 0101 red", "route 0101 0202 green", "", "# Seven Evil Exes", "#", "ally X7 Seven Evil Exes", "" }); string actual = writer.ToString(); actual = Regex.Replace(actual, @"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\S+", "<DATETIME>"); Assert.AreEqual(expected, actual); }
public SectorSelector(ResourceManager resourceManager, Sector sector) { if (resourceManager == null) throw new ArgumentNullException("resourceManager"); if (sector == null) throw new ArgumentNullException("sector"); m_sector = sector; m_resourceManager = resourceManager; }
public void Merge(Sector metadataSource) { if (metadataSource == null) throw new ArgumentNullException("metadataSource"); // TODO: This is very fragile; if a new type is added to Sector we need to add more code here. if (metadataSource.Names.Any()) { Names.Clear(); Names.AddRange(metadataSource.Names); } if (metadataSource.DataFile != null) DataFile = metadataSource.DataFile; Subsectors.AddRange(metadataSource.Subsectors); Allegiances.AddRange(metadataSource.Allegiances); Borders.AddRange(metadataSource.Borders); Routes.AddRange(metadataSource.Routes); Labels.AddRange(metadataSource.Labels); Credits = metadataSource.Credits; Products.AddRange(metadataSource.Products); StylesheetText = metadataSource.StylesheetText; }
public SubsectorSelector(ResourceManager resourceManager, Sector sector, int index) { if (resourceManager == null) throw new ArgumentNullException("resourceManager"); if (sector == null) throw new ArgumentNullException("sector"); if (index < 0 || index >= 16) throw new ArgumentOutOfRangeException("index", "index must be 0...15"); m_sector = sector; m_index = index; m_resourceManager = resourceManager; }
public SectorSelector(ResourceManager resourceManager, Sector sector) { this.sector = sector ?? throw new ArgumentNullException(nameof(sector)); this.resourceManager = resourceManager ?? throw new ArgumentNullException(nameof(resourceManager)); }