コード例 #1
0
ファイル: HypercubeMap.cs プロジェクト: Herocane/Hypercube
        /// <summary>
        /// Creates a new blank map.
        /// </summary>
        public HypercubeMap(Hypercube Core, string Filename, string MapName, short SizeX, short SizeY, short SizeZ)
        {
            ServerCore = Core;
            Map        = new ClassicWorld(SizeX, SizeZ, SizeY);

            HCSettings          = new HypercubeMetadata(); // -- Hypercube specific settings, woo.
            HCSettings.Building = true;                    // -- Enable building and physics by default.
            HCSettings.Physics  = true;
            HCSettings.History  = new int[Map.BlockData.Length];

            foreach (Rank r in Core.Rankholder.Ranks)   // -- Allow all ranks to access this map by default.
            {
                JoinRanks.Add(r);
                BuildRanks.Add(r);
                ShowRanks.Add(r);
            }

            Map.MetadataParsers.Add("Hypercube", HCSettings); // -- Add the parser so it will save with the map :)

            Map.MapName = MapName;
            Path        = Filename;

            Map.GeneratingSoftware = "Hypercube";
            Map.GeneratorName      = "Blank";
            Map.CreatingService    = "Classicube";
            Map.CreatingUsername   = "******";

            var myRef = (CPEMetadata)Map.MetadataParsers["CPE"];

            if (myRef.CustomBlocksFallback == null)
            {
                myRef.CustomBlocksLevel    = 1;
                myRef.CustomBlocksVersion  = 1;
                myRef.CustomBlocksFallback = new byte[256];

                for (int i = 50; i < 66; i++)
                {
                    myRef.CustomBlocksFallback[i] = (byte)Core.Blockholder.GetBlock(i).CPEReplace;
                }

                Map.MetadataParsers["CPE"] = myRef;
            }

            Map.Save(Path);

            LastClient = DateTime.UtcNow;
            Clients    = new List <NetworkClient>();
            Entities   = new List <Entity>();

            ClientThread = new Thread(MapMain);
            ClientThread.Start();

            EntityThread = new Thread(MapEntities);
            EntityThread.Start();
        }
コード例 #2
0
ファイル: HypercubeMap.cs プロジェクト: Herocane/Hypercube
        /// <summary>
        /// Reloads a map that was unloaded for memory conservation.
        /// </summary>
        public void LoadMap()
        {
            Map        = new ClassicWorld(Path);
            HCSettings = new HypercubeMetadata();             // -- Create our HC Specific settings
            Map.MetadataParsers.Add("Hypercube", HCSettings); // -- Register it with the map loader
            Map.Load();                                       // -- Load the map

            if (HCSettings.History == null)
            {
                HCSettings.History = new int[Map.BlockData.Length];
            }

            Path   = Path.Replace(".cwu", ".cw");
            Loaded = true;
            System.IO.File.Move(Path + "u", Path);
        }
