using System.Collections.Generic; using System.Linq; using System.Reflection; using UnityEngine; public class ListSetUp : MonoBehaviour { public static string Globalset(GlobalOption globalOption, string id)//string cat, string id { switch (globalOption) { case GlobalOption.Door: id = SetDoor(id); break; case GlobalOption.Int: if (id.Split('?').Length == 1 || id == "none") { id = "MELAMINEWHITE"; } break; case GlobalOption.Ext: id = SetTexture(id); break; case GlobalOption.Kick: id = SetTextureKICK(id); break; case GlobalOption.Fascia: id = SetTextureFACIA(id); break; case GlobalOption.Ogee: id = SetTextureOgee(id); break; case GlobalOption.Valance: id = SetTextureVALANCE(id); break; case GlobalOption.KnobV: if (!EXIST(_G.LibraryKnobs, id) || id.Split('?').Length == 1 || id == "none") { id = _G.LibraryKnobs.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?0"; } break; case GlobalOption.Counter: id = SetCounter(id); break; case GlobalOption.Splash: if (id.IndexOf("SP.") != -1 || id == "none") { id = "SPLA.1,4,4,FFFFFF,FFFFFF,NA,r90,S,ffffff,1"; } break; case GlobalOption.KnobH: if (!EXIST(_G.LibraryKnobs, id) || id.Split('?').Length == 1 || id == "none") { id = _G.LibraryKnobs.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?0"; } break; // case GlobalOption.OPTIONSRECIPE_11: // if (id.Equals("none", System.StringComparison.CurrentCultureIgnoreCase)) { id = ""; } // break; default: Debug.Log($"Global option missing or not implemented. ({globalOption.ToString()})"); break; } return id; // if (cat == "DOOR") { id = SetDoor(id); } // if (cat == "KICK") { id = SetTextureKICK(id); } // if (cat == "INTPNL") { if (id.Split('?').Length == 1 || id == "none") { id = "MELAMINEWHITE"; } } // if (cat == "EXTPNL") { id = SetTexture(id); } // if (cat == "SPLASH") { if (id.IndexOf("SP.") != -1 || id == "none") { id = "SPLA.1,4,4,FFFFFF,FFFFFF,NA,r90,S,ffffff,1"; } } // if (cat == "OGEE") { id = SetTextureOgee(id); } // if (cat == "FACIA") { id = SetTextureFACIA(id); } // if (cat == "VALA") { id = SetTextureVALANCE(id); } // if (cat == "KNOB") // { // if (!EXIST(_G.LibraryKnobs, id) || id.Split('?').Length == 1 || id == "none") { id = _G.LibraryKnobs.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?0"; } // } // if (cat == "KNOBT") // { // if (!EXIST(_G.LibraryKnobs, id) || id.Split('?').Length == 1 || id == "none") { id = _G.LibraryKnobs.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?0"; } // } // if (cat == "COUN") { id = SetCounter(id); } // return id; } public static void namechange(int i) { _G.OBJs[i][41] = SetCounter(_G.OBJs[i][41]); _G.OBJs[i][61] = SetDoor(_G.OBJs[i][61]); _G.OBJs[i][82] = SetTexture(_G.OBJs[i][82]); _G.OBJs[i][80] = SetTextureNONE(_G.OBJs[i][80]);//Side _G.OBJs[i][63] = SetTextureKICK(_G.OBJs[i][63]);//kick _G.OBJs[i][64] = SetTextureOgee(_G.OBJs[i][64]);//ogee _G.OBJs[i][66] = SetTextureFACIA(_G.OBJs[i][66]);//Facia _G.OBJs[i][69] = SetTextureNONE(_G.OBJs[i][69]);//BOX color code Exterior _G.OBJs[i][75] = SetTexture(_G.OBJs[i][69]);//BOX FINISH PANEL _G.OBJs[i][50] = SetTextureFiller(_G.OBJs[i][50]);//FILLER _G.OBJs[i][51] = SetTextureFiller(_G.OBJs[i][51]);//FILLER _G.OBJs[i][85] = SetKnob(_G.OBJs[i][85], "?V");//Knob 25 model ? H/V _G.OBJs[i][86] = SetKnob(_G.OBJs[i][86], "?H");//Knob 26 model ? H/V } public static string SetDoor(string STR) { //if (!EXIST(_G.LibraryDoors, STR)) { STR = _G.LibraryDoors.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID); _G.NT = true; } return STR; } //public static string setTexture(string STR) //{ // if (STR.IndexOf("?") == -1) STR += "?0"; // if (!EXIST(_G.LibraryCabTextures, STR.Split('?')[0]) || STR.Split('?').Length == 1 || STR == "none") { STR = _G.LibraryCabTextures[0].Split(',')[0] + "?V"; } // return STR; //} public static string SetTexture(string STR) { if (STR.IndexOf("?") == -1) STR += "?0"; if (!EXIST(_G.LibraryCabTextures, STR.Split('?')[0]) || STR.Split('?').Length == 1 || STR == "none") { STR = _G.LibraryCabTextures.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?0"; } return STR; } //public static string setTextureNONE(string STR) //{ // if (STR.IndexOf("?") == -1) STR += "?0"; // if (!EXIST(LibraryData:_G.LibraryCabTextures, STR: STR.Split('?')[0]) && STR.IndexOf("NONE?") == -1) // { // STR = _G.LibraryCabTextures[0].Split(',')[0]; _G.NT = true; // } // return STR; //} public static string SetTextureNONE(string STR) { if (STR.IndexOf("?") == -1) STR += "?0"; if (!EXIST(LibraryData: _G.LibraryCabTextures, id: STR.Split('?')[0]) && STR.IndexOf("NONE?") == -1) { STR = _G.LibraryCabTextures.ElementAt(0).Value.GetPropertyValue(Header.ID); _G.NT = true; } return STR; } public static string SetTextureKICK(string STR) { if (!EXIST(_G.LibraryKicks, STR) && STR.IndexOf("NONE?") == -1 || STR.Split('?').Length == 1 || STR == "none" || STR == "NONE?90?6") { STR = _G.LibraryKicks.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?" + "90" + "?" + "4.5"; _G.NT = true; } return STR; } public static string SetTextureFACIA(string STR) { if (!EXIST(_G.LibraryFacias, STR.Split('?')[0]) && STR.IndexOf("NONE?") == -1 || STR.Split('?').Length < 3 || STR == "none") { STR = "NONE?90?6"; _G.NT = true; } return STR; } public static string SetTextureVALANCE(string STR) { if (!EXIST(_G.LibraryValances, STR.Split('?')[0]) && STR.IndexOf("NONE?") == -1 || STR.Split('?').Length < 3 || STR == "none") { STR = "NONE?90?3"; _G.NT = true; } return STR; } public static string SetTextureOgee(string STR) { if (!EXIST(_G.LibraryOgees, STR.Split('?')[0]) && STR.IndexOf("NONE?") == -1 || STR.Split('?').Length < 4 || STR == "none") { STR = "NONE?90?3?0"; _G.NT = true; } return STR; } public static string SetTextureFiller(string STR) { if (!EXIST(_G.LibraryFillers, STR.Split('?')[0]) && STR.IndexOf("NONE") == -1) { STR = "NONE"; _G.NT = true; } return STR; } public static string SetKnob(string STR, string vh) { if (STR.IndexOf("?") == -1) STR += vh; if (!EXIST(_G.LibraryKnobs, STR.Split('?')[0]) || STR.Split('?').Length == 1 || STR == "none") { STR = _G.LibraryKnobs.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID) + "?V"; } return STR; } public static string SetCounter(string STR) { if (!EXIST(_G.LibraryCounters, STR.Split(',')[0]) || (STR.Split(',').Length == 1 && STR == "none")) { STR = "COUN.1,1,1,FFFFFF,FFFFFF,1,90,S,ffffff,1,none"; //if (_P.CountLib == "csv") { STR = _G.LibraryCounters[0].Split(',')[0] + ",1,1,FFFFFF,FFFFFF,1,90,S,ffffff,1,none"; } if (_P.CountLib == "csv") { STR = _G.LibraryCounters.ElementAt(0).Value.GetPropertyValue(CsvHeaders.ID); } } return STR; } public static bool EXIST(Dictionary LibraryData, string id) where T : CsvData { bool exist =true; if(!_G.UIT){ id = id.Split('?')[0]; exist = LibraryData.ContainsKey(id); if (!exist) { if (id != "NONE") { Debug.Log("The id " + id + " was not found in the library which could indicate a mismatch between the library used to save and the library right now " + LibraryData); ; } } } return exist; } }