예제 #1
0
        /// <summary>
        ///     Setup of readonly fields and non-optional steps.
        /// </summary>
        private World(WorldInformation information, string worldDirectory, string chunkDirectory,
            IWorldGenerator generator)
        {
            positionsToActivate = new HashSet<(int x, int z)>();
            positionsActivating = new HashSet<(int, int)>();
            chunksToGenerate = new UniqueQueue<Chunk>();
            chunkGenerateTasks = new List<Task>(MaxGenerationTasks);
            chunksGenerating = new Dictionary<int, Chunk>(MaxGenerationTasks);
            positionsToLoad = new UniqueQueue<(int x, int z)>();
            chunkLoadingTasks = new List<Task<Chunk?>>(MaxLoadingTasks);
            positionsLoading = new Dictionary<int, (int x, int z)>(MaxLoadingTasks);
            activeChunks = new Dictionary<ValueTuple<int, int>, Chunk>();
            positionsToReleaseOnActivation = new HashSet<(int x, int z)>();
            chunksToSave = new UniqueQueue<Chunk>();
            chunkSavingTasks = new List<Task>(MaxSavingTasks);
            chunksSaving = new Dictionary<int, Chunk>(MaxSavingTasks);
            positionsSaving = new HashSet<(int x, int z)>(MaxSavingTasks);
            positionsActivatingThroughSaving = new HashSet<(int x, int z)>();

            Information = information;

            WorldDirectory = worldDirectory;
            ChunkDirectory = chunkDirectory;
            this.generator = generator;

            UpdateCounter = new UpdateCounter();

            Setup();
        }
예제 #2
0
 public TargetFinder(IWorldPosition origin, float range, IWorldGenerator worldGenerator, IEntityFactory <T> factory)
 {
     this.origin         = origin;
     this.range          = range;
     this.worldGenerator = worldGenerator;
     this.factory        = factory;
 }
예제 #3
0
 private static async System.Threading.Tasks.Task <GlobeRegion> CreateRegionAsync(Globe globe,
                                                                                  TerrainCell startCell,
                                                                                  IWorldGenerator globeGenerator,
                                                                                  ProgressStorageService progressStorageService)
 {
     return(await globeGenerator.GenerateRegionAsync(globe, startCell));
 }
예제 #4
0
    //TODO Попробовать сделать загрузку всех провинций параллельно.
    // Выглядит так, что каждый запуск метода не зависит от предыдущих запусков.
    /// <summary>
    /// Создание соседних провинций.
    /// </summary>
    /// <param name="playerCoords"> Текущии координаты игрока. </param>
    /// <param name="worldManager"> Менеджер мира. </param>
    /// <param name="worldGenerator"> Генератор мира, используемый для создания новых провинций. </param>
    /// <returns> Возвращает объект Task. </returns>
    private static async System.Threading.Tasks.Task CreateNeighborRegionsAsync(OffsetCoords playerCoords,
                                                                                IWorldManager worldManager,
                                                                                IWorldGenerator worldGenerator,
                                                                                ProgressStorageService progressStorageService)
    {
        for (var offsetX = -1; offsetX <= 1; offsetX++)
        {
            for (var offsetY = -1; offsetY <= 1; offsetY++)
            {
                if (offsetX == 0 && offsetY == 0)
                {
                    // Это нулевое смещение от текущего элемента.
                    // Пропускаем, т.к. текущий элемент уже есть.
                    continue;
                }

                var terrainX = playerCoords.X + offsetX;
                var terrainY = playerCoords.Y + offsetY;

                if (worldManager.Globe.Terrain.GetLowerBound(0) <= terrainX &&
                    terrainX <= worldManager.Globe.Terrain.GetUpperBound(0) &&
                    worldManager.Globe.Terrain[0].GetLowerBound(0) <= terrainY &&
                    terrainY <= worldManager.Globe.Terrain[0].GetUpperBound(0))
                {
                    var terrainCell = worldManager.Globe.Terrain[terrainX][terrainY];
                    if (!worldManager.Regions.ContainsKey(terrainCell))
                    {
                        var createdNeiborRegion = await CreateRegionAsync(worldManager.Globe, terrainCell, worldGenerator, progressStorageService);

                        worldManager.Regions[terrainCell] = createdNeiborRegion;
                    }
                }
            }
        }
    }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the World.
        /// </summary>
        /// <param name="worldSize">Size of World (measured by rows and columns).</param>
        public World(WorldSize worldSize, IWorldGenerator worldGenerator)
        {
            this.worldGenerator = worldGenerator;
            this.Size           = worldSize;

            NextGeneration();
        }
