Ejemplo n.º 1
0
            /// <summary>
            /// Generates the decor vertices for the specified tile.
            /// </summary>
            /// <param name="x">The tile x coordinate.</param>
            /// <param name="y">The tile y coordinate.</param>
            /// <param name="color">The color tint to apply.</param>
            private void GenerateDecorVertices(int x, int y, Color color)
            {
                var  dri       = decorRenderInfo.decor;
                int  n         = dri.Length;
                Bits connected = TileRendererUtils.GetDecorConnectionBits(x, y, queryLayer);

                for (int i = 0; i < n; i++)
                {
                    var  decor    = dri[i];
                    var  variants = decor.variants;
                    Bits required = decor.requiredConnections;
                    if (variants != null && variants.Length > 0 && (connected & required) ==
                        required && (connected & decor.forbiddenConnections) == 0)
                    {
                        // Use a seeded random noise to determine if the tops spawn here
                        float score = PerlinSimplexNoise.noise((float)(i + x + connected) *
                                                               SIMPLEX_SCALE.x, (float)(i + y + connected) * SIMPLEX_SCALE.y);
                        if (score >= decor.probabilityCutoff)
                        {
                            TileRendererUtils.AddDecorVertexInfo(ref decor, x, y, score, color,
                                                                 decorTriangles);
                        }
                    }
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Generates the vertices for the specified tile.
            /// </summary>
            /// <param name="x">The tile x coordinate.</param>
            /// <param name="y">The tile y coordinate.</param>
            /// <param name="color">The color tint to apply.</param>
            private void GenerateVertices(int x, int y, Color color)
            {
                // Difficult to optimize this further as bits can have any combination
                Bits connected = TileRendererUtils.GetConnectionBits(x, y, queryLayer);
                int  n         = atlasInfo.Length;

                for (int i = 0; i < n; i++)
                {
                    var  ai      = atlasInfo[i];
                    Bits require = ai.requiredConnections;
                    // If all required bits, and no forbidden bits, render this one
                    if ((require & connected) == require && (ai.forbiddenConnections &
                                                             connected) == 0)
                    {
                        TileRendererUtils.AddVertexInfo(ai, x, y, connected, color);
                        break;
                    }
                }
            }