Example #1
0
        public override void OnImportsSatisfied()
        {
            base.OnImportsSatisfied();

            EventAggregator.GetEvent <EntityImportedEvent <CustomRegion> >().Subscribe(OnCustomRegionImported);
            EventAggregator.GetEvent <GeographicalContextChangeEvent>().Subscribe(empty => RefreshCollection());

            RegionImporter.Imported +=
                delegate
            {
                EventAggregator.GetEvent <ResumeNormalProcessingEvent>().Publish(Empty.Value);
            };

            RegionImporter.Importing +=
                delegate
            {
                EventAggregator.GetEvent <PleaseStandByEvent>().Publish(RegionImporter.CreatePleaseStandByEventPayload());
            };

            EventAggregator.GetEvent <SimpleImportCompletedEvent>().Subscribe(Requery);

            EventAggregator.GetEvent <ContextAppliedEvent>().Subscribe(s =>
            {
                if (s.Equals("Saved") && IsActive)
                {
                    OnLoad();
                }
            });
        }
        public static HeightData ImportHeightmap(string filepath, HeightmapType type)
        {
            ushort[,] hms = RegionImporter.GetHeightmap(filepath, type);
            HeightData asc = new HeightData(512, 512, filepath);

            for (int x = 0; x < 512; x++)
            {
                for (int z = 0; z < 512; z++)
                {
                    asc.SetHeight(x, z, hms[x, 511 - z]);
                }
            }
            asc.filename     = Path.GetFileNameWithoutExtension(filepath);
            asc.cellSize     = 1;
            asc.nodata_value = -9999;
            asc.RecalculateValues(false);
            asc.lowPoint  = 0;
            asc.highPoint = 255;
            asc.isValid   = true;
            ConsoleOutput.WriteLine("Lowest: " + asc.lowestValue);
            ConsoleOutput.WriteLine("Hightest: " + asc.highestValue);
            asc.lowestValue  = 0;
            asc.highestValue = 255;
            return(asc);
        }
Example #3
0
        public override void ProcessRegion(World world, MCUtils.Region reg, int rx, int rz, int pass)
        {
            ConsoleOutput.WriteLine($"Starting merge for region [{rx},{rz}] ...");
            int scale = chunkMode ? 32 : 512;

            bool[,] fraction;
            lock (mask)
            {
                fraction = GetSubMask((rx - upperLeftCornerRegionX) * scale, (rz - upperLeftCornerRegionZ) * scale, scale, scale);
            }
            string otherRegionName = otherRegionPrefix + $"r.{rx}.{rz}.mca";
            var    filename        = Path.Combine(otherRegionFolder, otherRegionName);

            if (File.Exists(filename))
            {
                var otherRegion  = RegionImporter.OpenRegionFile(filename);
                var merger       = new RegionMerger(otherRegion, reg, fraction);
                var mergedRegion = merger.Merge();
                for (int x = 0; x < 32; x++)
                {
                    for (int z = 0; z < 32; z++)
                    {
                        reg.chunks[x, z] = mergedRegion.chunks[x, z];
                    }
                }
            }
            else
            {
                ConsoleOutput.WriteWarning($"Merge region '{otherRegionName}' was not found, no merging was done");
            }
        }
Example #4
0
        private void _initData()
        {
            RegionImporter.Imported +=
                delegate { EventAggregator.GetEvent <ResumeNormalProcessingEvent>().Publish(Empty.Value); };

            RegionImporter.Importing +=
                delegate
            {
                EventAggregator.GetEvent <PleaseStandByEvent>().Publish(RegionImporter.CreatePleaseStandByEventPayload());
            };

            // RegionViewModels.CollectionChanged += (o, e) => RegionCollectionChanged(this, e);
        }
Example #5
0
        public void OnImportsSatisfied()
        {
            RegionImporter.Imported += delegate
            {
                EventAggregator.GetEvent <ResumeNormalProcessingEvent>().Publish(Empty.Value);
            };

            RegionImporter.Importing += delegate
            {
                EventAggregator.GetEvent <PleaseStandByEvent>().Publish(RegionImporter.CreatePleaseStandByEventPayload());
            };

            ImportDataFileCommand.RaiseCanExecuteChanged();
        }
Example #6
0
        public OverviewmapExporter(string regionPath, bool mcMapStyle)
        {
            if (Path.GetExtension(regionPath).ToLower() != ".mca")
            {
                throw new System.ArgumentException("The file '" + regionPath + "' is not a .mca file");
            }
            var data = MinecraftRegionImporter.ImportHeightmap(regionPath, HeightmapType.SolidBlocks);

            map = RegionImporter.GetSurfaceMap(regionPath, HeightmapType.SolidBlocks, mcMapStyle);
            if (!mcMapStyle)
            {
                map = GenerateShadedMap(data, map);
            }
        }
Example #7
0
 //todo bad code alert fix it
 private void ExecuteOpenFileDialog()
 {
     RegionImporter.Execute();
 }
 /// <summary>
 /// Called when a part's imports have been satisfied and it is safe to use.
 /// </summary>
 public void OnImportsSatisfied()
 {
     ImportHospitalsCommand = new DelegateCommand(() => HospitalImporter.Execute());
     ImportRegionsCommand   = new DelegateCommand(() => RegionImporter.Execute());
 }
Example #9
0
 private void OnRegionImport()
 {
     RegionImporter.Execute();
     OnLoad();
 }