Example #1
0
        protected override void Process(System.Web.HttpContext context, ResourceManager resourceManager)
        {
            context.Response.ContentType = ContentTypes.Text.Plain;
            context.Response.StatusCode  = 200;

            string?sectorName = GetStringOption(context, "sector");
            string?type       = GetStringOption(context, "type");
            string?regex      = GetStringOption(context, "regex");
            string?milieu     = GetStringOption(context, "milieu");

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap.Flush();
            SectorMap map = SectorMap.GetInstance(resourceManager);

            var sectorQuery = from sector in map.Sectors
                              where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) &&
                              (sector.DataFile != null) &&
                              (type == null || sector.DataFile.Type == type) &&
                              (!sector.Tags.Contains("ZCR")) &&
                              (!sector.Tags.Contains("meta")) &&
                              (milieu == null || sector.CanonicalMilieu == milieu)
                              orderby sector.Names[0].Text
                              select sector;

            Dictionary <string, HashSet <string> > codes = new Dictionary <string, HashSet <string> >();

            Regex filter = new Regex(regex ?? ".*");

            foreach (var sector in sectorQuery)
            {
                WorldCollection?worlds = sector.GetWorlds(resourceManager, cacheResults: false);
                if (worlds == null)
                {
                    continue;
                }

                foreach (var code in worlds
                         .SelectMany(world => world.Codes)
                         .Where(code => filter.IsMatch(code) && !s_knownCodes.IsMatch(code)))
                {
                    if (!codes.ContainsKey(code))
                    {
                        codes.Add(code, new HashSet <string>());
                    }
                    codes[code].Add($"{sector.Names[0].Text} [{sector.CanonicalMilieu}]");
                }
            }

            foreach (var code in codes.Keys.OrderBy(s => s))
            {
                context.Response.Output.Write(code + " - ");
                foreach (var sector in codes[code].OrderBy(s => s))
                {
                    context.Response.Output.Write(sector + " ");
                }
                context.Response.Output.WriteLine("");
            }
        }
Example #2
0
            public override void Process(ResourceManager resourceManager)
            {
                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));

                World startWorld = ResolveLocation(Context, "start", resourceManager, map);

                if (startWorld == null)
                {
                    return;
                }

                World endWorld = ResolveLocation(Context, "end", resourceManager, map);

                if (endWorld == null)
                {
                    return;
                }

                int jump = GetIntOption("jump", 2).Clamp(0, 12);

                var finder = new TravellerPathFinder(resourceManager, map, jump)
                {
                    RequireWildernessRefuelling = GetBoolOption("wild", false),
                    ImperialWorldsOnly          = GetBoolOption("im", false),
                    AvoidRedZones = GetBoolOption("nored", false)
                };
                List <World> route = finder.FindPath(startWorld, endWorld) ??
                                     throw new HttpError(404, "Not Found", "No route found");

                SendResult(route.Select(w => new Results.RouteStop(w)).ToList());
            }
Example #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!AdminAuthorized())
            {
                return;
            }

            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            MapOptions options = MapOptions.SectorGrid | MapOptions.FilledBorders;

            Stylesheet.Style style = Stylesheet.Style.Poster;
            ParseOptions(ref options, ref style);

            double x        = -0.5;
            double y        = -0.5;
            double scale    = 2;
            Size   tileSize = new Size(1000, 1000);

            RectangleF tileRect = new RectangleF();

            tileRect.X      = (float)(x * tileSize.Width / (scale * Astrometrics.ParsecScaleX));
            tileRect.Y      = (float)(y * tileSize.Height / (scale * Astrometrics.ParsecScaleY));
            tileRect.Width  = (float)(tileSize.Width / (scale * Astrometrics.ParsecScaleX));
            tileRect.Height = (float)(tileSize.Height / (scale * Astrometrics.ParsecScaleY));

            DateTime dt = DateTime.Now;

            Render.RenderContext ctx = new Render.RenderContext();
            ctx.resourceManager = resourceManager;
            ctx.selector        = new RectSelector(
                SectorMap.FromName(SectorMap.DefaultSetting, resourceManager),
                resourceManager,
                tileRect);
            ctx.tileRect = tileRect;
            ctx.scale    = scale;
            ctx.options  = options;
            ctx.styles   = new Stylesheet(scale, options, style);
            ctx.tileSize = tileSize;
            ctx.silly    = false;
            ctx.tiling   = true;

            ctx.styles.microRoutes.visible       = true;
            ctx.styles.macroRoutes.visible       = false;
            ctx.styles.macroBorders.visible      = false;
            ctx.styles.microBorders.visible      = true;
            ctx.styles.capitals.visible          = false;
            ctx.styles.worlds.visible            = true;
            ctx.styles.worldDetails              = WorldDetails.Dotmap;
            ctx.styles.showAllSectorNames        = false;
            ctx.styles.showSomeSectorNames       = false;
            ctx.styles.macroNames.visible        = false;
            ctx.styles.pseudoRandomStars.visible = false;
            ctx.styles.fillMicroBorders          = true;

            ProduceResponse("Overview", ctx, tileSize);
        }
Example #4
0
            public override void Process(ResourceManager resourceManager)
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                SectorMap map = SectorMap.GetInstance(resourceManager);

                SendResult(map.GetMilieux().Select(code => new Results.Milieu(code)).ToList());
            }
Example #5
0
        private static void ProcessReader(String name, String ext, BinaryReader br)
        {
            switch (ext)
            {
            case "fat":     // Map written in text mode, actually it doesn't exist in the packed files
                break;

            case "fam":     // Map
                SectorMap.Read(name, br);
                break;

            case "xml":     // Xml
                using (var sw = new StreamWriter(name))
                    sw.WriteLine(Xml.Read(name, br).Content);

                break;

            case "txt":     // Text
                Txt.Read(name, br);
                break;

            case "ndw":
                NDW.Read(name, br);
                break;

            // Not needed for the server (yet or anyways)
            case "cat":     // Catalog
            case "dds":
            case "DDS":
            case "png":     // Png
            case "tga":     // Tga
            case "pgm":
            case "bak":     // Backup
            case "anm":     // Animation
            case "fx":
            case "fxh":
            case "fxi":
            case "geo":
            case "geo01":
            case "ogg":     // Ogg
                break;

            // Unknown yet
            case "tec":
            case "sha":
            case "spt":
            case "scc":
            case "cache":
            case "tk":
            case "lnk":
                break;

            default:
                Console.WriteLine(ext);
                break;
            }
        }
