Example #1
0
        public override void Execute(HcMap map, string[] args)
        {
            var sw = new Stopwatch();

            sw.Start();

            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;
            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            for (short x = 0; x < mapSize.X; x++)
            {
                for (short y = 0; y < mapSize.Y; y++)
                {
                    for (short z = 0; z < (mapSize.Z / 2); z++)
                    {
                        data[GetBlockCoords(x, y, z)] = z == (mapSize.Z / 2) - 1 ? _grassBlock : _dirtBlock;
                    }
                }
            }

            map.SetMap(data);

            sw.Stop();
            Chat.SendMapChat($"&cMap created in {sw.Elapsed.TotalSeconds}s.", 0, map);
            map.Resend();
        }
Example #2
0
        public override void Execute(HcMap map, string[] args)
        {
            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;
            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            map.SetMap(data);
            map.Resend();
        }
Example #3
0
File: Main.cs Project: umby24/ZBase
        private static void LoadMaps()
        {
            if (!Directory.Exists("Maps"))
            {
                Directory.CreateDirectory("Maps");
            }

            if (!Directory.Exists("D3Maps"))
            {
                Directory.CreateDirectory("D3Maps");
            }

            HcMap.Maps = new Dictionary <string, HcMap>();
            LoadD3Maps();
            // -- Load the default map
            string defaultPath = Path.Combine("Maps", Configuration.Settings.General.DefaultMap);

            if (!File.Exists(defaultPath) && !File.Exists(defaultPath + "u"))
            {
                HcMap.DefaultMap = new HcMap(defaultPath, "default", new Vector3S(128, 128, 128));
                HcMap.Maps.Add("default", HcMap.DefaultMap);
                Logger.Log(LogType.Info, "Default map created");
            }
            else
            {
                if (!File.Exists(defaultPath))
                {
                    defaultPath += "u";
                }

                HcMap.DefaultMap = new HcMap(defaultPath);
                HcMap.Maps.Add(HcMap.DefaultMap.MapProvider.MapName, HcMap.DefaultMap);
            }

            // -- load all other maps (if they exist)
            string[] maps = Directory.GetFiles("Maps", "*.cw?");

            foreach (string map in maps)
            {
                if (map == defaultPath)
                {
                    continue;
                }

                var newMap = new HcMap(map);

                if (HcMap.Maps.ContainsKey(newMap.MapProvider.MapName))
                {
                    Logger.Log(LogType.Error, $"Could not load {map}, a map with the same name is already loaded.");
                    continue;
                }

                HcMap.Maps.Add(newMap.MapProvider.MapName, newMap);
            }
        }
Example #4
0
File: Chat.cs Project: umby24/ZBase
        public static void SendMapChat(string message, sbyte messageType, HcMap map, bool log = false)
        {
            message = Text.CleanseString(message);
            message = EmoteReplace(message);
            map.InvokeMapChat(message);

            if (log)
            {
                Logger.Log(LogType.Chat, "[To Map " + map.MapProvider.MapName + "]: " + message);
            }
        }
Example #5
0
        public override void Execute(HcMap map, string[] args)
        {
            var sw = new Stopwatch();

            sw.Start();

            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;
            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            for (short ix = 0; ix < mapSize.X; ix++)
            {
                for (short iy = 0; iy < mapSize.Y; iy++)
                {
                    data[GetBlockCoords(ix, iy, 0)] = _whiteCloth;
                }
                //map.BlockChange(-1, (short) ix, (short) iy, 0, whiteBlock, airBlock, false, false, false, 1);
            }

            for (short ix = 0; ix < mapSize.X; ix++)
            {
                for (short iz = 0; iz < mapSize.Z / 2; iz++)
                {
                    data[GetBlockCoords(ix, 0, iz)]             = _whiteCloth;
                    data[GetBlockCoords(ix, mapSize.Y - 1, iz)] = _whiteCloth;
                    //      map.BlockChange(-1, (short) ix, 0, (short) iz, whiteBlock, airBlock, false, false, false, 1);
                    //      map.BlockChange(-1, (short) ix, (short) (map.CWMap.SizeY - 1), (short) iz, whiteBlock, airBlock,
                    //          false, false, false, 1);
                }
            }

            for (short iy = 0; iy < mapSize.Y; iy++)
            {
                for (short iz = 0; iz < mapSize.Z / 2; iz++)
                {
                    data[GetBlockCoords(0, iy, iz)]             = _whiteCloth;
                    data[GetBlockCoords(mapSize.X - 1, iy, iz)] = _whiteCloth;
                    //     map.BlockChange(-1, 0, (short) iy, (short) iz, whiteBlock, airBlock, false, false, false, 1);
                    //     map.BlockChange(-1, (short) (map.CWMap.SizeX - 1), (short) iy, (short) iz, whiteBlock, airBlock,
                    //         false, false, false, 1);
                }
            }

            map.SetMap(data);
            sw.Stop();
            Chat.SendMapChat($"&cMap created in {sw.Elapsed.TotalSeconds}s.", 0, map);
            map.Resend();
        }
Example #6
0
        public override void Execute(HcMap map, string[] args)
        {
            var sw = new Stopwatch();

            sw.Start();

            byte bedrockBlock = BlockManager.GetBlock("solid").Id;

            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;

            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            for (short ix = 0; ix < mapSize.X; ix++)
            {
                for (short iy = 0; iy < mapSize.Y; iy++)
                {
                    data[GetBlockCoords(ix, iy, 0)] = bedrockBlock;
                }
            }

            for (short ix = 0; ix < mapSize.X; ix++)
            {
                for (short iz = 0; iz < mapSize.Z / 2; iz++)
                {
                    data[GetBlockCoords(ix, 0, iz)]             = bedrockBlock;
                    data[GetBlockCoords(ix, mapSize.Y - 1, iz)] = bedrockBlock;
                }
            }

            for (short iy = 0; iy < mapSize.Y; iy++)
            {
                for (short iz = 0; iz < mapSize.Z / 2; iz++)
                {
                    data[GetBlockCoords(0, iy, iz)]             = bedrockBlock;
                    data[GetBlockCoords(mapSize.X - 1, iy, iz)] = bedrockBlock;
                }
            }

            map.SetMap(data);
            sw.Stop();
            Chat.SendMapChat($"&cMap created in {sw.Elapsed.TotalSeconds}s.", 0, map);
            map.Resend();
        }
