Пример #1
0
        public Biome(BiomeProperties properties, GeneratorSettings genSettings)
        {
            _genSettings = genSettings;

            _name            = properties.BiomeName;
            _biomeId         = properties.BiomeId;
            _baseHeight      = properties.BaseHeight;
            _heightVariation = properties.HeightVariation;
            _temperature     = properties.Temperature;
            _rainfall        = properties.Rainfall;
            _waterColor      = properties.WaterColor;
            _enableSnow      = properties.EnableSnow;
            _enableRain      = properties.EnableRain;

            _dirtGen = new MinableGenerator(
                BlockStates.Dirt(),
                genSettings.DirtSize);
            _gravelOreGen = new MinableGenerator(
                BlockStates.Gravel(),
                genSettings.GravelSize);
            _graniteGen = new MinableGenerator(
                BlockStates.Stone(StoneType.Granite),
                genSettings.GraniteSize);
            _dioriteGen = new MinableGenerator(
                BlockStates.Stone(StoneType.Diorite),
                genSettings.DioriteSize);
            _andesiteGen = new MinableGenerator(
                BlockStates.Stone(StoneType.Andesite),
                genSettings.AndesiteSize);
            _coalGen = new MinableGenerator(
                BlockStates.CoalOre(),
                genSettings.CoalSize);
            _ironGen = new MinableGenerator(
                BlockStates.IronOre(),
                genSettings.IronSize);
            _goldGen = new MinableGenerator(
                BlockStates.GoldOre(),
                genSettings.GoldSize);
            _redstoneGen = new MinableGenerator(
                BlockStates.RedstoneOre(),
                genSettings.RedstoneSize);
            _diamondGen = new MinableGenerator(
                BlockStates.DiamondOre(),
                genSettings.DiamondSize);
            _lapisGen = new MinableGenerator(
                BlockStates.LapisLazuliOre(),
                genSettings.LapisSize);

            _treesPerChunk     = 0;     // mc 0
            _extraTreeChance   = 0.05F; // mc 0.05F
            _grassPerChunk     = 10;
            _flowersPerChunk   = 4;
            _mushroomsPerChunk = 0;

            _deadBushPerChunk = 2;
            _reedsPerChunk    = 50;
            _cactiPerChunk    = 10;
        }
Пример #2
0
        public static Biome GetBiome(int id, GeneratorSettings settings)
        {
            BiomeId biomeId = (BiomeId)id;

            switch (biomeId)
            {
            case BiomeId.Ocean:
                return(new BiomeOcean(new BiomeProperties(), settings));

            case BiomeId.Plains:
                return(new BiomePlains(new BiomeProperties(), settings));

            case BiomeId.Desert:
                return(new BiomeDesert(new BiomeProperties(), settings));

            case BiomeId.Mountains:
                return(new BiomeHill(BiomeHillType.Normal, new BiomeProperties(), settings));

            case BiomeId.Forest:
                return(new BiomeForest(new BiomeProperties(), settings));

            case BiomeId.Taiga:
                return(new BiomeTaiga(BiomeTaigaType.Normal, new BiomeProperties(), settings));

            case BiomeId.Swamp:
                return(new BiomeSwamp(new BiomeProperties(), settings));

            case BiomeId.River:
                return(new BiomeRiver(new BiomeProperties(), settings));

            case BiomeId.Beach:
                return(new BiomeBeach(new BiomeProperties(), settings));

            case BiomeId.Savanna:
                return(new BiomeSavanna(new BiomeProperties(), settings));

            default:
                return(null);
            }
        }
Пример #3
0
        private async Task OnGameTick(object sender, GameTickArgs e)
        {
            if (e.WorldAge % 512 == 0 && e.TimeOfDay > 12000 && e.TimeOfDay < 24000)
            {
                EntityWorldPos playerPosition = AttachedObject.GetValue(EntityWorldPositionComponent.EntityWorldPositionProperty);
                int            x = random.Next(9) - 4 + (int)playerPosition.X;
                int            z = random.Next(9) - 4 + (int)playerPosition.Z;
                BlockWorldPos  monsterBlockPos = new BlockWorldPos(x, 0, z);
                ChunkWorldPos  monsterChunkPos = monsterBlockPos.ToChunkWorldPos();
                var            chunkAccessor   = AttachedObject.GetComponent <ChunkAccessorComponent>();
                BiomeId        biomeId         = await chunkAccessor.GetBlockBiome(monsterBlockPos);

                IWorld            world   = AttachedObject.GetValue(WorldComponent.WorldProperty);
                GeneratorSettings setting = await world.GetGeneratorSettings();

                Biome        biome = Biome.GetBiome((int)biomeId, setting);
                IChunkColumn chunk = await chunkAccessor.GetChunk(monsterChunkPos);

                // TODO
                biome.SpawnMonster(world, GrainFactory, await chunk.GetState(), random, monsterBlockPos);
            }
        }