public int Compare(object x, object y) { SimPe.Plugin.MmatWrapper mmat1 = (SimPe.Plugin.MmatWrapper)x; SimPe.Plugin.MmatWrapper mmat2 = (SimPe.Plugin.MmatWrapper)y; int cmp = mmat1.GetSaveItem("materialStateFlags").IntegerValue - mmat2.GetSaveItem("materialStateFlags").IntegerValue; if (cmp == 0) { cmp = mmat1.GetSaveItem("objectStateIndex").IntegerValue - mmat2.GetSaveItem("objectStateIndex").IntegerValue; } return(cmp); }
/// <summary> /// This takes care of the MMAT Resources /// </summary> /// <param name="map"></param> /// <param name="uniquefamily"></param> /// <param name="grouphash"></param> void FixMMAT(Hashtable map, bool uniquefamily, string grouphash) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Updating Material Overrides"); } Interfaces.Files.IPackedFileDescriptor[] mpfds = package.FindFiles(Data.MetaData.MMAT); //MMAT Hashtable familymap = new Hashtable(); uint mininst = 0x5000; foreach (Interfaces.Files.IPackedFileDescriptor pfd in mpfds) { SimPe.Plugin.MmatWrapper mmat = new SimPe.Plugin.MmatWrapper(); mmat.ProcessData(pfd, package); //make the MMAT Instance number unique pfd.Instance = mininst++; //get unique family value if (uniquefamily) { string family = mmat.GetSaveItem("family").StringValue; string nfamily = (string)familymap[family]; if (nfamily == null) { nfamily = System.Guid.NewGuid().ToString(); familymap[family] = nfamily; } mmat.Family = nfamily; } string newref = (string)map[Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue.Trim().ToLower()) + "_txmt"]; if (newref != null) { newref = Hashes.StripHashFromName(newref); newref = newref.Substring(0, newref.Length - 5); mmat.Name = grouphash + newref; } else { mmat.Name = grouphash + Hashes.StripHashFromName(mmat.GetSaveItem("name").StringValue); } newref = (string)map[Hashes.StripHashFromName(mmat.ModelName.Trim().ToLower())]; if (newref != null) { newref = Hashes.StripHashFromName(newref); mmat.ModelName = newref; } else { mmat.ModelName = Hashes.StripHashFromName(mmat.ModelName); } if (ver == FixVersion.UniversityReady) { SimPe.Interfaces.Scenegraph.IScenegraphFileIndexItem item = FileTable.FileIndex.FindFileByName(mmat.ModelName, Data.MetaData.CRES, Data.MetaData.GLOBAL_GROUP, true); bool addfl = true; if (item != null) { if (item.FileDescriptor.Group == Data.MetaData.GLOBAL_GROUP) { addfl = false; } } if (addfl) { mmat.ModelName = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + mmat.ModelName; } } //mmat.FileDescriptor.Group = Data.MetaData.LOCAL_GROUP; mmat.SynchronizeUserData(); } }