예제 #1
0
파일: Main.cs 프로젝트: sergeybe/geoloader
        private void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
        {
            var countryId = FindCountryIdByName(countries, ddlCountry.SelectedItem.ToString());

            ddlRegion.Items.Clear();
            if (countryId == -1)
            {
                var dialog = new OpenFileDialog {
                    Title = "Выберите wpt файл", Filter = "wpt files (*.wpt)|*.wpt", RestoreDirectory = true
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var wptLister = new WptListLoader();
                    caches             = wptLister.List(dialog.FileName);
                    wptName            = Path.GetFileNameWithoutExtension(dialog.FileName);
                    btnSaveGpx.Enabled = true;
                    btnSavePoi.Enabled = true;
                    //btnSave_Click(sender, e);
                }
            }
            else
            {
                var loader = new RegionLoader();
                regions = loader.List(countryId);
                foreach (var region in regions)
                {
                    ddlRegion.Items.Add(region.Name);
                }
            }
        }
예제 #2
0
 void CleanBannedRegions(Client player, string[] cmd, int iarg)
 {
     if (player.Admin(Permissions.Region) == false)
     {
         throw new ErrorException("Disabled");
     }
     RegionLoader.CleanBanned(player.Session.World.Regions);
 }
예제 #3
0
 public UserControlSubscribers()
 {
     InitializeComponent();
     Region_cmbBox.ItemsSource = RegionLoader.Load();
     if (UserSingleton.GetInstance.IsAuthenticated)
     {
         CanOnlyDisconnect();
     }
 }
예제 #4
0
        void Delete(Client player, string[] cmd, int iarg)
        {
            if (player.Admin() == false)
            {
                throw new ErrorException("Disabled");
            }
            WorldRegion region = player.Session.CurrentRegion;

            if (region == null)
            {
                throw new ErrorException("No region here");
            }

            if (cmd.Length <= iarg)
            {
                throw new ShowHelpException(); //Need more arguments
            }
            RegionList regions = player.Session.World.Regions;

            string subdel = cmd [iarg].ToLowerInvariant();

            switch (subdel)
            {
            case "single":
                DeleteSingle(region, regions);
                player.TellSystem(Chat.Purple, region.Name + " removed");
                player.Session.CurrentRegion = null;
                break;

            case "recursive":
                DeleteRecursive(region);
                player.TellSystem(Chat.Purple, region.Name + " and subregions removed");
                region.Deleted = true;
                player.Session.CurrentRegion = null;
                break;

            case "subonly":
                DeleteSubregions(region);
                player.TellSystem(Chat.Purple, "Subregions of " + region.Name + " removed");
                break;

            default:
                throw new ShowHelpException();
            }
            RegionLoader.Save(regions);

            //Update all players regions
            foreach (var p in PlayerList.List)
            {
                RegionCrossing.SetRegion(p.Session);
            }

            ScoreboardRegionManager.UpdateAllPlayersRegion();
        }
예제 #5
0
        public VanillaWorld(string name)
        {
            this.ServerName = name;
            this.Endpoint   = GetPortFromProperties(name);
            Commands        = new VanillaWorldCommands();

            string regionPath = Path.Combine(name, "regions.json");

            this.Regions = RegionLoader.Load(regionPath);

            stopBackend = new Timer(StopBackend, null, -1, -1);
        }
예제 #6
0
        public void Convert(string levelPath, string savePath, int dimension)
        {
            MainForm form = MainForm.Form;

            this.Dimension = dimension;
            string regionPath = this.GetRegionPath(dimension, levelPath);

            levelPath = Path.Combine(levelPath, "level.dat");
            if (!File.Exists(levelPath))
            {
                form.Log($"ファイル {levelPath} が見つかりませんでした");
                form.IsExcecuting = false;
                return;
            }
            if (!Directory.Exists(regionPath))
            {
                form.Log($"パス {regionPath} が見つかりませんでした");
                form.IsExcecuting = false;
                return;
            }
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }

            File.Copy(levelPath, Path.Combine(savePath, "level.dat"), true);
            this.LoadLevelData(savePath);
            this.LevelData.Load();
            this.LevelData.SetWorldName(form.GetWorldName());
            this.LevelData.SetWorldSpawn(dimension);
            this.LevelData.Save();


            string[] files = Directory.GetFiles(regionPath);

            form.SetProgressValue(0);
            form.SetMaxProgress(files.Length * 1024);

            if (!Directory.Exists(Path.Combine(savePath, "region")))
            {
                Directory.CreateDirectory(Path.Combine(savePath, "region"));
            }

            for (int i = 0; i < files.Length; ++i)
            {
                string name     = Path.GetFileName(files[i]);
                string copyFile = Path.Combine(savePath, "region", name);
                File.Copy(files[i], copyFile, true);
                RegionLoader b = new RegionLoader(this, copyFile);
                b.Convert();
            }
        }
