示例#1
0
        private Expanse[] DeserializeExpanses(byte[] bytes, int startIndex)
        {
            int offset = 4;

            Expanse[] expanses = new Expanse[BitConverter.ToInt32(bytes, startIndex + offset)];
            offset += 4;

            for (int i = 0; i < expanses.Length; i++)
            {
                expanses[i] = new Expanse(bytes, startIndex + offset);
                offset     += BitConverter.ToInt32(bytes, startIndex + offset);
            }

            return(expanses);
        }
示例#2
0
        protected CelestialBody(MapGenerator.Containers.Container container)
        {
            ID       = container.ID;
            Type     = container.Type;
            Position = container.GlobalPosition;
            Radius   = container.Radius;

            if (container.Expanses != null)
            {
                Expanses = new Expanse[container.Expanses.Length];
                for (int i = 0; i < Expanses.Length; i++)
                {
                    Expanses[i] = new Expanse(container.Expanses[i]);
                }
            }
            else
            {
                Expanses = new Expanse[0];
            }
            if (container.Galaxies != null)
            {
                Galaxies = new Galaxy[container.Galaxies.Length];
                for (int i = 0; i < Galaxies.Length; i++)
                {
                    Galaxies[i] = new Galaxy(container.Galaxies[i]);
                }
            }
            else
            {
                Galaxies = new Galaxy[0];
            }
            if (container.Sectors != null)
            {
                Sectors = new Sector[container.Sectors.Length];
                for (int i = 0; i < Sectors.Length; i++)
                {
                    Sectors[i] = new Sector(container.Sectors[i]);
                }
            }
            else
            {
                Sectors = new Sector[0];
            }
            if (container.SolarSystems != null)
            {
                SolarSystems = new SolarSystem[container.SolarSystems.Length];
                for (int i = 0; i < SolarSystems.Length; i++)
                {
                    SolarSystems[i] = new SolarSystem(container.SolarSystems[i]);
                }
            }
            else
            {
                SolarSystems = new SolarSystem[0];
            }
            if (container.Stars != null)
            {
                Stars = new Star[container.Stars.Length];
                for (int i = 0; i < Stars.Length; i++)
                {
                    Stars[i] = new Star(container.Stars[i]);
                }
            }
            else
            {
                Stars = new Star[0];
            }
            if (container.Planets != null)
            {
                Planets = new Planet[container.Planets.Length];
                for (int i = 0; i < Planets.Length; i++)
                {
                    Planets[i] = new Planet(container.Planets[i]);
                }
            }
            else
            {
                Planets = new Planet[0];
            }
        }