Ah code, now we can talk solutions :)
I'm not even half way and its getting quite long and feels inelegant for implementing given the amount of checks and combinations involved.
I agree this looks wrong. It looks like you are testing for a few specific bits. You generally do this with bit masking. Terms you are looking for are bit masking, bit arithmetic, and more generally, bit operations.
Can you tell what the mask is? That is, how did you derive the "if (tile.Mask == 22 || tile.Mask == 18 || tile.Mask == 55 || tile.Mask == 23 || tile.Mask == 54 || tile.Mask == 19)" line ?
I tried to reverse engineer it, but the result is wrong
print(bin(18)) # prints 00010010
print(bin(55)) # prints 00110111
print(bin(23)) # prints 00010111
print(bin(54)) # prints 00110110
print(bin(19)) # prints 00010011
If you check each column, and replace the value by * (dont care) if you compare both a 0 and a 1 sometimes, I get
00010110
00010010
00110111
00010111
00110110
00010011
00*10*1*
There are 3 * bits there, which means there should be 8 cases, but you have only 6, so something is missing. That information should be in the description of your mask.
The trick here is that the * bits are not interesting, so you force them to 0 with an 'and 0' operation. The bits you care about must be preserved, so you force them to stay the same with an 'and 1' operation. That means the bitmask here seems to be [except for the missing cases]:
00*10*1* and 11011010
// second number is the same as the first, with * replaced by 0, and (0/1) replaced by 1
The result of this operation is then 00010010 (again the first number, but only the * replaced by 0)
You can convert 11011010 back to decimal, I prefer hexadecimal, which is 0xDA.
Similarly, 00010010 is 0x12 in hexadecimal number system.
Your first line then becomes "if ((tile.Mask & 0xDA) == 0x12)"
If you try that for all numbers 0..255:
for n in range(0, 256):
if (n & 0xDA) == 0x12:
print(n)
Output:
18
19
22
23
50
51
54
55
Values 50 and 51 are missing in your 'if' statement. I don't know why.
Can you find out?
[ you can likely split things out even more, if the Vec3 value is a separate part in the tile mask, you can convert that separately, reducing stuff by a factor 2 or 4. ]