示例#1
0
 public SerializableMap CreateMemento()
 {
     return(new SerializableMap
     {
         pvcAllocateWait = _pvcAllocateWait,
         lastPvcSector = _lastPvcSector,
         // create array of serialized sectors
         sectors = Sectors.Select(s => s.CreateMemento()).ToArray()
     });
 }
 public MapData Clone()
 {
     return(new MapData(
                nameSpace: NameSpace,
                lineDefs: LineDefs.Select(item => item.Clone()),
                sideDefs: SideDefs.Select(item => item.Clone()),
                vertices: Vertices.Select(item => item.Clone()),
                sectors: Sectors.Select(item => item.Clone()),
                things: Things.Select(item => item.Clone()),
                comment: Comment,
                unknownProperties: UnknownProperties.Select(item => item.Clone()),
                unknownBlocks: UnknownBlocks.Select(item => item.Clone())));
 }
        private string BuildUrl()
        {
            var url = $"{BaseUrl}trainingcourses?keyword={Keyword}";

            if (OrderBy != OrderBy.None)
            {
                url += $"&orderby={OrderBy}";
            }
            if (Sectors != null && Sectors.Any())
            {
                url += "&routeIds=" + string.Join("&routeIds=", Sectors.Select(HttpUtility.HtmlEncode));
            }
            if (Levels != null && Levels.Any())
            {
                url += "&levels=" + string.Join("&levels=", Levels);
            }

            if (_shortlistUserId.HasValue)
            {
                url += $"&shortlistUserId={_shortlistUserId}";
            }
            return(url);
        }
示例#4
0
        public void Parse(bool skipMultiSectors)
        {
            Loading = true;

            ParseRoadLookFiles();

            // Load all LUTs
            LoadLUT();

            ItemSearchRequests = new List <Ets2ItemSearchRequest>();
            Sectors            = SectorFiles.Select(x => new Ets2Sector(this, x)).ToList();

            // 2-stage process so we can validate node UID's at item stage
            ThreadPool.SetMaxThreads(1, 1);
            Parallel.ForEach(Sectors, (sec) => sec.ParseNodes());
            Parallel.ForEach(Sectors, (sec) => sec.ParseItems());

            Loading = false;

            // Some nodes may refer to items in other sectors.
            // We can search all sectors for those, but this is relatively slow process.
            if (!skipMultiSectors)
            {
                // Now find all that were not found
                Console.WriteLine(ItemSearchRequests.Count +
                                  " were not found; attempting to search them through all sectors");
                foreach (var req in ItemSearchRequests)
                {
                    Ets2Item item = Sectors.Select(sec => sec.FindItem(req.ItemUID)).FirstOrDefault(tmp => tmp != null);

                    if (item == null)
                    {
                        Console.WriteLine("Still couldn't find node " + req.ItemUID.ToString("X16"));
                    }
                    else
                    {
                        if (req.IsBackward)
                        {
                            item.Apply(req.Node);
                            req.Node.BackwardItem = item;
                        }
                        if (req.IsForward)
                        {
                            item.Apply(req.Node);
                            req.Node.ForwardItem = item;
                        }

                        if (item.StartNode == null && item.StartNodeUID != null)
                        {
                            Ets2Node startNode;
                            if (Nodes.TryGetValue(item.StartNodeUID, out startNode))
                            {
                                item.Apply(startNode);
                            }
                        }
                        if (item.EndNode == null && item.EndNodeUID != null)
                        {
                            Ets2Node endNode;
                            if (Nodes.TryGetValue(item.EndNodeUID, out endNode))
                            {
                                item.Apply(endNode);
                            }
                        }

                        Console.Write(".");
                    }
                }
            }

            // Navigation cache
            BuildNavigationCache();

            // Lookup all cities
            Cities = Items.Values.Where(x => x.Type == Ets2ItemType.City).GroupBy(x => x.City).Select(x => x.FirstOrDefault()).ToDictionary(x => x.City, x => x);

            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Building) + " buildings were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Road) + " roads were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Prefab) + " prefabs were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Prefab && x.Prefab != null && x.Prefab.Curves.Any()) + " road prefabs were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Service) + " service points were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.Company) + " companies were found");
            Console.WriteLine(Items.Values.Count(x => x.Type == Ets2ItemType.City) + " cities were found");
        }