Example #7
0
        public override void Execute(Client executingClient, string[] args)
        {
            if (args.Length != 0)
            {
                Chat.SendClientChat("§EIncorrect number of arguments.", 0, executingClient);
                return;
            }

            if (executingClient.ClientPlayer.CurrentMap == HcMap.DefaultMap)
            {
                Chat.SendClientChat("§EYou cannot delete the default map!", 0, executingClient);
                return;
            }

            HcMap toDelete = executingClient.ClientPlayer.CurrentMap;

            toDelete.Delete();
            Chat.SendClientChat("§SMap Deleted.", 0, executingClient);
        }
Example #8
0
        public override void Execute(Client executingClient, string[] args)
        {
            if (args.Length > 1 || args.Length == 0)
            {
                Chat.SendClientChat("§EIncorrect number of arguments.", 0, executingClient);
                return;
            }

            if (HcMap.Maps.ContainsKey(args[0]))   // -- Check if the map already exists.
            {
                executingClient.ClientPlayer.ChangeMap(HcMap.Maps[args[0]]);
                return;
            }

            var newMap = new HcMap(Path.Combine("Maps", args[0] + ".cw"), args[0], new Vector3S(128, 128, 128));

            HcMap.Maps.Add(newMap.MapProvider.MapName, newMap);

            executingClient.ClientPlayer.ChangeMap(newMap);
            Chat.SendClientChat("§SMap created.", 0, executingClient);
        }
Example #9
0
File: Main.cs Project: umby24/ZBase
        private static void LoadD3Maps()
        {
            string[] mapFolders = Directory.GetDirectories("D3Maps");

            foreach (string folder in mapFolders)
            {
                string[] files = Directory.GetFiles(folder);

                if (!files.Contains(Path.Combine(folder, "Data-Layer.gz")) && !files.Contains(Path.Combine(folder, "Config.txt")))
                {
                    continue;
                }

                var nMap = new HcMap(folder);
                if (HcMap.Maps.ContainsKey(nMap.MapProvider.MapName))
                {
                    Logger.Log(LogType.Error, $"Could not load D3Map {folder}, a map with the same name is already loaded.");
                    continue;
                }

                HcMap.Maps.Add(nMap.MapProvider.MapName, nMap);
            }
        }
Example #10
0
        public override void Execute(HcMap map, string[] args)
        {
            Stopwatch sw = Stopwatch.StartNew();

            Vector3S mapSize = map.GetSize();

            MapSize = mapSize;

            var data = new byte[mapSize.X * mapSize.Y * mapSize.Z];

            double    hmapSizeX  = Math.Ceiling(mapSize.X / (double)_mapScale);
            double    hmapSizeY  = Math.Ceiling(mapSize.Y / (double)_mapScale);
            const int fields     = 1;
            var       mBuildings = new Dictionary <double, int>();
            var       rng        = new Random();

            for (var x = 0; x < hmapSizeX + 2; x++)
            {
                for (var y = 0; y < hmapSizeY + 2; y++)
                {
                    double number = (x + y * hmapSizeX) * fields;
                    mBuildings[number] = rng.Next(0, mapSize.Z);
                }
            }

            for (var x = 0; x < hmapSizeX + 2; x++)
            {
                for (var y = 0; y < hmapSizeY + 2; y++)
                {
                    double number  = (x + y * hmapSizeX) * fields;
                    int    oheight = mBuildings[number];
                    int    height  = oheight * _priority;

                    var count = 0;
                    for (int ax = -_area; ax < _area; ax++)
                    {
                        for (int ay = -_area; ay < _area; ay++)
                        {
                            if (x + ax < 0 || x + ax >= hmapSizeX || y + ay < 0 || y + ay >= hmapSizeY)
                            {
                                continue;
                            }

                            double num     = x + ax + (y + ay) * hmapSizeX * fields;
                            int    bheight = mBuildings[num];
                            height = height + bheight;
                            count++;
                        }
                    }

                    height = (int)Math.Floor(((double)height / (count + _priority)));

                    int  bx  = x * _mapScale;
                    int  by  = y * _mapScale;
                    byte mat = BlockManager.GetBlock("Red Cloth").Id; //21; // -- material

                    for (var iz = 0; iz < height; iz++)
                    {
                        if (mat > 33)
                        {
                            mat = BlockManager.GetBlock("Red Cloth").Id;
                        }

                        for (var ix = 0; ix < _mapScale; ix++)
                        {
                            for (var iy = 0; iy < _mapScale; iy++)
                            {
                                if (bx + ix > mapSize.X || by + iy > mapSize.Y)
                                {
                                    continue;
                                }

                                int xCoord = bx + ix;
                                int yCoord = by + iy;

                                data[GetBlockCoords(xCoord, yCoord, iz)] = mat;
                            }
                        }

                        mat++;
                    }
                }
            }

            map.SetMap(data);

            sw.Stop();
            Chat.SendMapChat("&2Contructed \"Candy\" in &a" + sw.Elapsed.TotalSeconds + "&2s.", 0, map);
            map.Resend();
        }
Example #11
0
 public abstract void Execute(HcMap map, string[] args);