コード例 #3
0
ファイル: HypercubeMap.cs プロジェクト: Herocane/Hypercube
        /// <summary>
        /// Loads a pre-existing map
        /// </summary>
        /// <param name="Filename">The path to the map.</param>
        public HypercubeMap(Hypercube Core, string Filename)
        {
            ServerCore = Core;
            Path       = Filename;

            Map        = new ClassicWorld(Filename);
            HCSettings = new HypercubeMetadata();             // -- Create our HC Specific settings
            Map.MetadataParsers.Add("Hypercube", HCSettings); // -- Register it with the map loader
            Map.Load();                                       // -- Load the map

            // -- Creates HC Metadata if it does not exist.
            if (HCSettings.BuildRanks == null)
            {
                foreach (Rank r in Core.Rankholder.Ranks)  // -- Allow all ranks to access this map by default.
                {
                    BuildRanks.Add(r);
                }
            }

            if (HCSettings.ShowRanks == null)
            {
                foreach (Rank r in Core.Rankholder.Ranks)  // -- Allow all ranks to access this map by default.
                {
                    ShowRanks.Add(r);
                }
            }

            if (HCSettings.JoinRanks == null)
            {
                foreach (Rank r in Core.Rankholder.Ranks)  // -- Allow all ranks to access this map by default.
                {
                    JoinRanks.Add(r);
                }

                HCSettings.Building = true;
                HCSettings.Physics  = true;
            }

            HCSettings.Building = true;
            HCSettings.Physics  = true;

            if (HCSettings.History == null)
            {
                HCSettings.History = new int[Map.BlockData.Length];
            }

            LastClient = DateTime.UtcNow;
            Clients    = new List <NetworkClient>();
            Entities   = new List <Entity>();

            // -- Set CPE Information...
            var myRef = (CPEMetadata)Map.MetadataParsers["CPE"];

            if (myRef.CustomBlocksFallback == null)
            {
                myRef.CustomBlocksLevel    = 1;
                myRef.CustomBlocksVersion  = 1;
                myRef.CustomBlocksFallback = new byte[256];

                for (int i = 50; i < 66; i++)
                {
                    myRef.CustomBlocksFallback[i] = (byte)Core.Blockholder.GetBlock(i).CPEReplace;
                }

                Map.MetadataParsers["CPE"] = myRef;
            }

            // -- Memory Conservation:
            if (Path.Substring(Path.Length - 1, 1) == "u")   // -- Unloads anything with a ".cwu" file extension. (ClassicWorld unloaded)
            {
                Map.BlockData      = null;
                HCSettings.History = null;
                GC.Collect();
                Loaded = false;
                var testing = (HypercubeMetadata)Map.MetadataParsers["Hypercube"];
                testing.History = null;
            }
        }
コード例 #4
0
        protected override void OnActivateScene(object parameter)
        {
            app.RenderMouse = false;

            BurntimeClassic classic = app as BurntimeClassic;
            ClassicWorld    world   = classic.Game.World;

            maggots = 0;
            rats    = 0;
            snakes  = 0;
            meat    = 0;

            fighter    = 0;
            doctor     = 0;
            technician = 0;

            locations        = 0;
            cities           = 0;
            controlledCities = 0;

            for (int i = 0; i < world.Locations.Count; i++)
            {
                Location l = world.Locations[i];
                // add controlled city
                if (l.IsCity)
                {
                    bool controlled = true;
                    foreach (Location n in l.Neighbors)
                    {
                        if (!n.IsCity && n.Player != world.ActivePlayerObj)
                        {
                            controlled = false;
                            break;
                        }
                    }

                    cities++;
                    if (controlled)
                    {
                        controlledCities++;
                    }
                }

                // add player camp info to stats
                if (l.Player == world.ActivePlayerObj)
                {
                    locations++;

                    for (int j = 0; j < l.Rooms.Count; j++)
                    {
                        maggots += l.Rooms[j].Items.GetCount(classic.Game.ItemTypes["item_maggots"]);
                        rats    += l.Rooms[j].Items.GetCount(classic.Game.ItemTypes["item_rats"]);
                        snakes  += l.Rooms[j].Items.GetCount(classic.Game.ItemTypes["item_snake"]);
                        meat    += l.Rooms[j].Items.GetCount(classic.Game.ItemTypes["item_meat"]);
                    }

                    for (int j = 0; j < l.Characters.Count; j++)
                    {
                        if (l.Characters[j].Player == world.ActivePlayerObj)
                        {
                            switch (l.Characters[j].Class)
                            {
                            case CharClass.Mercenary: fighter++; break;

                            case CharClass.Doctor: doctor++; break;

                            case CharClass.Technician: technician++; break;
                            }
                        }
                    }
                }
            }

            for (int i = 0; i < world.ActivePlayerObj.Group.Count; i++)
            {
                switch (world.ActivePlayerObj.Group[i].Class)
                {
                case CharClass.Mercenary: fighter++; break;

                case CharClass.Doctor: doctor++; break;

                case CharClass.Technician: technician++; break;
                }
            }
        }