Example #6
0
        /// <summary>
        /// Moves a file in the image to a different sector. Updates the sector map and the <see cref="DirectoryRecord"/> of the file. This method does not perform any validation on whether the file can be moved to the given sector.
        /// </summary>
        /// <param name="filesector">The <see cref="FileSector"/> to be moved.</param>
        /// <param name="newsector">The sector to move the <see cref="FileSector"/> to.</param>
        public void ChangeFileSector(FileSector filesector, UInt32 newsector)
        {
            Assert.IsNotNull(filesector, nameof(filesector));

            SectorMap.Remove(filesector.Record.SectorNumber);

            SectorMap[newsector] = filesector;

            filesector.Record.SectorNumber = newsector;
        }
Example #7
0
            public override void Process(ResourceManager resourceManager)
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));

                Location loc;

                // Accept either sector [& hex] or sx,sy [& hx,hy] or x,y
                if (HasOption("sector"))
                {
                    string sectorName = GetStringOption("sector");
                    Sector sector     = map.FromName(sectorName) ??
                                        throw new HttpError(404, "Not Found", $"The specified sector '{sectorName}' was not found.");

                    if (HasOption("subsector"))
                    {
                        string subsector = GetStringOption("subsector");
                        int    index     = sector.SubsectorIndexFor(subsector);
                        if (index == -1)
                        {
                            throw new HttpError(404, "Not Found", $"The specified subsector '{subsector}' was not found.");
                        }
                        loc = new Location(sector.Location, new Hex(
                                               (byte)(index % 4 * Astrometrics.SubsectorWidth + Astrometrics.SubsectorWidth / 2),
                                               (byte)(index / 4 * Astrometrics.SubsectorHeight + Astrometrics.SubsectorHeight / 2)));
                    }
                    else
                    {
                        int hex = GetIntOption("hex", 0);
                        loc = new Location(sector.Location, hex);
                    }
                }
                else if (HasLocation())
                {
                    loc = GetLocation();
                }
                else
                {
                    throw new HttpError(400, "Bad Request", "Must specify either sector name (and optional hex) or sx, sy (and optional hx, hy), or x, y (world-space coordinates).");
                }

                Point coords = Astrometrics.LocationToCoordinates(loc);

                SendResult(new Results.CoordinatesResult()
                {
                    SectorX = loc.Sector.X,
                    SectorY = loc.Sector.Y,
                    HexX    = loc.Hex.X,
                    HexY    = loc.Hex.Y,
                    X       = coords.X,
                    Y       = coords.Y
                });
            }
Example #8
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!ServiceConfiguration.CheckEnabled("msec", Response))
            {
                return;
            }

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            ResourceManager resourceManager = new ResourceManager(Server, Cache);
            SectorMap       map             = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);
            Sector          sector;

            if (HasOption("sx") && HasOption("sy"))
            {
                int sx = GetIntOption("sx", 0);
                int sy = GetIntOption("sy", 0);

                sector = map.FromLocation(sx, sy);

                if (sector == null)
                {
                    SendError(404, "Not Found", String.Format("The sector at {0},{1} was not found.", sx, sy));
                    return;
                }
            }
            else if (HasOption("sector"))
            {
                string sectorName = GetStringOption("sector");
                sector = map.FromName(sectorName);

                if (sector == null)
                {
                    SendError(404, "Not Found", String.Format("The specified sector '{0}' was not found.", sectorName));
                    return;
                }
            }
            else
            {
                SendError(404, "Not Found", "No sector specified.");
                return;
            }

            string data;

            using (var writer = new StringWriter())
            {
                new MSECSerializer().Serialize(writer, sector);
                data = writer.ToString();
            }

            SendResult(data);
        }
Example #9
0
        /// <summary>
        /// Returns the highest sector in use by the ISO9660 image. This method assumes that this sector will be in use by a <see cref="FileSector"/>.
        /// </summary>
        /// <returns>The highest sector used by the image.</returns>
        public UInt32 GetHighestSectorUsed()
        {
            var lastsectoritem = SectorMap.Last();

            if (lastsectoritem.Value is FileSector file)
            {
                var lastsectorused = lastsectoritem.Key + (MathUtil.RoundUp(file.Record.DataLength, (UInt32)DefaultSectorSize) / DefaultSectorSize);
                return((UInt32)lastsectorused);
            }

            throw new Exception();
        }
Example #10
0
    public void populateSector()
    {
        float h = Camera.main.orthographicSize * 2;
        float w = h * Camera.main.aspect;

        SectorMap     map     = new SectorMap(number, w, h);
        List <Sector> sectors = map.sectors;

        for (int i = 0; i < sectors.Count; i++)
        {
            createSector(sectors[i]);
        }
    }
Example #11
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!AdminAuthorized())
            {
                return;
            }

            Response.ContentType = MediaTypeNames.Text.Plain;

            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            string sectorName = GetStringOption("sector");
            string type       = GetStringOption("type");

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap.Flush();
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            var sectorQuery = from sector in map.Sectors
                              where (sectorName == null || sector.Names[0].Text.StartsWith(sectorName, ignoreCase: true, culture: CultureInfo.InvariantCulture)) &&
                              (sector.DataFile != null) &&
                              (type == null || sector.DataFile.Type == type) &&
                              (sector.Tags.Contains("OTU"))
                              orderby sector.Names[0].Text
                              select sector;

            foreach (var sector in sectorQuery)
            {
                Response.Output.WriteLine(sector.Names[0].Text);
#if DEBUG
                WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: false);

                if (worlds != null)
                {
                    Response.Output.WriteLine("{0} world(s)", worlds.Count());
                    foreach (string s in worlds.ErrorList.Where(s => candidate.IsMatch(s)))
                    {
                        Response.Output.WriteLine(s);
                    }
                }
                else
                {
                    Response.Output.WriteLine("{0} world(s)", 0);
                }
