public PSC_Entry GetPscEntry(string charaID) { if (PscEntries.Any(e => e.Index == charaID)) { return(PscEntries.FirstOrDefault(e => e.Index == charaID)); } else { PSC_Entry pscEntry = new PSC_Entry() { Index = charaID }; PscEntries.Add(pscEntry); return(pscEntry); } }
public static PSC_File Load(byte[] bytes) { //First, validate that the psc file is from version 1.13 or greater if (BitConverter.ToInt16(bytes, 6) != PSC_HEADER_SIZE) { throw new InvalidDataException("PSC files from game versions prior to 1.13 are not supported."); } PSC_File pscFile = new PSC_File(); int numEntries = BitConverter.ToInt32(bytes, 8); int numConfigurations = BitConverter.ToInt32(bytes, 16); int currentSpecPos = PSC_HEADER_SIZE + ((12 * numEntries) * numConfigurations); for (int i = 0; i < numConfigurations; i++) { PSC_Configuration config = new PSC_Configuration(); config.Index = i; int pscEntryOffset = PSC_HEADER_SIZE + ((12 * numEntries) * i); for (int a = 0; a < numEntries; a++) { PSC_Entry pscEntry = new PSC_Entry(); pscEntry.Index = BitConverter.ToInt32(bytes, pscEntryOffset + 0).ToString(); int numSpec = BitConverter.ToInt32(bytes, pscEntryOffset + 4); for (int s = 0; s < numSpec; s++) { pscEntry.PscSpecEntries.Add(PSC_SpecEntry.Read(bytes, currentSpecPos)); currentSpecPos += 196; } config.PscEntries.Add(pscEntry); pscEntryOffset += 12; } pscFile.Configurations.Add(config); } return(pscFile); }