示例#1
0
    public FloralEntry[] LoadFloral(BlockManager alreadyLoadedBlocks, BiomeManager biomes)
    {
        List <FloralEntry> potentialFloral = new List <FloralEntry>();

        potentialFloral.Add(new FloralEntry()
        {
            Floral           = (PlantBlock)alreadyLoadedBlocks.GetBlockOrDefault("Base/Block/GrassPlant"),
            HeightRange      = new Vector2(55, 115),
            HumidityRange    = new Vector2(0.3f, 1f),
            TemperatureRange = new Vector2(0.25f, 0.9f),
            SpawnChance      = 0.9f
        });

        potentialFloral.Add(new FloralEntry()
        {
            Floral           = (PlantBlock)alreadyLoadedBlocks.GetBlockOrDefault("Base/Block/Dandelion"),
            HeightRange      = new Vector2(60, 85),
            HumidityRange    = new Vector2(0.3f, 1f),
            TemperatureRange = new Vector2(0.3f, 0.8f),
            SpawnChance      = 0.1f
        });

        potentialFloral.Add(new FloralEntry()
        {
            Floral           = (PlantBlock)alreadyLoadedBlocks.GetBlockOrDefault("Base/Block/Poppy"),
            HeightRange      = new Vector2(62, 80),
            HumidityRange    = new Vector2(0.2f, 0.7f),
            TemperatureRange = new Vector2(0.45f, 0.9f),
            SpawnChance      = 0.1f
        });

        return(potentialFloral.ToArray());
    }
        public void OnProtoSerialize(ProtobufSerializer serializer)
        {
            QuickLogger.Info($"Saving {_prefabID.Id} Data");

            if (!Directory.Exists(SaveDirectory))
            {
                Directory.CreateDirectory(SaveDirectory);
            }

            var saveData = new SaveData
            {
                HasBreakerTripped = PowerManager.GetHasBreakerTripped(),
                TurbineRot        = new TargetRotation(_targetRotation),
                Health            = HealthManager.GetHealth(),
                Charge            = PowerManager.GetCharge(),
                DegPerSec         = BiomeManager.GetBiomeData(_currentBiome).Speed,
                Biome             = _currentBiome,
                CurrentSpeed      = _currentSpeed,
                PassedTime        = HealthManager.GetPassedTime(),
                StoredPower       = PowerManager.GetStoredPower()
            };

            var output = JsonConvert.SerializeObject(saveData, Formatting.Indented);

            File.WriteAllText(SaveFile, output);

            QuickLogger.Info($"Saved {_prefabID.Id} Data");


            //TODO Replace this
            //LoadItems.CleanOldSaveData();
        }
 public override void EditSpawnRange(Player player, ref int spawnRangeX, ref int spawnRangeY, ref int safeRangeX, ref int safeRangeY)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.EditSpawnRange(player, ref spawnRangeX, ref spawnRangeY, ref safeRangeX, ref safeRangeY);
     }
 }
示例#4
0
    private bool GenerateChunk(Vector3i chunkPos)
    {
        bool generated = false;

        for (int z = -1; z < Chunk.SIZE_Z + 1; z++)
        {
            for (int x = -1; x < Chunk.SIZE_X + 1; x++)
            {
                for (int y = 0; y < Chunk.SIZE_Y; y++)
                {
                    Vector3i worldPos = Chunk.ToWorldPosition(chunkPos, new Vector3i(x, y, z));

                    if (worldPos.y <= WATER_LEVEL && map.GetBlock(worldPos).IsEmpty())
                    {
                        map.SetBlock(water, worldPos);
                        generated = true;
                    }

                    int islandHeight = BiomeManager.getCurrentBiome().getHeight(worldPos.x, worldPos.z);
                    if (worldPos.y <= islandHeight)
                    {
                        GenerateBlockForIsland(worldPos, islandHeight - worldPos.y, islandHeight);
                        generated = true;
                        continue;
                    }
                }
            }
        }
        return(generated);
    }