#endif
                Response.Output.WriteLine();
            }
            return;
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            ResourceManager resourceManager = new ResourceManager(Server, Cache);
            SectorMap       map             = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            Location loc = new Location(map.FromName("Spinward Marches").Location, 1910);

            // Accept either sector [& hex] or sx,sy [& hx,hy]
            if (HasOption("sector"))
            {
                string sectorName = GetStringOption("sector");
                Sector sector     = map.FromName(sectorName);
                if (sector == null)
                {
                    SendError(404, "Not Found", "Sector not found.");
                    return;
                }

                int hex = GetIntOption("hex", 0);
                loc = new Location(sector.Location, hex);
            }
            else if (HasOption("sx") && HasOption("sy"))
            {
                int sx = GetIntOption("sx", 0);
                int sy = GetIntOption("sy", 0);
                int hx = GetIntOption("hx", 0);
                int hy = GetIntOption("hy", 0);
                loc = new Location(map.FromLocation(sx, sy).Location, hx * 100 + hy);
            }
            else
            {
                SendError(404, "Not Found", "Must specify either sector name (and optional hex) or sx, sy (and optional hx, hy).");
                return;
            }

            Point coords = Astrometrics.LocationToCoordinates(loc);

            Result result = new Result();

            result.sx = loc.SectorLocation.X;
            result.sy = loc.SectorLocation.Y;
            result.hx = loc.HexLocation.X;
            result.hy = loc.HexLocation.Y;
            result.x  = coords.X;
            result.y  = coords.Y;
            SendResult(result);
        }
Example #13
0
            public override void Process()
            {
                ResourceManager resourceManager = new ResourceManager(context.Server);

                MapOptions options = MapOptions.SectorGrid | MapOptions.BordersMajor | MapOptions.NamesMajor | MapOptions.NamesMinor;

                Stylesheet.Style style = Stylesheet.Style.Poster;
                ParseOptions(ref options, ref style);

                double x     = GetDoubleOption("x", 0);
                double y     = GetDoubleOption("y", 0);
                double scale = Util.Clamp(GetDoubleOption("scale", 0), MinScale, MaxScale);

                int width  = GetIntOption("w", NormalTileWidth);
                int height = GetIntOption("h", NormalTileHeight);

                if (width < 0 || height < 1)
                {
                    throw new HttpError(400, "Bad Request",
                                        string.Format("Requested dimensions ({0}x{1}) invalid.", width, height));
                }
                if (width * height > MaxDimension * MaxDimension)
                {
                    throw new HttpError(400, "Bad Request",
                                        string.Format("Requested dimensions ({0}x{1}) too large.", width, height));
                }


                Size tileSize = new Size(width, height);

                RectangleF tileRect = new RectangleF();

                tileRect.X      = (float)(x * tileSize.Width / (scale * Astrometrics.ParsecScaleX));
                tileRect.Y      = (float)(y * tileSize.Height / (scale * Astrometrics.ParsecScaleY));
                tileRect.Width  = (float)(tileSize.Width / (scale * Astrometrics.ParsecScaleX));
                tileRect.Height = (float)(tileSize.Height / (scale * Astrometrics.ParsecScaleY));

                DateTime dt    = DateTime.Now;
                bool     silly = (Math.Abs((int)x % 2) == Math.Abs((int)y % 2)) && (dt.Month == 4 && dt.Day == 1);

                silly = GetBoolOption("silly", silly);

                Selector      selector = new RectSelector(SectorMap.ForMilieu(resourceManager, GetStringOption("milieu")), resourceManager, tileRect);
                Stylesheet    styles   = new Stylesheet(scale, options, style);
                RenderContext ctx      = new RenderContext(resourceManager, selector, tileRect, scale, options, styles, tileSize);

                ctx.Silly = silly;
                ctx.ClipOutsectorBorders = true;
                ProduceResponse(context, "Tile", ctx, tileSize);
            }
Example #14
0
        private static void Flush(HttpContext context)
        {
            SectorMap.Flush();

            var enumerator = context.Cache.GetEnumerator();

            while (enumerator.MoveNext())
            {
                context.Cache.Remove(enumerator.Key.ToString());
            }

            Write(context.Response, "Sector map flushed.");
            Write(context.Response, "<b>&Omega;</b>");
        }
Example #15
0
        public static SectorMap GetMap(UInt32 id)
        {
            lock (LockObject)
            {
                if (Maps.ContainsKey(id))
                    return Maps[id];

                var sm = new SectorMap(id);

                Maps.Add(id, sm);

                return sm;
            }
        }
Example #16
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!ServiceConfiguration.CheckEnabled("jumpworlds", Response))
            {
                return;
            }

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            //
            // Jump
            //
            int jump = Util.Clamp(GetIntOption("jump", 6), 0, 12);

            //
            // Coordinates
            //
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);
            Location  loc = new Location(map.FromName("Spinward Marches").Location, 1910);

            if (HasOption("sector") && HasOption("hex"))
            {
                string sectorName = GetStringOption("sector");
                int    hex        = GetIntOption("hex", 0);
                loc = new Location(map.FromName(sectorName).Location, hex);
            }
            else if (HasOption("sx") && HasOption("sy") && HasOption("hx") && HasOption("hy"))
            {
                int sx = GetIntOption("sx", 0);
                int sy = GetIntOption("sy", 0);
                int hx = GetIntOption("hx", 0);
                int hy = GetIntOption("hy", 0);
                loc = new Location(map.FromLocation(sx, sy).Location, hx * 100 + hy);
            }
            else if (HasOption("x") && HasOption("y"))
            {
                loc = Astrometrics.CoordinatesToLocation(GetIntOption("x", 0), GetIntOption("y", 0));
            }

            Selector selector = new HexSelector(map, resourceManager, loc, jump);

            Result data = new Result();

            data.Worlds.AddRange(selector.Worlds);
            SendResult(data);
        }
            public override void Process()
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                ResourceManager resourceManager = new ResourceManager(context.Server);

                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));
                Sector           sector;

                if (context.Request.HttpMethod == "POST")
                {
                    var type   = SectorMetadataFileParser.SniffType(context.Request.InputStream);
                    var parser = SectorMetadataFileParser.ForType(type);
                    using (var reader = new System.IO.StreamReader(context.Request.InputStream, context.Request.ContentEncoding))
                    {
                        sector = parser.Parse(reader);
                    }
                }
                else if (HasOption("sx") && HasOption("sy"))
                {
                    int sx = GetIntOption("sx", 0);
                    int sy = GetIntOption("sy", 0);

                    sector = map.FromLocation(sx, sy);

                    if (sector == null)
                    {
                        throw new HttpError(404, "Not Found", string.Format("The sector at {0},{1} was not found.", sx, sy));
                    }
                }
                else if (HasOption("sector"))
                {
                    string sectorName = GetStringOption("sector");
                    sector = map.FromName(sectorName);

                    if (sector == null)
                    {
                        throw new HttpError(404, "Not Found", string.Format("The specified sector '{0}' was not found.", sectorName));
                    }
                }
                else
                {
                    throw new HttpError(400, "Bad Request", "No sector specified.");
                }

                SendResult(context, new Results.SectorMetadata(sector, sector.GetWorlds(resourceManager, cacheResults: true)));
            }