예제 #6
0
        public ChunkColumn GetChunk(ChunkCoordinates coordinates, IWorldGenerator generator)
        {
            var sw = Stopwatch.StartNew();

            sw.Stop();

            byte[] index = Combine(BitConverter.GetBytes(coordinates.X), BitConverter.GetBytes(coordinates.Z));
            if (Dimension == Dimension.Nether)
            {
                index = Combine(index, BitConverter.GetBytes(1));
            }

            byte[] versionKey = Combine(index, 0x76);
            sw.Start();
            byte[] version = Db.Get(versionKey);
            sw.Stop();

            ChunkColumn chunkColumn = null;

            if (version != null && version.First() >= 10)
            {
                chunkColumn = new ChunkColumn
                {
                    X = coordinates.X,
                    Z = coordinates.Z
                };

                byte[] chunkDataKey = Combine(index, new byte[] { 0x2f, 0 });
                for (byte y = 0; y < 16; y++)
                {
                    chunkDataKey[^ 1] = y;
예제 #7
0
        public void SetUp()
        {
            _systemContainer = Substitute.For <ISystemContainer>();

            _entityEngine = Substitute.For <IEntityEngine>();
            _systemContainer.EntityEngine.Returns(_entityEngine);
            _mutableEntities = new List <IEntity>();
            _entityEngine.MutableEntities.Returns(_mutableEntities);

            _mapSystem = Substitute.For <IMapSystem>();
            _systemContainer.MapSystem.Returns(_mapSystem);
            _mapCollection = new Atlas();
            _mapSystem.MapCollection.Returns(_mapCollection);

            _messageSystem = Substitute.For <IMessageSystem>();
            _systemContainer.MessageSystem.Returns(_messageSystem);
            _messages = new List <Message>();
            _messageSystem.AllMessages.Returns(_messages);

            _timeSystem = Substitute.For <ITimeSystem>();
            _systemContainer.TimeSystem.Returns(_timeSystem);
            _currentTime = 0;
            _timeSystem.CurrentTime.Returns(_currentTime);

            _worldGenerator = Substitute.For <IWorldGenerator>();

            _saveSystem = new SaveSystem(_systemContainer, _worldGenerator);
        }
 public GameController(IDisplayPresenter presenter, IQuitManager quitManager,
                       ISaveStateManager saveStateManager, IWorldGenerator worldGenerator)
 {
     _presenter        = presenter;
     _quitManager      = quitManager;
     _saveStateManager = saveStateManager;
     _worldGenerator   = worldGenerator;
 }
예제 #9
0
 /// <summary>
 /// Creates an in-memory world with a given world generator.
 /// </summary>
 public Level(IWorldGenerator generator) : this()
 {
     GeneratorName  = generator.GeneratorName;
     generator.Seed = RandomSeed;
     generator.Initialize(this);
     WorldGenerator = generator;
     Spawn          = WorldGenerator.SpawnPoint;
 }
예제 #10
0
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator
 /// and the specified working directory.
 /// </summary>
 public World(Level level, IWorldGenerator worldGenerator, string directory) : this(level, worldGenerator)
 {
     Directory = directory;
     if (!System.IO.Directory.Exists(directory))
     {
         System.IO.Directory.CreateDirectory(directory);
     }
 }
예제 #11
0
        public SPWorldProvider(Alex alex, IWorldGenerator worldGenerator)
        {
            Alex            = alex;
            OptionsProvider = alex.Services.GetService <IOptionsProvider>();

            _generator = worldGenerator;

            ThreadCancellationTokenSource = new CancellationTokenSource();
        }
예제 #12
0
        public MultiVerseInstance(string name, MultiVerseLevel level, IWorldGenerator generator, string generatorName)
        {
            Name          = name;
            Level         = level;
            Generator     = generator;
            GeneratorName = generatorName;

            Level.EventDispatcher.RegisterEvents(this);
        }
예제 #13
0
파일: World.cs 프로젝트: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator.
 /// </summary>
 public World(IWorldGenerator worldGenerator)
 {
     Name = "world";
     WorldGenerator = worldGenerator;
     Seed = DataUtility.Random.Next();
     Entities = new List<Entity>();
     Regions = new Dictionary<Vector3, Region>();
     worldGenerator.Initialize();
 }
예제 #14
0
        public Level(string name, IWorldGenerator worldGenerator)
        {
            Name           = name;
            WorldGenerator = worldGenerator;
            EntityManager  = new EntityManager();
            Players        = new ConcurrentDictionary <int, Player>();
            Entities       = new ConcurrentDictionary <int, Entity>();

            SpawnPoint = worldGenerator.GetSpawnPoint();
        }
예제 #15
0
        public void Generate(IWorldGenerator generator)
        {
            var e = chunkGenerate.Create();

            e.chunk = this;
            e.pos.Set(position);
            e.world     = this.world;
            e.generator = generator;
            e.Publish();
        }
예제 #16
0
파일: Region.cs 프로젝트: pdelvo/Craft.Net
 /// <summary>
 /// Creates a region from the given region file.
 /// </summary>
 public Region(Vector3 position, IWorldGenerator worldGenerator, string file) : this(position, worldGenerator)
 {
     if (File.Exists(file))
         regionFile = File.Open(file, FileMode.OpenOrCreate);
     else
     {
         regionFile = File.Open(file, FileMode.OpenOrCreate);
         CreateRegionHeader();
     }
 }
예제 #17
0
        public bool TryGet(Type type, out IWorldGenerator generator)
        {
            if (TypeMapping.TryGetValue(type, out string gen))
            {
                return(TryGet(gen, out generator));
            }

            generator = default;
            return(false);
        }
예제 #18
0
        public World(IWorldGenerator generator, int Dimension)
        {
            Init();

            this.DimensionID = Dimension;

            Difficulty          = Difficulty.Easy;
            this._chunkProvider = new ChunkProvider(generator);
            Worlds.Add(this, Dimension);
        }
예제 #19
0
        private TargetFinder <IEntity> GetTargetFinder(float range, IWorldPosition origin, IEntity[] targets)
        {
            IWorldGenerator generator      = Substitute.For <IWorldGenerator>();
            var             monsterFactory = Substitute.For <IEntityFactory <IEntity> >();

            monsterFactory.GetActiveEntities().Returns(targets);
            generator.MapLength.Returns(100);
            var targetFinder = new TargetFinder <IEntity>(origin, range, generator, monsterFactory);

            return(targetFinder);
        }
예제 #20
0
        private void Debug(IWorldGenerator generator)
        {
            Alex.IsMultiplayer = false;

            Alex.IsMouseVisible = false;

            generator.Initialize();
            var debugProvider = new SPWorldProvider(Alex, generator);

            Alex.LoadWorld(debugProvider, debugProvider.Network);
        }
예제 #21
0
파일: World.cs 프로젝트: keneo/Craft.Net
 public World(IWorldGenerator WorldGenerator)
 {
     EntityManager = new EntityManager(this);
     Name = "world";
     GameMode = GameMode.Creative;
     Difficulty = Difficulty.Peaceful;
     this.WorldGenerator = WorldGenerator;
     SpawnPoint = WorldGenerator.SpawnPoint;
     Seed = MinecraftServer.Random.Next();
     Regions = new Dictionary<Vector3, Region>();
 }
예제 #22
0
        //public event EventHandler<BlockChangedEventArgs> OnBlockChanged;

        public World(IWorldGenerator WorldGenerator)
        {
            //EntityManager = new EntityManager(this);
            Name                = "world";
            GameMode            = GameMode.Creative;
            Difficulty          = Difficulty.Peaceful;
            this.WorldGenerator = WorldGenerator;
            SpawnPoint          = WorldGenerator.SpawnPoint;
            //Seed = MinecraftServer.Random.Next();
            Regions = new Dictionary <Vector3, Region>();
        }
예제 #23
0
        public Server()
        {
            Config = new ServerConfig();
            JsonSerializerSettings settings = new JsonSerializerSettings();
            settings.MissingMemberHandling = MissingMemberHandling.Error;
            //Parse the config file. If the config isn't valid, throw an error.
            if (File.Exists("config.json"))
                try { Config = JsonConvert.DeserializeObject<ServerConfig>(File.ReadAllText("config.json"), settings); }
                catch (JsonException e) { Logger.Log("Config file is invalid!", LogType.Error); }
            else
                File.WriteAllText("config.json", JsonConvert.SerializeObject(Config, Formatting.Indented));

            //Parse the IP from the config file.
            if (!string.IsNullOrWhiteSpace(Config.IP))
            {
                if (!IPAddress.TryParse(Config.IP, out ServerIP))
                    ServerIP = IPAddress.Any;
            }
            else
                ServerIP = IPAddress.Any;
            ServerPort = Config.Port;
            MCServer = new MinecraftServer(new IPEndPoint(ServerIP, ServerPort));
            LogProvider.RegisterProvider(new MCServerLogger());

            //Choose the world generator based on the config file.
            if (string.IsNullOrWhiteSpace(Config.World))
                Config.World = "world";
            switch (Config.WorldType)
            {
                case LevelGenerator.Debug:
                    Generator = new DebugGenerator();
                    break;
                case LevelGenerator.Flatland:
                    Generator = new FlatlandGenerator();
                    break;
                default:
                    //No default generator yet!
                    Generator = new DebugGenerator();
                    break;
            }
            Level l = new Level(Generator, Config.World);
            l.GameMode = GameMode.Survival;
            if (Config.Gamemode == Gamemode.Creative) l.GameMode = GameMode.Creative;
            MCServer.AddLevel(l);

            MCServer.Settings.MotD = Config.MOTD;
            MCServer.Settings.MaxPlayers = Config.MaxPlayers;
            MCServer.Settings.OnlineMode = Config.Online;
            MCServer.Settings.Difficulty = Config.Difficulty;

            MCServer.PlayerLoggedIn += new EventHandler<Craft.Net.Server.Events.PlayerLogInEventArgs>(PlayerLoggedIn);
            MCServer.Start();
        }
예제 #24
0
 public Chunk(int offset, IWorldGenerator generator)
 {
     Blockstates = new byte[16, 256];
     Blocks      = new short[16, 256];
     for (var x = 0; x < 16; x++)
     {
         for (var y = 0; y < 256; y++)
         {
             Blocks[x, y] = generator.Generate(x + offset, y);
         }
     }
 }
예제 #25
0
파일: World.cs 프로젝트: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator
 /// and the specified working directory.
 /// </summary>
 public World(IWorldGenerator worldGenerator, string directory)
 {
     Name = "world";
     WorldGenerator = worldGenerator;
     Seed = DataUtility.Random.Next();
     Entities = new List<Entity>();
     Regions = new Dictionary<Vector3, Region>();
     Directory = directory;
     if (!System.IO.Directory.Exists(directory))
         System.IO.Directory.CreateDirectory(directory);
     worldGenerator.Initialize();
 }
예제 #26
0
        public bool TryGet(string name, out IWorldGenerator generator)
        {
            generator = default;

            if (!WorldGenerators.TryGetValue(name, out var factory))
            {
                return(false);
            }

            generator = factory();

            return(true);
        }
예제 #27
0
파일: Level.cs 프로젝트: pdelvo/Craft.Net
 public Level(IWorldGenerator worldGenerator, string directory)
 {
     Name = "world";
     if (!Directory.Exists(directory))
         Directory.CreateDirectory(directory);
     LevelDirectory = directory;
     WorldGenerator = worldGenerator;
     WorldGenerator.Initialize();
     SpawnPoint = WorldGenerator.SpawnPoint;
     World = new World(WorldGenerator, Path.Combine(directory, "region"));
     SaveInterval = TimeSpan.FromSeconds(5);
     saveTimer = new Timer(Save, null, (int)SaveInterval.TotalMilliseconds, Timeout.Infinite);
     tickTimer = new Timer(Tick, null, TickLength, TickLength);
 }
예제 #28
0
        public World(MinecraftServer server, string name, IWorldGenerator generator)
        {
            Server = server;
            Name   = name;

            Chunks         = new TimedCache <Chunk>("Chunk cache", TimeSpan.FromMinutes(5));
            PlayerEntities = new List <PlayerEntity>();
            Entities       = new List <BaseEntity>();

            Generator = generator;

            if (!Directory.Exists(GetDirectory()))
            {
                Directory.CreateDirectory(GetDirectory());

                Format = new WaterWorldFormat(this);

                // world does not exist - generate
                int a = (int)Math.Floor(initializationChunks / 2d);
                int i = 0;

                Stopwatch totalStopwatch = new();
                totalStopwatch.Start();

                for (int x = -a; x <= a; x++)
                {
                    for (int z = -a; z <= a; z++)
                    {
                        LoadChunk(x, z);
                        i++;
                    }
                }

                totalStopwatch.Stop();
                Logger.Info(
                    $"Finished generating world! ({i} chunks) Took {Math.Round(totalStopwatch.Elapsed.TotalMilliseconds, 2)}ms");

                Format.Save();
            }
            else
            {
                Format = new WaterWorldFormat(this);
                Format.Load();
            }

            WorldThread      = new Thread(Update);
            WorldThread.Name = "World update thread";
            WorldThread.Start();
        }
예제 #29
0
        public void IterationSetup()
        {
            var container = new ServiceContainer();

            // инстанцируем явно, чтобы обеспечить одинаковый рандом для всех запусков тестов.
            container.Register <IDice>(factory => new LinearDice(1), new PerContainerLifetime());
            container.Register(factory => BenchHelper.CreateSchemeLocator(), new PerContainerLifetime());
            container.Register <ISchemeService, SchemeService>(new PerContainerLifetime());
            container.Register <ISchemeServiceHandlerFactory, SchemeServiceHandlerFactory>(new PerContainerLifetime());

            // Для мира
            container.Register <IWorldGenerator, WorldGenerator>(new PerContainerLifetime());

            _generator = container.GetInstance <IWorldGenerator>();
        }
예제 #30
0
        public void LoadAnvilChunkLoadTest()
        {
            int width = 32;
            int depth = 32;

            string basePath = @"D:\Development\Worlds\KingsLanding";
            int    regionX  = 4;
            int    regionZ  = 25;
            //string basePath = @"D:\Temp\TestSave130";
            //int regionX = 0;
            //int regionZ = 0;

            int cx = (width * regionX) + 3;
            int cz = (depth * regionZ) + 0;

            ChunkCoordinates coordinates = new ChunkCoordinates(cx, cz);

            int rx = coordinates.X >> 5;
            int rz = coordinates.Z >> 5;

            Assert.AreEqual(regionX, rx);
            Assert.AreEqual(regionZ, rz);

            //IWorldGenerator generator = new AirWorldGenerator();
            IWorldGenerator generator = null;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            AnvilWorldProvider wp = new AnvilWorldProvider(basePath);

            int         iterations = 1000;
            ChunkColumn chunk      = null;

            for (int i = 0; i < iterations; i++)
            {
                chunk = wp.GetChunk(coordinates, basePath, generator);
            }

            long ticks = sw.ElapsedTicks;
            long ms    = sw.ElapsedMilliseconds;

            Console.WriteLine($"Read {iterations} chunk-columns in {ticks}ns ({ms}ms) at a rate of {ticks/iterations}ticks/col. 1ms={TimeSpan.TicksPerMillisecond}");

            Assert.NotNull(chunk);
            Assert.Less(ticks / iterations, 100);
        }
예제 #31
0
        public void given_origin_at_start_of_map_and_target_at_start_of_map_returns_Vector3_Right()
        {
            IWorldGenerator generator = Substitute.For <IWorldGenerator>();

            generator.MapLength.Returns(100);
            var worldDirection = new RepeatedWorldDirection(generator);
            var origin         = Substitute.For <IWorldPosition>();
            var target         = Substitute.For <IWorldPosition>();

            origin.TruePosition.Returns(new Vector3(5, 0, 0));
            target.TruePosition.Returns(new Vector3(25, 0, 0));

            var direction = worldDirection.GetDirection(origin, target).normalized;

            Assert.AreEqual(Vector3.right, direction);
        }
예제 #32
0
파일: Level.cs 프로젝트: aholmes/Craft.Net
 public Level(IWorldGenerator worldGenerator, string directory)
 {
     Difficulty = Difficulty.Normal;
     Name       = "world";
     if (!Directory.Exists(directory))
     {
         Directory.CreateDirectory(directory);
     }
     LevelDirectory = directory;
     WorldGenerator = worldGenerator;
     WorldGenerator.Initialize(this);
     SpawnPoint   = WorldGenerator.SpawnPoint;
     World        = new World(this, WorldGenerator, Path.Combine(directory, "region"));
     SaveInterval = TimeSpan.FromSeconds(5);
     saveTimer    = new Timer(Save, null, (int)SaveInterval.TotalMilliseconds, Timeout.Infinite);
     tickTimer    = new Timer(Tick, null, TickLength, TickLength);
 }
예제 #33
0
        public void IterationSetup()
        {
            var serviceCollection = new ServiceCollection();

            // инстанцируем явно, чтобы обеспечить одинаковый рандом для всех запусков тестов.
            serviceCollection.AddSingleton <IDice>(factory => new Dice(1));
            serviceCollection.AddSingleton <ISchemeLocator>(factory => CreateSchemeLocator());
            serviceCollection.AddSingleton <ISchemeService, SchemeService>();
            serviceCollection.AddSingleton <ISchemeServiceHandlerFactory, SchemeServiceHandlerFactory>();

            // Для мира
            serviceCollection.AddSingleton <IWorldGenerator, WorldGenerator>();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            _generator = serviceProvider.GetRequiredService <IWorldGenerator>();
        }
예제 #34
0
        /// <summary>
        /// Creates and adds a world to this level, with the given name.
        /// </summary>
        public void AddWorld(string name, IWorldGenerator worldGenerator = null)
        {
            if (Worlds.Any(w => w.Name.ToUpper() == name.ToUpper()))
            {
                throw new InvalidOperationException("A world with the same name already exists in this level.");
            }
            var world = new World(name);

            if (worldGenerator == null)
            {
                world.WorldGenerator = WorldGenerator;
            }
            else
            {
                world.WorldGenerator = worldGenerator;
            }
            Worlds.Add(world);
        }
예제 #35
0
        public BlockWorld()
        {
            rendererPool     = new ObjectPool <ChunkRenderer>(RendererPoolSize, () => new ChunkRenderer());
            meshUpdateQueue  = new Queue <ChunkLocation>();
            chunkMap         = new Dictionary <ChunkLocation, Chunk>();
            chunkLoadQueue   = new SimplePriorityQueue <ChunkLocation, int>();
            chunkUnloadStack = new Stack <Chunk>();
            currentlyLoading = new HashSet <ChunkLocation>();
            loadedChunks     = new ConcurrentQueue <WorldChunk>();

            mesher    = new ChunkMesher();
            generator = new DefaultWorldGenerator((int)Stopwatch.GetTimestamp());

            updateTimer = new Stopwatch();
            debugTimer  = new Stopwatch();
            debugTimer.Start();

            UpdateChunkQueues();
        }
예제 #36
0
파일: Level.cs 프로젝트: aholmes/Craft.Net
        public static IWorldGenerator GetGenerator(string generatorName)
        {
            IWorldGenerator worldGenerator = null;

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes().Where(t =>
                                                                                  !t.IsAbstract && !t.IsInterface && typeof(IWorldGenerator).IsAssignableFrom(t)))
            {
                var generator = (IWorldGenerator)Activator.CreateInstance(type);
                if (generator.GeneratorName == generatorName)
                {
                    worldGenerator = generator;
                }
            }
            if (worldGenerator == null)
            {
                worldGenerator = DefaultGenerator;
            }
            return(worldGenerator);
        }
예제 #37
0
파일: Level.cs 프로젝트: skirmish/Craft.Net
 public Level(IWorldGenerator generator) : this()
 {
     WorldGenerator = generator;
     generator.Initialize(this);
     World.WorldGenerator = WorldGenerator;
 }
예제 #38
0
파일: World.cs 프로젝트: keneo/Craft.Net
 public World(IWorldGenerator WorldGenerator, long Seed) : this(WorldGenerator)
 {
     this.Seed = Seed;
 }
예제 #39
0
 public World(string name, IWorldGenerator worldGenerator) : this(name)
 {
     WorldGenerator = worldGenerator;
 }
예제 #40
0
파일: World.cs 프로젝트: GrigoryanArtem/EVO
 public void Generation(IWorldGenerator generator)
 {
     _world = generator.Generate(Width, Height);
 }
예제 #41
0
파일: Region.cs 프로젝트: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new Region for server-side use at the given position using
 /// the provided terrain generator.
 /// </summary>
 public Region(Vector3 position, IWorldGenerator worldGenerator)
 {
     Chunks = new Dictionary<Vector3, Chunk>();
     this.Position = position;
     this.WorldGenerator = worldGenerator;
 }
예제 #42
0
파일: Level.cs 프로젝트: Booser/Craft.Net
 /// <summary>
 /// Creates and adds a world to this level, with the given name.
 /// </summary>
 public void AddWorld(string name, IWorldGenerator worldGenerator = null)
 {
     if (Worlds.Any(w => w.Name.ToUpper() == name.ToUpper()))
         throw new InvalidOperationException("A world with the same name already exists in this level.");
     var world = new World(name);
     if (worldGenerator == null)
         world.WorldGenerator = WorldGenerator;
     else
         world.WorldGenerator = worldGenerator;
     Worlds.Add(world);
 }
예제 #43
0
파일: Level.cs 프로젝트: Booser/Craft.Net
 /// <summary>
 /// Creates a named in-memory world with a given world generator.
 /// </summary>
 public Level(IWorldGenerator generator, string levelName) : this(generator)
 {
     LevelName = levelName;
 }
예제 #44
0
파일: Level.cs 프로젝트: Booser/Craft.Net
 /// <summary>
 /// Creates an in-memory world with a given world generator.
 /// </summary>
 public Level(IWorldGenerator generator) : this()
 {
     GeneratorName = generator.GeneratorName;
     generator.Seed = RandomSeed;
     generator.Initialize(this);
     WorldGenerator = generator;
     Spawn = WorldGenerator.SpawnPoint;
 }
예제 #45
0
파일: Region.cs 프로젝트: keneo/Craft.Net
 //Create new region without IWorldGenerator
 public Region(Vector3 Position)
 {
     Chunks = new Dictionary<Vector3, Chunk>();
     this.Position = Position;
     this.WorldGenerator = null;
 }
예제 #46
0
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator
 /// and the specified working directory.
 /// </summary>
 public World(Level level, IWorldGenerator worldGenerator, string directory) : this(level, worldGenerator)
 {
     Directory = directory;
     if (!System.IO.Directory.Exists(directory))
         System.IO.Directory.CreateDirectory(directory);
 }
예제 #47
0
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator.
 /// </summary>
 public World(Level level, IWorldGenerator worldGenerator) : this(level)
 {
     WorldGenerator = worldGenerator;
 }
예제 #48
0
파일: World.cs 프로젝트: pdelvo/Craft.Net
 /// <summary>
 /// Creates a new world for server-side use with the specified world generator and seed.
 /// </summary>
 /// <param name="worldGenerator"></param>
 /// <param name="seed"></param>
 public World(IWorldGenerator worldGenerator, long seed) : this(worldGenerator)
 {
     Seed = seed;
     worldGenerator.Initialize();
 }