예제 #7
0
    // initializes objects, called after Load settings and before update.
    public override void Init()
    {
        base.Init();
        //Debug.Log("Init");

        //Debug.Log("Size: " + System.Runtime.InteropServices.Marshal.SizeOf(typeof(SaveStructure)));

        GenerationQueue = new ColumnGenerationQueue(1);
        GenerationQueue.Start(Gpu_Acceloration);

        Regions = new RegionLoader(Directory.GetCurrentDirectory());

        //Region reg = Regions.CreateRegion(new Vector3Int(0, 0, 0));
        //reg.CreateColumn(new Vector3Int(0, 0, 0));
        //CommandInput.LoadCommands(this); // add to load custom console commands.
    }
예제 #8
0
    public static void SpawnRegion(RegionConfig region, TileManager target)
    {
        TileManager instance = Instantiate(region.TileSet).gameObject.GetComponent <TileManager>();

        target.AppendGrid(instance);

        //spawn the units and shit
        UnitSpawnManager spawner = instance.GetComponent <UnitSpawnManager>();


        List <UnitSpawnGroupConfig> groups = RegionLoader.GetGroupsForPower(region);

        if (region.SpawnSquad)
        {
            groups.Add(SquadManager.MakeSquadGroup());
        }

        // MDebug.Log("Spawn Groups " + groups.Count);
        spawner.SpawnGroups(groups);
    }
예제 #9
0
    void SpawnGroup(UnitSpawnGroupConfig group, List <int> spawnerIDs)
    {
        if (group == null)
        {
            Debug.LogWarning("No Group");
            return;
        }

        globalGroupCounter++;

        List <UnitSpawner> spawnersForGroup = GetSpawnerForGroup(spawnerIDs, group);

        if (spawnersForGroup == null || spawnersForGroup.Count == 0)
        {
            Debug.LogWarning("NO SPAWNERS FOR GROUP");
            return;
        }

        List <WeightedUnit> unitConfigs = RegionLoader.GetUnitsForGroupPower(group);

        if (unitConfigs.Count > spawnersForGroup.Count)
        {
            Debug.LogWarning("Not enough spawners for my group :(   spawners:" + spawnersForGroup.Count + "  units:" + unitConfigs.Count);
            //  return;
        }

        // MDebug.Log(spawnersForGroup.Count+ "   "+unitConfigs.Count);
        while (spawnersForGroup.Count > 0 && unitConfigs.Count > 0)
        {
            // MDebug.Log("SPAWN");
            WeightedUnit unit    = unitConfigs.GetRandom();
            UnitSpawner  spawner = spawnersForGroup.GetRandom();

            unitConfigs.Remove(unit);
            spawnersForGroup.Remove(spawner);

            spawner.SpawnUnit(unit.UnitConfig, unit.TurnTimeOnSpawn, globalGroupCounter, unit.HidePlayerUnit);
        }
    }
예제 #10
0
		public void Run()
		{
			MCUtilsConsole.WriteLine("Enter path to region file 1:");
			string r1 = GetFilePath(false);
			if (r1 == null) return;
			MCUtilsConsole.WriteLine("Enter path to region file 2:");
			string r2 = GetFilePath(false);
			if (r2 == null) return;
			MCUtilsConsole.WriteLine("Enter path to map image:");
			string map = GetFilePath(false);
			if (map == null) return;
			MCUtilsConsole.WriteLine("Enter path to output file:");
			string savepath = GetFilePath(true);
			MCUtilsConsole.WriteLine("Starting merge...");
			Region region1;
			Region region2;
			try
			{
				region1 = RegionLoader.LoadRegion(r1);
				region2 = RegionLoader.LoadRegion(r2);
			}
			catch (Exception e)
			{
				MCUtilsConsole.WriteError("Failed to open region file(s):");
				MCUtilsConsole.WriteError(e.ToString());
				return;
			}
			Bitmap mask = new Bitmap(map);
			var merger = new RegionMerger(region1, region2, mask);
			MCUtilsConsole.WriteLine("Merging ...");
			var mergedRegion = merger.Merge();
			MCUtilsConsole.WriteLine("Writing file...");
			FileStream stream = new FileStream(savepath, FileMode.Create);
			RegionSerializer.WriteRegionToStream(mergedRegion, stream, Version.DefaultVersion);
			stream.Close();
			MCUtilsConsole.WriteLine("Done");
		}