Example #18
0
        /// <summary>
        /// Checks if there is available room in the image for a <see cref="DirectoryRecord"/> at its current sector.
        /// </summary>
        /// <param name="record">The <see cref="DirectoryRecord"/> to be checked.</param>
        /// <param name="sectorsneedded">The number of sectors needed by the <see cref="DirectoryRecord"/>.</param>
        /// <returns>Return true if there is available room in the image for the file at its current sector. Otherwise, false.</returns>
        public Boolean CheckForRoom(DirectoryRecord record, Int32 sectorsneedded)
        {
            Assert.IsNotNull(record, nameof(record));

            var sectorsneedsed = Enumerable.Range((Int32)record.SectorNumber, sectorsneedded).Skip(1);

            foreach (var sector in sectorsneedsed)
            {
                if (SectorMap.ContainsKey((UInt32)sector) == true)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #19
0
        public void OrdersUpdate(GameTime gt, LocalUnits lh, SectorMap smap)
        {
            ClearingOrders(lh);
            GivingOrders(lh);
            MakingOrders(gt, lh, smap);

            s10 += gt.ElapsedGameTime;
            if (s10.TotalSeconds >= 1)
            {
                s10 -= TimeSpan.FromSeconds(1);
                foreach (Order order in N)
                {
                    order.sleep = false;
                }
            }
        }
Example #20
0
            public override void Process()
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                ResourceManager resourceManager = new ResourceManager(context.Server);

                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));
                Sector           sector;

                if (HasOption("sx") && HasOption("sy"))
                {
                    int sx = GetIntOption("sx", 0);
                    int sy = GetIntOption("sy", 0);

                    sector = map.FromLocation(sx, sy);

                    if (sector == null)
                    {
                        throw new HttpError(404, "Not Found", string.Format("The sector at {0},{1} was not found.", sx, sy));
                    }
                }
                else if (HasOption("sector"))
                {
                    string sectorName = GetStringOption("sector");
                    sector = map.FromName(sectorName);

                    if (sector == null)
                    {
                        throw new HttpError(404, "Not Found", string.Format("The specified sector '{0}' was not found.", sectorName));
                    }
                }
                else
                {
                    throw new HttpError(400, "Bad Request", "No sector specified.");
                }

                string data;

                using (var writer = new StringWriter())
                {
                    new MSECSerializer().Serialize(writer, sector);
                    data = writer.ToString();
                }

                SendResult(context, data);
            }
Example #21
0
            public override void Process(ResourceManager resourceManager)
            {
                MapOptions options = MapOptions.SectorGrid | MapOptions.BordersMajor | MapOptions.NamesMajor | MapOptions.NamesMinor;
                Style      style   = Style.Poster;

                ParseOptions(ref options, ref style);

                double x     = GetDoubleOption("x", 0);
                double y     = GetDoubleOption("y", 0);
                double scale = GetDoubleOption("scale", 0).Clamp(MinScale, MaxScale);

                int width  = GetIntOption("w", NormalTileWidth);
                int height = GetIntOption("h", NormalTileHeight);

                if (width < 1 || height < 1)
                {
                    throw new HttpError(400, "Bad Request",
                                        $"Requested dimensions ({width}x{height}) invalid.");
                }
                if (width * height > MaxDimension * MaxDimension)
                {
                    throw new HttpError(400, "Bad Request",
                                        $"Requested dimensions ({width}x{height}) too large.");
                }


                Size tileSize = new Size(width, height);

                RectangleF tileRect = new RectangleF()
                {
                    X      = (float)(x * tileSize.Width / (scale * Astrometrics.ParsecScaleX)),
                    Y      = (float)(y * tileSize.Height / (scale * Astrometrics.ParsecScaleY)),
                    Width  = (float)(tileSize.Width / (scale * Astrometrics.ParsecScaleX)),
                    Height = (float)(tileSize.Height / (scale * Astrometrics.ParsecScaleY))
                };
                DateTime dt = DateTime.Now;

                Selector      selector = new RectSelector(SectorMap.ForMilieu(resourceManager, GetStringOption("milieu")), resourceManager, tileRect);
                Stylesheet    styles   = new Stylesheet(scale, options, style);
                RenderContext ctx      = new RenderContext(resourceManager, selector, tileRect, scale, options, styles, tileSize)
                {
                    ClipOutsectorBorders = true
                };

                ProduceResponse(Context, "Tile", ctx, tileSize, AbstractMatrix.Identity);
            }
