Beispiel #1
0
        protected virtual WormNode CreateNextCrystalCaveKeyNode(WormSystemGen wormSys, int radius, int nodeSpacing)
        {
            int tests       = 14;
            int tilePadding = 8;

            WormNode currNode = this.KeyNodes[this.KeyNodes.Count - 1];

            var testNodes = this.CreateTestNodes(tests, radius, nodeSpacing, currNode);

            WormNode bestNode   = null;
            float    prevGauged = -1f;

            foreach (WormNode testNode in testNodes)
            {
                float gauged = this.GaugeCrystalCaveNode(wormSys, testNode, currNode, tilePadding);
                if (prevGauged != -1 && gauged > prevGauged)
                {
                    continue;
                }

                prevGauged = gauged;
                bestNode   = testNode;
            }

            return(bestNode);
        }
Beispiel #2
0
        public override void Apply(GenerationProgress progress)
        {
            progress.Message = "Generating Snaking Caves";               //Lang.gen[76].Value+"..Thin Ice"

            int pad   = WormGenPass.PaddingDistance;
            int tileX = WorldGen.genRand.Next(pad, Main.maxTilesX - pad);
            int tileY = WorldGen.genRand.Next((int)Main.worldSurface + pad, (Main.maxTilesY - 200) - pad);

            WormSystemGen wormSys = CrystalCaveSystemGen.Create(progress, 0.5f, tileX, tileY);

            wormSys.PaintNodes(progress, 0.5f);

            progress.Set(1f);
        }
Beispiel #3
0
        protected override WormNode CreateKeyNode(WormSystemGen wormSys)
        {
            this.CalculateNextRadiusAndNodeSpacing(out int radius, out int nodeSpacing);

            WormNode newNode;

            if (this.KeyNodes.Count == 0)
            {
                newNode = new WormNode(this.OriginTileX, this.OriginTileY, radius, nodeSpacing, this);
            }
            else
            {
                newNode = this.CreateNextCrystalCaveKeyNode(wormSys, radius, nodeSpacing);
            }

            return(newNode);
        }
        ////////////////

        protected override float GaugeCrystalCaveNode(
            WormSystemGen wormSys,
            WormNode testNode,
            WormNode prevNode,
            float tilePadding)
        {
            float gauged = base.GaugeCrystalCaveNode(wormSys, testNode, prevNode, tilePadding);

            // downward is best
            float vertGauge = (testNode.TileY - prevNode.TileY) > 0f
                                ? 0 : 100000f;
            // closest to center is best
            float horizGauge = Math.Abs(prevNode.TileX - testNode.TileX);

            horizGauge *= 10;

            return(gauged + vertGauge + horizGauge);
        }
Beispiel #5
0
        ////////////////

        protected virtual float GaugeCrystalCaveNode(
            WormSystemGen wormSys,
            WormNode testNode,
            WormNode prevNode,
            float tilePadding)
        {
            float gauged = 0f;

            foreach (WormNode existingNode in wormSys)
            {
                float value = (float)existingNode.GetDistance(testNode);

                value -= existingNode.TileRadius + testNode.TileRadius + tilePadding;
                if (value < 0f)
                {
                    value = 100000 - value;                     // too close penalty
                }

                gauged += value;
            }

            return(gauged / (float)wormSys.NodeCount);
        }