Пример #1
0
        /// <summary>
        /// Constructs a new World.
        /// </summary>
        /// <param name="regionID">The ID number of the region to create.</param>
        public World(Run8Wrapper run8, int regionID)
        {
            Debug.Assert(run8 != null);
            PermissionImpl          = EDispatcherPermission.Rescinded;
            AIPermissionImpl        = false;
            Run8                    = run8;
            SyncContext             = SynchronizationContext.Current;
            PingTimer               = new Timer(PingTimerTick, null, 5000, 5000);
            ClearExpiredTrainsTimer = new Timer(ClearExpiredTrainsTick, null, 0, 1000);
            Trains                  = new ObservableCollection <Train>();
            Regions regions = (Regions)Application.LoadComponent(new Uri("/iecc8;component/Region/Regions.xaml", UriKind.Relative));

            Schema.Region region = null;
            foreach (Schema.Region i in regions)
            {
                foreach (RegionEntry j in i.SubAreas)
                {
                    if (j.ID == regionID)
                    {
                        region = i;
                        break;
                    }
                }
            }
            if (region == null)
            {
                throw new UnrecognizedRegionException();
            }
            Region = new Region(region, this);
        }
Пример #2
0
        /// <summary>
        /// Constructs the region.
        /// </summary>
        /// <param name="data">The data to use to build the region.</param>
        /// <param name="world">The world in which this region will exist.</param>
        public Region(Schema.Region data, World world)
        {
            SortedList <ushort, Schema.SubArea> subData = new SortedList <ushort, Schema.SubArea>();

            foreach (RegionEntry i in data.SubAreas)
            {
                subData[i.ID] = (Schema.SubArea)Application.LoadComponent(new Uri("/iecc8;component/Region/" + data.Name + "/" + i.Name + ".xaml", UriKind.Relative));
            }
            SortedList <ushort, SubArea> subs = new SortedList <ushort, SubArea>();

            foreach (RegionEntry i in data.SubAreas)
            {
                subs[i.ID] = new SubArea(subData[i.ID], i.ID, world);
            }
            SubAreas = new ReadOnlyDictionary <ushort, SubArea>(subs);
            foreach (KeyValuePair <ushort, SubArea> i in subs)
            {
                i.Value.InitLinks(subData[i.Key], this);
            }
        }