Example #22
0
                public override void Process()
                {
                    ResourceManager resourceManager = new ResourceManager(context.Server);

                    MapOptions options = MapOptions.SectorGrid | MapOptions.FilledBorders;

                    Stylesheet.Style style = Stylesheet.Style.Poster;
                    ParseOptions(ref options, ref style);

                    float x        = -0.5f;
                    float y        = -0.5f;
                    float scale    = 2;
                    Size  tileSize = new Size(1000, 1000);

                    RectangleF tileRect = new RectangleF();

                    tileRect.X      = x * tileSize.Width / (scale * Astrometrics.ParsecScaleX);
                    tileRect.Y      = y * tileSize.Height / (scale * Astrometrics.ParsecScaleY);
                    tileRect.Width  = tileSize.Width / (scale * Astrometrics.ParsecScaleX);
                    tileRect.Height = tileSize.Height / (scale * Astrometrics.ParsecScaleY);

                    Selector selector = new RectSelector(
                        SectorMap.ForMilieu(resourceManager, GetStringOption("milieu")),
                        resourceManager,
                        tileRect);
                    Stylesheet styles = new Stylesheet(scale, options, style);

                    styles.microRoutes.visible       = true;
                    styles.macroRoutes.visible       = false;
                    styles.macroBorders.visible      = false;
                    styles.microBorders.visible      = true;
                    styles.capitals.visible          = false;
                    styles.worlds.visible            = true;
                    styles.worldDetails              = WorldDetails.Dotmap;
                    styles.showAllSectorNames        = false;
                    styles.showSomeSectorNames       = false;
                    styles.macroNames.visible        = false;
                    styles.pseudoRandomStars.visible = false;
                    styles.fillMicroBorders          = true;

                    RenderContext ctx = new RenderContext(resourceManager, selector, tileRect, scale, options, styles, tileSize);

                    ctx.ClipOutsectorBorders = true;

                    ProduceResponse(context, "Overview", ctx, tileSize);
                }
Example #23
0
        public bool CreateSectorMap(SectorMap sectorMap)
        {
            outpostwarsEntities entities = new outpostwarsEntities();

            try
            {
                // Add tew New Player into the player Collection
                entities.SectorMaps.Add(sectorMap);
                // Save changes
                return(entities.SaveChanges() == 1);
            }
            catch (DbEntityValidationException ex)
            {
                LogCriticalError(ex);
            }
            return(false);
        }
Example #24
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            MapOptions options = MapOptions.SectorGrid | MapOptions.BordersMajor | MapOptions.NamesMajor | MapOptions.NamesMinor;

            Stylesheet.Style style = Stylesheet.Style.Poster;
            ParseOptions(ref options, ref style);

            double x      = GetDoubleOption("x", 0);
            double y      = GetDoubleOption("y", 0);
            double scale  = Util.Clamp(GetDoubleOption("scale", 0), MinScale, MaxScale);
            int    width  = Util.Clamp(GetIntOption("w", NormalTileWidth), MinDimension, MaxDimension);
            int    height = Util.Clamp(GetIntOption("h", NormalTileHeight), MinDimension, MaxDimension);

            Size tileSize = new Size(width, height);

            RectangleF tileRect = new RectangleF();

            tileRect.X      = (float)(x * tileSize.Width / (scale * Astrometrics.ParsecScaleX));
            tileRect.Y      = (float)(y * tileSize.Height / (scale * Astrometrics.ParsecScaleY));
            tileRect.Width  = (float)(tileSize.Width / (scale * Astrometrics.ParsecScaleX));
            tileRect.Height = (float)(tileSize.Height / (scale * Astrometrics.ParsecScaleY));

            DateTime dt    = DateTime.Now;
            bool     silly = (Math.Abs((int)x % 2) == Math.Abs((int)y % 2)) && (dt.Month == 4 && dt.Day == 1);

            silly = GetBoolOption("silly", silly);

            Render.RenderContext ctx = new Render.RenderContext();
            ctx.resourceManager = resourceManager;
            ctx.selector        = new RectSelector(
                SectorMap.FromName(SectorMap.DefaultSetting, resourceManager),
                resourceManager,
                tileRect);
            ctx.tileRect = tileRect;
            ctx.scale    = scale;
            ctx.options  = options;
            ctx.styles   = new Stylesheet(scale, options, style);
            ctx.tileSize = tileSize;
            ctx.silly    = silly;
            ctx.tiling   = true;
            ProduceResponse("Tile", ctx, tileSize);
        }
Example #25
0
            public override void Process()
            {
                ResourceManager resourceManager = new ResourceManager(context.Server);

                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                SectorMap map = SectorMap.GetInstance(resourceManager);

                // Filter parameters
                string milieu      = GetStringOption("milieu") ?? GetStringOption("era");
                bool   requireData = GetBoolOption("requireData", defaultValue: false);

                string[] tags = GetStringsOption("tag");

                UniverseResult data = new UniverseResult();

                foreach (Sector sector in map.Sectors)
                {
                    if (requireData && sector.DataFile == null)
                    {
                        continue;
                    }

                    if (sector.Tags.Contains("meta"))
                    {
                        continue;
                    }

                    if (milieu != null && sector.DataFile?.Milieu != milieu)
                    {
                        continue;
                    }

                    if (tags != null && !tags.Any(tag => sector.Tags.Contains(tag)))
                    {
                        continue;
                    }

                    data.Sectors.Add(new UniverseResult.SectorResult(sector));
                }

                SendResult(context, data);
            }
Example #26
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!AdminAuthorized())
            {
                return;
            }

            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            Response.ContentType = MediaTypeNames.Text.Plain;

            foreach (Sector sector in map.Sectors)
            {
                WorldCollection worlds = sector.GetWorlds(resourceManager);
                if (worlds == null)
                {
                    continue;
                }
                foreach (World world in worlds)
                {
                    List <string> list = new List <string> {
                        sector.Names[0].Text,
                        sector.X.ToString(),
                        sector.Y.ToString(),
                        world.X.ToString(),
                        world.Y.ToString(),
                        world.Name,
                        world.UWP,
                        world.Bases,
                        world.Remarks,
                        world.PBG,
                        world.Allegiance,
                        world.Stellar
                    };
                    WriteCSV(list);
                }
            }
        }
Example #27
0
            public override void Process()
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                ResourceManager resourceManager = new ResourceManager(context.Server);

                //
                // Jump
                //
                int jump = Util.Clamp(GetIntOption("jump", 6), 0, 12);

                //
                // Coordinates
                //
                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));
                Location         loc = new Location(map.FromName("Spinward Marches").Location, 1910);

                if (HasOption("sector") && HasOption("hex"))
                {
                    string sectorName = GetStringOption("sector");
                    int    hex        = GetIntOption("hex", 0);
                    Sector sector     = map.FromName(sectorName);
                    if (sector == null)
                    {
                        throw new HttpError(404, "Not Found", string.Format("The specified sector '{0}' was not found.", sectorName));
                    }

                    loc = new Location(sector.Location, hex);
                }
                else if (HasLocation())
                {
                    loc = GetLocation();
                }

                Selector selector = new HexSelector(map, resourceManager, loc, jump);

                var data = new Results.JumpWorldsResult();

                data.Worlds.AddRange(selector.Worlds);
                SendResult(context, data);
            }
