I haven’t worked much with structs or enums, but after having a look at a couple of tutorials, I thought they were quite easy. I thought about setting an enum inside a struct, such as for chunk manipulation with a 2d array of an enum, but for some reason it says I need a comma in the middle of the variable I’m setting!
[Flags]
public enum WallState
{
LEFT = 1,
RIGHT = 2,
UP = 4,
DOWN = 8,
VISITED = 128,
}
public struct Chunk
{
public WallState[,] Walls;
public Position ChunkPosition;
}
// ^ struct and 2d enum array
public static Chunk[,] ConvertToChunk(WallState[,] maze) {
Chunk[,] out = new Chunk[3,3]; // <<<< error line
for (int x = 0; x < 3; x ++) {
for (int y = 0; y < 3; y ++) {
WallState[,] temp = new WallState[5,5];
for (int xc = 0; xc < 5; xc ++) {
for (int yc = 0; yc < 5; yc ++) {
temp[xc,yc] = maze[x*5+xc,y*5+yc];
}
} // << apparently need another?
out[x,y] = new Chunk{ Walls = temp, ChunkPosition = new Position{ X = x, Y = y } }; // need a } after out[x,y]....
}
}
}
//I'm getting an error for some reason right after I declare Chunk[,]...
//I'm also getting an error that I need a semicolon instead of =...
//