Exemple #1
0
 private MeshInstance CreateMeshInstance(float3 pos, int index, ConfigTransformGroup group, byte variant)
 {
     return(new MeshInstance
     {
         transform = CreateTransform(pos, group[index].PieceTransform),
         basePieceIndex = group[index].BaseMeshIndex,
         variantIndex = variant
     });
 }
Exemple #2
0
            public void Execute(int index)
            {
                byte configuration = 0;
                int3 dc            = CoordFromIndex(index, tileExtents);

                bool hasLF = dc.x > 0 && dc.z < dataExtents.Z && IsFilled(dc.x - 1, yLevel, dc.z);
                bool hasRF = dc.x < dataExtents.X && dc.z < dataExtents.Z && IsFilled(dc.x, yLevel, dc.z);
                bool hasLB = dc.x > 0 && dc.z > 0 && IsFilled(dc.x - 1, yLevel, dc.z - 1);
                bool hasRB = dc.x < dataExtents.X && dc.z > 0 && IsFilled(dc.x, yLevel, dc.z - 1);

                if (emptyBoundaries != Direction.All && (hasLF || hasRF || hasLB || hasRB))
                {
                    if (dc.x == 0 && !HasFlag(emptyBoundaries, Direction.XMinus))
                    {
                        hasLF = true; hasLB = true;
                    }
                    if (dc.x == dataExtents.X && !HasFlag(emptyBoundaries, Direction.XPlus))
                    {
                        hasRF = true; hasRB = true;
                    }
                    if (dc.z == 0 && !HasFlag(emptyBoundaries, Direction.ZMinus))
                    {
                        hasLB = true; hasRB = true;
                    }
                    if (dc.z == dataExtents.Z && !HasFlag(emptyBoundaries, Direction.ZPlus))
                    {
                        hasLF = true; hasRF = true;
                    }
                }

                if (hasLF)
                {
                    configuration |= Tile.LeftForward;
                }
                if (hasRF)
                {
                    configuration |= Tile.RightForward;
                }
                if (hasLB)
                {
                    configuration |= Tile.LeftBackward;
                }
                if (hasRB)
                {
                    configuration |= Tile.RightBackward;
                }

                var transformGroup = configs[configuration];

                var tileType = TileType.Normal;

                if (configuration == 0)
                {
                    tileType = TileType.Void;
                }
                else if (configuration == configs.Length - 1)
                {
                    if (skipCenter)
                    {
                        tileType = TileType.Void;
                    }
                    else
                    if (centerRandomRotation)
                    {
                        var rot = (PieceTransform)(1 << (2 + (index % 4)));
                        if ((byte)rot >= (byte)PieceTransform.Rotate90)
                        {
                            transformGroup = new ConfigTransformGroup(new TileTheme.ConfigTransform(transformGroup[0].BaseMeshIndex, rot));
                        }
                    }
                }
                else
                {
                    if (skipBorder)
                    {
                        tileType = TileType.Void;
                    }
                }

                tiles[index] = new TileMeshData {
                    type = tileType, configTransformGroup = transformGroup, variant0 = 0, variant1 = 0
                };
            }