Example #28
0
        protected override void Process(System.Web.HttpContext context)
        {
            ResourceManager resourceManager = new ResourceManager(context.Server);

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap map = SectorMap.GetInstance(resourceManager);

            context.Response.ContentType  = MediaTypeNames.Text.Plain;
            context.Response.BufferOutput = false;

            foreach (Sector sector in map.Sectors)
            {
                WorldCollection worlds = sector.GetWorlds(resourceManager);
                if (worlds == null)
                {
                    continue;
                }
                foreach (World world in worlds)
                {
                    List <string> list = new List <string> {
                        sector.Names[0].Text,
                        sector.X.ToString(),
                        sector.Y.ToString(),
                        world.X.ToString(),
                        world.Y.ToString(),
                        world.Name,
                        world.UWP,
                        world.Bases,
                        world.Remarks,
                        world.PBG,
                        world.Allegiance,
                        world.Stellar
                    };
                    WriteCSV(context.Response.Output, list);
                }
            }
        }
Example #29
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!ServiceConfiguration.CheckEnabled("universe", Response))
            {
                return;
            }

            ResourceManager resourceManager = new ResourceManager(Server, Cache);

            // NOTE: This (re)initializes a static data structure used for
            // resolving names into sector locations, so needs to be run
            // before any other objects (e.g. Worlds) are loaded.
            SectorMap map = SectorMap.FromName(SectorMap.DefaultSetting, resourceManager);

            // Filter parameters
            string era         = GetStringOption("era");
            bool   requireData = GetBoolOption("requireData", defaultValue: false);

            Result data = new Result();

            foreach (Sector sector in map.Sectors)
            {
                if (requireData && sector.DataFile == null)
                {
                    continue;
                }

                if (era != null && (sector.DataFile == null || sector.DataFile.Era != era))
                {
                    continue;
                }

                SectorBase sb = new SectorBase(sector);
                data.Sectors.Add(sb);
            }

            SendResult(data);
        }
            public override void Process(ResourceManager resourceManager)
            {
                // NOTE: This (re)initializes a static data structure used for
                // resolving names into sector locations, so needs to be run
                // before any other objects (e.g. Worlds) are loaded.
                SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));

                //
                // Jump
                //
                int jump = GetIntOption("jump", 6).Clamp(0, 12);

                //
                // Coordinates
                //
                Location loc = Location.Empty;

                if (HasOption("sector") && HasOption("hex"))
                {
                    string sectorName = GetStringOption("sector");
                    int    hex        = GetIntOption("hex", 0);
                    Sector sector     = map.FromName(sectorName) ??
                                        throw new HttpError(404, "Not Found", $"The specified sector '{sectorName}' was not found.");

                    loc = new Location(sector.Location, hex);
                }
                else if (HasLocation())
                {
                    loc = GetLocation();
                }

                Selector selector = new HexSelector(map, resourceManager, loc, jump);

                var data = new Results.JumpWorldsResult();

                data.Worlds.AddRange(selector.Worlds);
                SendResult(data);
            }
Example #31
0
        public Inventory(Int32 x, Int32 y, Int32 numPages)
        {
            _map = null;
            _gridSpace = null;
            _inventoryType = InventoryType.None;
            _owner = null;
            _doubleCheckBlock = false;
            _dirty = false;
            _x = x;
            _y = y;
            _numPages = numPages;

            if (_x <= 0)
                _x = 1;

            if (_y <= 0)
                _y = 1;

            if (_numPages <= 0)
                _numPages = 1;

            CreateGridSpace();
        }