예제 #11
0
        static void DeleteSingle(WorldRegion r, RegionList regions)
        {
            lock (regions)
            {
                var parent = WorldRegion.GetParentList(regions, r);
                if (parent == null)
                {
                    return;
                }

                //Move all subregions to parent list
                if (r.SubRegions != null)
                {
                    foreach (var s in r.SubRegions)
                    {
                        parent.Add(s);
                    }
                }

                r.Residents.Clear();
                r.SubRegions.Clear();
            }
            RegionLoader.Save(regions);
        }
예제 #12
0
        internal static WorldRegion Create(Dimensions dimension, CoordDouble start, CoordDouble end, string regionName, Client player, string resident, RegionList regions)
        {
            if (regions == null)
            {
                throw new ErrorException("No regions in this world");
            }

            WorldRegion w = new WorldRegion(dimension, start, end, regionName);

            w.Residents.Add(resident);
            w.Type = "protected";

            lock (regions)
            {
                //Test for overlapping regions
                WorldRegion existing = RegionCrossing.GetBaseRegion(regions.List, w, dimension);
                if (existing == null)
                {
                    //New Top level region
                    regions.List.Add(w);
                    RegionLoader.Save(regions);
                    return(w);
                }

                //Make sure you already are a part of the region
                if (existing.ResidentPermissions(player) == false)
                {
                    throw new ErrorException("You can't set a subregion unless you are a resident in the parent region.");
                }

                //All inside, make subregion
                if (existing.Cover(w))
                {
                    if (existing.SubRegions == null)
                    {
                        existing.SubRegions = new List <WorldRegion>();
                    }
                    existing.SubRegions.Add(w);
                    RegionLoader.Save(regions);
                    return(w);
                }
                //Need to make a wrapping region

                //Only admins may create wrapping regions
                if (player != null && player.Admin() == false)
                {
                    throw new ErrorException("New region must be fully inside " + existing);
                }

                //New region covering several old ones?
                var parentList = WorldRegion.GetParentList(regions, existing);
                if (parentList == null)
                {
                    throw new ErrorException("Parent list not found for " + existing);
                }

                //regions to move inside the new one
                var moving = new List <WorldRegion>();

                //Determine if we are breaking any boundaries
                bool breaking = false;
                foreach (var s in parentList)
                {
                    if (w.Cover(s))
                    {
                        moving.Add(s);
                    }
                    else if (w.Overlap(s))   //Overlap but not cover completely
                    {
                        player.TellSystem(Chat.Red, "Breaking boundaries: " + s);
                        breaking = true;
                    }
                }
                if (breaking)
                {
                    player.TellSystem(Chat.Red, "Failed creating: " + w);
                    player.TellSystem(Chat.Red, "Aborting: Broke region boundaries");
                    return(null);
                }

                //Move subregions into new region and remove from parentlist
                w.SubRegions = moving;
                foreach (var s in moving)
                {
                    player.TellSystem(Chat.Aqua, "New subregion: " + s);
                    parentList.Remove(s);
                }
                parentList.Add(w);
                RegionLoader.Save(regions);
                return(w);
            }
        }
예제 #13
0
 protected void SetSpawnConfigs(RegionConfigDataBase Region)
 {
     configsToSpawn = RegionLoader.RegionsToSpawn(Region);
 }
예제 #14
0
 public void LoadRegions()
 {
     Regions = RegionLoader.Load("main/regions.json");
 }
예제 #15
0
 void CleanBannedRegions(Client player, string[] cmd, int iarg)
 {
     RegionLoader.CleanBanned(player.Session.World.Regions);
 }