示例#5
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.R) || Input.GetKeyDown(KeyCode.JoystickButton5))
     {
         rotateCamera(RIGHT);
     }
     if (Input.GetKeyDown(KeyCode.JoystickButton4))
     {
         rotateCamera(LEFT);
     }
     if (Input.GetKeyDown(KeyCode.V))
     {
         SwitchView();
     }
     if (followThePlayer)
     {
         camTarget = player.transform.position; //needs to be refreshed
     }
     else
     {
         _currentBiomePos = BiomeManager.WorldToBiomePos(player.transform.position);
         camTarget        = BiomeManager.BiomeToWorldPos(_currentBiomePos) + BiomeCenterOffset;
     }
     Follow(camTarget, camSize);
 }
示例#6
0
        public override TagCompound Save()
        {
            TagCompound compound = new TagCompound();

            BiomeManager.Save(compound);
            return(compound);
        }
        private void SystemHandler()
        {
            if (MaxSpeed <= 0)
            {
                MaxSpeed = BiomeManager.GetBiomeData(_currentBiome).Speed;
            }


            /*
             * Handles starting and stopping the turbine and its rotor based off conditions
             */
            if (IsConstructed)
            {
                if (PowerManager.GetHasBreakerTripped() || !IsUnderWater() || HealthManager.GetHealth() <= 0)
                {
                    if (!string.IsNullOrEmpty(_currentBiome))
                    {
                        ChangeMotorSpeed(MaxSpeed);
                    }
                    StopMotor();
                }
                else
                {
                    if (!string.IsNullOrEmpty(_currentBiome))
                    {
                        ChangeMotorSpeed(MaxSpeed);
                    }
                    StartMotor();
                    RotateRotor();
                }
            }
        }
示例#8
0
            public void Generate(GenerationProgress progress)
            {
                const int lostCityHeight = 175;

                progress.Message = "Clearing out the Lost City";

                Rectangle tunnels = BiomeManager.Get <Epicenter.Mouth>().Tunnels;
                Rectangle area    = BiomeManager.Get <LostCity>().Area = new Rectangle(tunnels.X, tunnels.Bottom - 10, tunnels.Width, lostCityHeight);

                var noise = new FastNoise(WorldGen._genRandSeed)
                {
                    NoiseType   = FastNoise.NoiseTypes.CubicFractal,
                    FractalType = FastNoise.FractalTypes.Billow,
                    Frequency   = 0.08f
                };
                var focal         = new Vector2(area.Center.X, (int)(area.Top + area.Width * 0.8));
                var maxMiddleDist = (area.TopLeft() - focal).LengthSquared();

                for (int i = area.Left; i < area.Right; i++)
                {
                    for (int j = area.Top; j < area.Bottom; j++)
                    {
                        var middleDist = (new Vector2(i, j) - focal).LengthSquared() / maxMiddleDist;
                        var result     = noise.GetNoise(i, j);
                        if (result < -0.52f * (1 + middleDist))
                        {
                            WorldGen.KillTile(i, j);
                        }
                    }
                }
            }
 public override void EditSpawnRate(Player player, ref int spawnRate, ref int maxSpawns)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.EditSpawnRate(player, ref spawnRate, ref maxSpawns);
     }
 }
示例#10
0
    private void FixedUpdate()
    {
        if (pressure > maxPressureThreshold ^ pressure < minPressureThreshold)
        {
            //any damage function
            setHP(HP - 1);
        }

        if (temperature > maxTemperatureThreshold ^ temperature < minTemperatureThreshold)
        {
            //any damage function
            setHP(HP - 1);
        }

        /*
         * //toggle radiation DPS
         * if (Input.GetKey("r"))
         * {
         *  setRadiation(radiation + 1);
         * }
         */

        //Temperature setting

        setTemperature(BiomeManager.getBiomeAt((int)GameObject.FindGameObjectWithTag("Player").transform.position.x).getTemperature((int)GameObject.FindGameObjectWithTag("Player").transform.position.y));
        setPressure(BiomeManager.getBiomeAt((int)GameObject.FindGameObjectWithTag("Player").transform.position.x).getPressure((int)GameObject.FindGameObjectWithTag("Player").transform.position.y));
    }