Example #32
0
            public override void Process(ResourceManager resourceManager)
            {
                Selector   selector;
                RectangleF tileRect;
                MapOptions options = MapOptions.SectorGrid | MapOptions.SubsectorGrid | MapOptions.BordersMajor | MapOptions.BordersMinor | MapOptions.NamesMajor | MapOptions.NamesMinor | MapOptions.WorldsCapitals | MapOptions.WorldsHomeworlds;
                Style      style   = Style.Poster;

                ParseOptions(ref options, ref style);
                string title;
                bool   clipOutsectorBorders;

                if (HasOption("x1") && HasOption("x2") &&
                    HasOption("y1") && HasOption("y2"))
                {
                    // Arbitrary rectangle

                    int x1 = GetIntOption("x1", 0);
                    int x2 = GetIntOption("x2", 0);
                    int y1 = GetIntOption("y1", 0);
                    int y2 = GetIntOption("y2", 0);

                    tileRect = new RectangleF()
                    {
                        X = Math.Min(x1, x2),
                        Y = Math.Min(y1, y2)
                    };
                    tileRect.Width  = Math.Max(x1, x2) - tileRect.X;
                    tileRect.Height = Math.Max(y1, y2) - tileRect.Y;

                    // NOTE: This (re)initializes a static data structure used for
                    // resolving names into sector locations, so needs to be run
                    // before any other objects (e.g. Worlds) are loaded.
                    SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));
                    selector = new RectSelector(map, resourceManager, tileRect, slop: false);

                    // Include specified hexes
                    tileRect.Offset(-1, -1);
                    tileRect.Width  += 1;
                    tileRect.Height += 1;

                    title = $"Poster ({x1},{y1}) - ({x2},{y2})";
                    clipOutsectorBorders = true;
                }
                else if (HasOption("domain"))
                {
                    string domain = GetStringOption("domain") !;
                    double x, y, w = 2, h = 2;
                    switch (domain.ToLowerInvariant())
                    {
                    case "deneb": x = -4; y = -1; title = "Domain of Deneb"; break;

                    case "vland": x = -2; y = -1; title = "Domain of Vland"; break;

                    case "ilelish": x = -2; y = 1; title = "Domain of Ilelish"; break;

                    case "antares": x = 0; y = -2; title = "Domain of Antares"; break;

                    case "sylea": x = 0; y = 0; title = "Domain of Sylea"; break;

                    case "sol": x = 0; y = 2; title = "Domain of Sol"; break;

                    case "gateway": x = 2; y = 0; title = "Domain of Gateway"; break;

                    // And these aren't domains, but...
                    case "foreven": x = -6; y = -1; title = "Land Grant / Foreven"; break;

                    case "imperium": x = -4; y = -1; w = 7; h = 5; title = "Third Imperium"; break;

                    case "solomani": x = -1.5; y = 2.75; w = 4; h = 2.25; title = "Solomani Confederacy"; break;

                    case "zhodani": x = -8; y = -3; w = 5; h = 3; title = "Zhodani Consulate"; break;

                    case "hive":
                    case "hiver": x = 2; y = 1; w = 6; h = 4; title = "Hive Federation"; break;

                    case "aslan": x = -8; y = 1; w = 7; h = 4; title = "Aslan Hierate"; break;

                    case "vargr": x = -4; y = -4; w = 8; h = 3; title = "Vargr Extents"; break;

                    case "kkree": x = 4; y = -2; w = 4; h = 4; title = "Two Thousand Worlds"; break;

                    case "jp": x = 0; y = -3; w = 4; h = 3; title = "Julian Protectorate"; break;
                    // TODO: Zhodani provinces

                    case "chartedspace": x = -8; y = -3; w = 16; h = 8; title = "Charted Space"; break;

                    case "jg": x = 160; y = 0; w = 2; h = 2; title = "Judges Guild"; break;

                    default:
                        throw new HttpError(404, "Not Found", $"Unknown domain: {domain}");
                    }

                    int x1 = (int)Math.Round(x * Astrometrics.SectorWidth - Astrometrics.ReferenceHex.X + 1);
                    int y1 = (int)Math.Round(y * Astrometrics.SectorHeight - Astrometrics.ReferenceHex.Y + 1);
                    int x2 = (int)Math.Round(x1 + w * Astrometrics.SectorWidth - 1);
                    int y2 = (int)Math.Round(y1 + h * Astrometrics.SectorHeight - 1);

                    tileRect = new RectangleF()
                    {
                        X = Math.Min(x1, x2),
                        Y = Math.Min(y1, y2)
                    };
                    tileRect.Width  = Math.Max(x1, x2) - tileRect.X;
                    tileRect.Height = Math.Max(y1, y2) - tileRect.Y;

                    // NOTE: This (re)initializes a static data structure used for
                    // resolving names into sector locations, so needs to be run
                    // before any other objects (e.g. Worlds) are loaded.
                    SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));
                    selector = new RectSelector(map, resourceManager, tileRect, slop: false);

                    // Include selected hexes
                    tileRect.Offset(-1, -1);
                    tileRect.Width  += 1;
                    tileRect.Height += 1;

                    // Account for jagged hexes
                    tileRect.Height += 0.5f;
                    tileRect.Inflate(0.25f, 0.10f);
                    if (style == Style.Candy)
                    {
                        tileRect.Width += 0.75f;
                    }

                    clipOutsectorBorders = true;
                }
                else
                {
                    // Sector - either POSTed or specified by name
                    Sector?sector = null;
                    options &= ~MapOptions.SectorGrid;

                    if (Context.Request.HttpMethod == "POST")
                    {
                        bool lint = GetBoolOption("lint", defaultValue: false);
                        Func <ErrorLogger.Record, bool>?filter = null;
                        if (lint)
                        {
                            bool hide_uwp = GetBoolOption("hide-uwp", defaultValue: false);
                            bool hide_tl  = GetBoolOption("hide-tl", defaultValue: false);
                            filter = (ErrorLogger.Record record) =>
                            {
                                if (hide_uwp && record.message.StartsWith("UWP"))
                                {
                                    return(false);
                                }
                                if (hide_tl && record.message.StartsWith("UWP: TL"))
                                {
                                    return(false);
                                }
                                return(true);
                            };
                        }
                        ErrorLogger errors = new ErrorLogger(filter);

                        sector = GetPostedSector(Context.Request, errors) ??
                                 throw new HttpError(400, "Bad Request", "Either file or data must be supplied in the POST data.");
                        if (lint && !errors.Empty)
                        {
                            throw new HttpError(400, "Bad Request", errors.ToString());
                        }


                        title = sector.Names.Count > 0 ? sector.Names[0].Text : "User Data";

                        // TODO: Suppress all OTU rendering.
                        options &= ~(MapOptions.WorldsHomeworlds | MapOptions.WorldsCapitals);
                    }
                    else
                    {
                        string sectorName = GetStringOption("sector") ??
                                            throw new HttpError(400, "Bad Request", "No sector specified.");

                        SectorMap.Milieu map = SectorMap.ForMilieu(resourceManager, GetStringOption("milieu"));

                        sector = map.FromName(sectorName) ??
                                 throw new HttpError(404, "Not Found", $"The specified sector '{sectorName}' was not found.");

                        title = sector.Names[0].Text;
                    }

                    if (sector != null && HasOption("subsector") && GetStringOption("subsector") !.Length > 0)
                    {
                        string subsector = GetStringOption("subsector") !;
                        int    index     = sector.SubsectorIndexFor(subsector);
                        if (index == -1)
                        {
                            throw new HttpError(404, "Not Found", $"The specified subsector '{subsector}' was not found.");
                        }

                        selector = new SubsectorSelector(resourceManager, sector, index);

                        tileRect = sector.SubsectorBounds(index);

                        options &= ~(MapOptions.SectorGrid | MapOptions.SubsectorGrid);

                        title = $"{title} - Subsector {'A' + index}";
                    }
Example #33
0
        public void InitNewVehicle(CreateCharacterModel model, ConfigNewCharacter newCharEntry, SectorMap map, Int64 charCoid, Int64 vehicleCoid)
        {
            SetCOID(vehicleCoid);

            CoidCurrentOwner = charCoid;
            Position = new Vector3(map.MapEntry.EntryX, map.MapEntry.EntryY, map.MapEntry.EntryZ);
            Rotation = new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
            Velocity = new Vector3();
            AngularVelocity = new Vector3();
            VehicleName = model.VehicleName;

            Trim = model.VehicleTrim;
            PrimaryColor = model.VehiclePrimaryColor;
            SecondaryColor = model.SecondaryColor;

            var armor = AllocateNewObjectFromCBID(newCharEntry.Armor);
            if (armor != null)
            {
                armor.SetCOID(CoidManager.NextCOID);
                armor.InitializeFromCBID(newCharEntry.Armor, map);
                armor.InitializeBaseData();

                SetArmorEquipped(armor.GetAsArmor());
            }

            var wheelSet = AllocateNewObjectFromCBID(model.CBidWheelset);
            if (wheelSet != null)
            {
                wheelSet.SetCOID(CoidManager.NextCOID);
                wheelSet.InitializeFromCBID(model.CBidWheelset, map);
                wheelSet.InitializeBaseData();

                SetWheelSet(wheelSet.GetAsWheelSet());
            }

            var powerPlant = AllocateNewObjectFromCBID(newCharEntry.PowerPlant);
            if (powerPlant != null)
            {
                powerPlant.SetCOID(CoidManager.NextCOID);
                powerPlant.InitializeFromCBID(newCharEntry.PowerPlant, map);
                powerPlant.InitializeBaseData();

                SetPowerPlant(powerPlant.GetAsPowerPlant());
            }

            var raceItem = AllocateNewObjectFromCBID(newCharEntry.RaceItem);
            if (raceItem != null)
            {
                raceItem.SetCOID(CoidManager.NextCOID);
                raceItem.InitializeFromCBID(newCharEntry.RaceItem, map);
                raceItem.InitializeBaseData();

                SetRaceItem(raceItem.GetAsSimpleObject());
            }

            var turret = AllocateNewObjectFromCBID(newCharEntry.Weapon);
            if (turret != null)
            {
                turret.SetCOID(CoidManager.NextCOID);
                turret.InitializeFromCBID(newCharEntry.Weapon, map);
                turret.InitializeBaseData();

                AddWeapon(1, turret.GetAsWeapon());
            }
        }
Example #34
0
            public static SearchResultItem LocationToSearchResult(SectorMap map, ResourceManager resourceManager, ItemLocation location)
            {
                if (location is WorldLocation)
                {
                    Sector sector;
                    World world;
                    ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                    if (sector == null || world == null)
                        return null;

                    WorldResult r = new WorldResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.HexX = world.X;
                    r.HexY = world.Y;
                    r.Name = world.Name;
                    r.Sector = sector.Names[0].Text;
                    r.Uwp = world.UWP;
                    r.Importance = world.ImportanceValue;

                    return r;
                }
                else if (location is SubsectorLocation)
                {
                    Sector sector;
                    Subsector subsector;
                    ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                    if (sector == null || subsector == null)
                        return null;

                    SubsectorResult r = new SubsectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.Name = subsector.Name;
                    r.Index = subsector.Index;
                    r.Sector = sector.Names[0].Text;

                    return r;
                }
                else if (location is SectorLocation)
                {
                    Sector sector = ((SectorLocation)location).Resolve(map);

                    if (sector == null)
                        return null;

                    SectorResult r = new SectorResult();
                    r.SectorX = sector.X;
                    r.SectorY = sector.Y;
                    r.SectorTags = sector.TagString;
                    r.Name = sector.Names[0].Text;

                    return r;
                }

                return null;
            }
Example #35
0
 public void SetMap(SectorMap map)
 {
     _map = map;
 }
 public virtual void SetMap(SectorMap map)
 {
     Map = map;
 }
    public fsMegaImage(iDiskImage DiskImage): base(DiskImage)
	{
		maxFiles = 64;
        LastSector = 8192;
        lSectorMap = new SectorMap(LastSector + 1);
	}
        public virtual void InitializeFromCBID(Int32 cbid, SectorMap map)
        {
            CloneBaseObject = AssetManager.AssetContainer.GetCloneBaseObjectForCBID(cbid);

            InitializeBaseData();
            InitializeSkillTree();
            SetMap(map);
        }
Example #39
0
        internal static Item LocationToSearchResult(SectorMap.Milieu map, ResourceManager resourceManager, ItemLocation location)
        {
            if (location is WorldLocation)
            {
                Sector sector;
                World world;
                ((WorldLocation)location).Resolve(map, resourceManager, out sector, out world);

                if (sector == null || world == null)
                    return null;

                WorldResult r = new WorldResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.HexX = world.X;
                r.HexY = world.Y;
                r.Name = world.Name;
                r.Sector = sector.Names[0].Text;
                r.Uwp = world.UWP;
                r.Importance = world.ImportanceValue;

                return r;
            }

            if (location is SubsectorLocation)
            {
                Sector sector;
                Subsector subsector;
                ((SubsectorLocation)location).Resolve(map, out sector, out subsector);

                if (sector == null || subsector == null)
                    return null;

                SubsectorResult r = new SubsectorResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name = subsector.Name;
                r.Index = subsector.Index;
                r.Sector = sector.Names[0].Text;

                return r;
            }

            if (location is SectorLocation)
            {
                Sector sector = ((SectorLocation)location).Resolve(map);

                if (sector == null)
                    return null;

                SectorResult r = new SectorResult();
                r.SectorX = sector.X;
                r.SectorY = sector.Y;
                r.SectorTags = sector.TagString;
                r.Name = sector.Names[0].Text;

                return r;
            }

            if (location is LabelLocation)
            {
                LabelLocation label = location as LabelLocation;
                Location l = Astrometrics.CoordinatesToLocation(label.Coords);
                Sector sector = label.Resolve(map);

                LabelResult r = new LabelResult();
                r.Name = label.Label;
                r.SectorX = l.Sector.X;
                r.SectorY = l.Sector.Y;
                r.HexX = l.Hex.X;;
                r.HexY = l.Hex.Y;
                r.Scale =
                    label.Radius > 80 ? 4 :
                    label.Radius > 40 ? 8 :
                    label.Radius > 20 ? 32 : 64;
                r.SectorTags = sector.TagString;

                return r;
            }

            throw new ArgumentException(string.Format("Unexpected result type: {0}", location.GetType().Name), "location");
        }