void SetTile(int bitmask, int x, int y, int l)
{
int tile = GetTileValueFromFramwork(x, y, l);
int newValue;
if (floorVariantIndices.Contains(tile) && !TreatFloorVariantsAsSpecial) {
// Floor tiles are special in that they don't contribute to the wall structure
// So floors stay floors
newValue = floorVariantIndices.GetRandom();
} else if (floorVariantIndices.Contains(tile) && TreatFloorVariantsAsSpecial) {
// if the tile is a floor tile and floor tile are to be treated as special
newValue = tile;
} else if (bitmask == 255 && !TreatCenterVariantsAsSpecial) {
// in case we have a center variant tile we need to check if the bitmask
// is actually inidcating a center tile and center tiles are not treated special.
// if so choose a random variant
newValue = centerVariantIndices.GetRandom();
} else if (centerVariantIndices.Contains(tile) && TreatCenterVariantsAsSpecial) {
newValue = tile;
} else if (indexSpriteMap.ContainsValue(tile)) {
// if the value is available in the map it will be treated regularly
if (!indexSpriteMap.TryGetValue(bitmask, out newValue)) {
Debug.LogWarning("bitmask value not contained in index list");
}
} else {
// if the value is not contained in the indexSpriteMap, it means that
// we are processing a special tile and we won't change those
newValue = -1;
}
CommitTile(x, y, l, newValue);
}