コード例 #1
0
ファイル: World.cs プロジェクト: pershingthesecond/VoxelGame
        /// <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
ファイル: TargetFinder.cs プロジェクト: FSorek/Essence2021
 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);
        }
コード例 #8
0
 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
ファイル: World.cs プロジェクト: seaboy1234/Craft.Net
 /// <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
ファイル: SPWorldProvider.cs プロジェクト: wqd1019dqw/Alex
        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
ファイル: World.cs プロジェクト: SharpenedMinecraft/SM1
        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
ファイル: Server.cs プロジェクト: cpancake/Craft.Net
        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
ファイル: MinetAnvilTest.cs プロジェクト: stefanbranetu/MiNET
        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
ファイル: BlockWorld.cs プロジェクト: jczajka/SurviveCore
        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
ファイル: World.cs プロジェクト: supertnt1/Craft.Net
 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
ファイル: World.cs プロジェクト: ammaraskar/Craft.Net
 /// <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
ファイル: World.cs プロジェクト: ammaraskar/Craft.Net
 /// <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();
 }