private static GameObject GetRMC_and_Set_Restriction_info(string tilename, int rotation, bool is_mirrored, Vector3 rmcPlacement) { // ((unity loads models with -x axis)) string RMCname = TileManager.TileListInfo[tilename].RMCname; Quaternion rotate_q = Quaternion.Euler(new Vector3(0, rotation, 0)); char x = RMCname[0]; char z = RMCname[2]; if (x == '1' && z == '1') { //nothing } else if (x == '1' && z == '2') { if (is_mirrored) { rotate_q = Quaternion.Euler(new Vector3(0, -rotation, 0)); if (rotation == 90 || rotation == 270) { // V1 = H2 if (RMCname.Contains("H2") && !RMCname.Contains("V1")) { RMCname += "V1"; } else if (!RMCname.Contains("H2") && RMCname.Contains("V1")) { RMCname = RMCname.Replace("V1", ""); } } } } else if (x == '2' && z == '1') { if (is_mirrored) { rotate_q = Quaternion.Euler(new Vector3(0, -rotation, 0)); if (rotation == 0 || rotation == 180) { // H1 = H2 if (RMCname.Contains("H2") && !RMCname.Contains("H1")) { RMCname += "H1"; } else if (!RMCname.Contains("H2") && RMCname.Contains("H1")) { RMCname = RMCname.Replace("H1", ""); } } } } else // 2x2 { if (is_mirrored) { // mirrored 2x2 tiles somehow invert restrictions H1 with H2 // switch H1 with H2 if (RMCname.Contains("H1")) { RMCname = RMCname.Replace("H2", "Hx").Replace("H1", "H2").Replace("Hx", "H1"); } else if (RMCname.Contains("H2")) { RMCname = RMCname.Replace("H2", "H1"); } if (rotation == 90) { // ("switched" H2) = V2 -> H1 = V2 if (RMCname.Contains("V2") && !RMCname.Contains("H1")) { RMCname += "H1"; } else if (!RMCname.Contains("V2") && RMCname.Contains("H1")) { RMCname = RMCname.Replace("H1", ""); } } } else { if (rotation == 270) { // H2 = V2 if (RMCname.Contains("V2") && !RMCname.Contains("H2")) { RMCname += "H2"; } else if (!RMCname.Contains("V2") && RMCname.Contains("H2")) { RMCname = RMCname.Replace("H2", ""); } } } } //Debug.Log(RMCname + " " + rotation + " " + is_mirrored); RMCname = NormalizeRMCname(RMCname); var rmc = Instantiate(Get_RMC_Containing(RMCname), rmcPlacement, rotate_q); BorderInfo.CreateComponent(rmc, RMCname); rmc.GetComponent <MeshRenderer>().material = transparent; return(rmc); }