Пример #1
0
        /// Temporary method @TODO: Clean this shit.
        public void TempMapGen()
        {
            this.groundNoiseMap = NoiseMap.GenerateNoiseMap(this.size, 11, NoiseMap.GroundWave(42));

            foreach (Vector2Int position in this.rect)
            {
                this.Spawn(
                    position,
                    new Ground(
                        position,
                        Ground.GroundByHeight(this.groundNoiseMap[position.x + position.y * this.size.x])
                        )
                    );

                if (this.grids[Layer.Ground].GetTilableAt(position).def.uid == "rocks")
                {
                    this.Spawn(
                        position,
                        new Mountain(position, Defs.mountains["mountain"])
                        );
                }

                if (this[position].fertility > 0f && !this[position].blockPlant)
                {
                    foreach (TilableDef tilableDef in Defs.plants.Values)
                    {
                        if (
                            this[position].fertility >= tilableDef.plantDef.minFertility &&
                            Random.value <= tilableDef.plantDef.probability
                            )
                        {
                            this.Spawn(
                                position,
                                new Plant(position, tilableDef, true)
                                );
                            break;
                        }
                    }
                }
            }

            this.UpdateConnectedMountains();
        }
Пример #2
0
        /// Temporary method @TODO: Clean this shit.
        public void TempMapGen()
        {
            this.groundNoiseMap = NoiseMap.GenerateNoiseMap(this.size, 11, NoiseMap.GroundWave(42));
            foreach (Vector2Int position in this.rect)
            {
                this.Spawn(
                    position,
                    new Ground(
                        position,
                        Ground.GroundByHeight(this.groundNoiseMap[position.x + position.y * this.size.x])
                        )
                    );

                if (this.grids[Layer.Ground].GetTilableAt(position).def.uid == "rocks")
                {
                    this.Spawn(
                        position,
                        new Mountain(position, Defs.mountains["mountain"])
                        );
                }

                if (this[position].fertility > 0f && !this[position].blockPlant)
                {
                    foreach (TilableDef tilableDef in Defs.plants.Values)
                    {
                        if (
                            this[position].fertility >= tilableDef.plantDef.minFertility &&
                            Random.value <= tilableDef.plantDef.probability
                            )
                        {
                            this.Spawn(
                                position,
                                new Plant(position, tilableDef, true)
                                );
                            break;
                        }
                    }
                }
            }

            foreach (LayerGridBucket bucket in this.grids[Layer.Mountain].buckets)
            {
                bool changed = false;
                foreach (Tilable tilable in bucket.tilables)
                {
                    if (tilable != null)
                    {
                        tilable.UpdateGraphics();
                        changed = true;
                    }
                }
                if (changed)
                {
                    bucket.rebuildMatrices = true;
                }
            }

            foreach (Vector2Int position in new RectI(new Vector2Int(10, 10), 5, 5))
            {
                if (this[position].blockStackable == false)
                {
                    this.Spawn(position, new Stackable(
                                   position,
                                   Defs.stackables["logs"],
                                   Random.Range(1, Defs.stackables["logs"].maxStack)
                                   ));
                }
            }
        }