示例#11
0
 public override void SendCustomBiomes(BinaryWriter writer)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         writer.Write(biome.GetInBiome(player));
     }
 }
示例#12
0
 public override void ReceiveCustomBiomes(BinaryReader reader)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.SetInBiome(player, reader.ReadBoolean());
     }
 }
示例#13
0
 public override void UpdateBiomeVisuals()
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.OnUpdateVisuals();
     }
 }
示例#14
0
 public override void CopyCustomBiomesTo(Player other)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.SetInBiome(other, biome.GetInBiome(player));
     }
 }
示例#15
0
 public override void UpdateBiomes()
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.UpdateBiome(player);
     }
 }
示例#16
0
            private static void InfectArea(GenerationProgress progress)
            {
                var area   = BiomeManager.Get <Epicenter>().Area;
                var widthL = SurfaceWidth / 2f; // The left side of the biome's width.
                var widthR = SurfaceWidth / 2f; // The right side of the biome's width.
                var j      = area.Top;          // The current iterator. We iterate from top to bottom via rows.

                // Just a shortcut function :P
                void InfectRow()
                {
                    for (int i = area.Center.X - (int)widthL; i < area.Center.X + (int)widthR; i++)
                    {
                        TileExtensions.Infect(i, j);
                    }
                }

                float GetJPercent() => (j - area.Top) / (float)area.Height;

                // Initial surface. Skinny.
                for (; GetJPercent() < 0.1 && widthL + widthR < area.Width; j++)
                {
                    widthL += Rand(-1, 1);
                    widthR += Rand(-1, 1);
                    InfectRow();
                }
                progress.Value = 0.3f;

                float inc = 1f; // How the shape of the biome should expand/

                // Expansion. The underground is a lot larger than the above ground.
                for (; GetJPercent() < 0.5 && widthL + widthR < area.Width; j++)
                {
                    inc    += 0.01f;
                    widthL += Rand(-inc / 3, inc);
                    widthR += Rand(-inc / 3, inc);
                    InfectRow();
                }
                progress.Value = 0.5f;

                // The more jagged edges of the bottom of the biome's bottom
                inc = 0f;
                for (; GetJPercent() < 0.8; j++)
                {
                    inc    += 0.02f;
                    widthL += Rand(-inc, inc);
                    widthR += Rand(-inc, inc);
                    InfectRow();
                }
                progress.Value = 0.7f;

                // Finally, close the bottom of the biome
                for (; GetJPercent() < 1 && widthL + widthR > 0 && inc > 0; j++)
                {
                    inc    -= 0.065f;
                    widthL += Rand(-inc - 1, inc / 2);
                    widthR += Rand(-inc - 1, inc / 2);
                    InfectRow();
                }
                progress.Value = 0.9f;
            }
示例#17
0
 public override void ModifySunLightColor(ref Color tileColor, ref Color backgroundColor)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.ModifySunlight(ref tileColor, ref backgroundColor);
     }
 }
示例#18
0
 public override void EditSpawnPool(IDictionary <int, float> pool, NPCSpawnInfo spawnInfo)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         biome.EditSpawnPool(pool, spawnInfo);
     }
 }
示例#19
0
    /* Start, Update */
    void Start()
    {
        _chunkGenerator       = GetComponent <ChunkGenerator>();
        _biomeManager         = GetComponent <BiomeManager>();
        _chunkObjectGenerator = GetComponent <ChunkObjectGenerator>();

        _cameraControllerTransform = Camera.main.transform.parent;
    }
示例#20
0
    public Structure[] LoadStructures(BlockManager blocks, BiomeManager biomes)
    {
        List <Structure> structures = new List <Structure>();

        structures.Add(new TreeStructure(blocks, biomes));

        return(structures.ToArray());
    }
示例#21
0
 void Awake()
 {
     instance    = this;
     biomeBlocks = new List <BlockDensityManager>();
     foreach (BiomeObject biome in generationMatrix)
     {
         currentGeneratedItemsCount.Add(biome.name, 0);
     }
 }
示例#22
0
 public override void UpdateMusic(ref int music, ref MusicPriority priority)
 {
     foreach (var biome in BiomeManager.GetAll())
     {
         if (biome.GetInBiome(Main.LocalPlayer))
         {
             biome.ModifyMusic(ref music, ref priority);
         }
     }
 }
示例#23
0
    public TerrainGenerator(Map map)
    {
        this.map      = map;
        this.bmanager = new BiomeManager(map);
        BlockSet blockSet = map.GetBlockSet();

        water = blockSet.GetBlock("Water");
        grass = blockSet.GetBlock("Grass");
        dirt  = blockSet.GetBlock("Dirt");
    }
示例#24
0
    private void OnCollisionEnter(Collision c)
    {
        BlockController block = c.gameObject.GetComponent <BlockController>();

        if (block && transform.localScale.y - BiomeManager.BlockToWorldPos(CurrentBiomePos(), block.biomeCoords).y < Biome.BlockSize * .9)
        {
            // TODO check if the Player is inside the x and z boundaries of the BlockThePlayerWalksOn.
            BlockThePlayerWalksOn = block;
        }
    }
示例#25
0
 public Biome(float pers, Block surface, bool isFlat, int maxMountainHeight, int offset)
 {
     _persistence = pers;
     biomeId      = biomeCount;
     biomeCount++;
     _surfaceBlock      = surface;
     _isFlat            = isFlat;
     _maxMountainHeight = maxMountainHeight;
     _offset            = offset;
     BiomeManager.addBiome(this);
 }
示例#26
0
            public void Generate(GenerationProgress progress)
            {
                progress.Message = "Building up the Lost City";

                var leftSide = InstantiateBuildings(Biome.Area.X - 10, Biome.Area.Bottom, -1);
                var rightSide = InstantiateBuildings(Biome.Area.X + 10, Biome.Area.Bottom, +1);

                ErectBuildings(leftSide);
                ErectBuildings(rightSide);

                BiomeManager.Get<LostCity>().buildings = leftSide.Concat(rightSide).ToList();
            }
示例#27
0
 // Use this for initialization
 void Start()
 {
     BaseTime.velocity = 1000;
     manager           = new BiomeManager();
     biome1            = new Biome();
     biome2            = new Biome();
     biome1.SetPosition(50, 1, 0);
     biome2.SetPosition(-50, 1, 0);
     biome1.fog = t => 30;
     biome2.fog = t => 20;
     manager.AddBiome("Bioma 1", biome1);
     manager.AddBiome("Bioma 2", biome2);
 }
示例#28
0
            public override void Update(GameTime gameTime)
            {
                base.Update(gameTime);

                float targetFade = Math.Min(1, BiomeManager.Get <Epicenter>().TileCounts / (float)BiomeManager.Get <Epicenter>().TileCountThreshold / 5);

                Instance.Fade += (targetFade - Instance.Fade) / 60;

                if (Instance.Fade < 0.01f && targetFade == 0)
                {
                    Instance.Fade = 0;
                }
            }
示例#29
0
 public StandardWorldProvider(string folder)
 {
     _folder       = folder;
     IsCaching     = true;
     _biomeManager = new BiomeManager(ServerSettings.Seed.GetHashCode());
     //	_biomeManager.AddBiomeType(new OceanBiome()); //Not adding until we fixed the transitions :(
     _biomeManager.AddBiomeType(new FlowerForestBiome());
     _biomeManager.AddBiomeType(new ForestBiome());
     _biomeManager.AddBiomeType(new BirchForestBiome());
     _biomeManager.AddBiomeType(new PlainsBiome());
     _biomeManager.AddBiomeType(new DesertBiome());
     _biomeManager.AddBiomeType(new SunFlowerPlainsBiome());
 }
        internal List <TechType> GetBiomeData(string biome = null, Transform tr = null)
        {
            if (_bioData?.Count <= 0 && tr != null || biome != null)
            {
                var data = BiomeManager.FindBiomeLoot(tr, biome);

                if (data != null)
                {
                    _bioData = data;
                }
            }

            return(_bioData);
        }