public void Save(Level level, string fileName) { FileStream fs = File.Open(fileName, FileMode.Create); //Seek past the header fs.Seek(0xA0, SeekOrigin.Begin); GameplayHeader gameplayHeader = new GameplayHeader { type88Pointer = SeekWrite(fs, SerializeLevelObjects(level.type88s, Type88.ELEMENTSIZE)), levelVarPointer = SeekWrite(fs, level.levelVariables.serialize()), englishPointer = SeekWrite(fs, GetLangBytes(level.english)), lang2Pointer = SeekWrite(fs, GetLangBytes(level.lang2)), frenchPointer = SeekWrite(fs, GetLangBytes(level.french)), germanPointer = SeekWrite(fs, GetLangBytes(level.german)), spanishPointer = SeekWrite(fs, GetLangBytes(level.spanish)), italianPointer = SeekWrite(fs, GetLangBytes(level.italian)), lang7Pointer = SeekWrite(fs, GetLangBytes(level.lang7)), lang8Pointer = SeekWrite(fs, GetLangBytes(level.lang8)), type04Pointer = SeekWrite(fs, SerializeLevelObjects(level.type04s, Type04.ELEMENTSIZE)), type80Pointer = SeekWrite(fs, GetType80Bytes(level.type80s)), cameraPointer = SeekWrite(fs, SerializeLevelObjects(level.gameCameras, GameCamera.ELEMENTSIZE)), type0CPointer = SeekWrite(fs, SerializeLevelObjects(level.type0Cs, Type0C.ELEMENTSIZE)), mobyIdPointer = SeekWrite(fs, GetIdBytes(level.mobyIds)), mobyPointer = SeekWrite(fs, GetMobyBytes(level.mobs)), pvarSizePointer = SeekWrite(fs, GetPvarSizeBytes(level.pVars)), pvarPointer = SeekWrite(fs, GetPvarBytes(level.pVars)), type50Pointer = SeekWrite(fs, GetKeyValueBytes(level.type50s)), type5CPointer = SeekWrite(fs, GetKeyValueBytes(level.type5Cs)), unkPointer6 = SeekWrite(fs, level.unk6), unkPointer7 = SeekWrite(fs, level.unk7), tieIdPointer = SeekWrite(fs, GetIdBytes(level.tieIds)), tiePointer = SeekWrite(fs, level.tieData), shrubIdPointer = SeekWrite(fs, GetIdBytes(level.shrubIds)), shrubPointer = SeekWrite(fs, level.shrubData), splinePointer = SeekWrite(fs, GetSplineBytes(level.splines)), cuboidPointer = SeekWrite(fs, SerializeLevelObjects(level.cuboids, Cuboid.ELEMENTSIZE)), type64Pointer = SeekWrite(fs, SerializeLevelObjects(level.type64s, Type64.ELEMENTSIZE)), type68Pointer = SeekWrite(fs, SerializeLevelObjects(level.type68s, Type68.ELEMENTSIZE)), unkPointer12 = SeekWrite(fs, new byte[0x10]), unkPointer17 = SeekWrite(fs, level.unk17), type7CPointer = SeekWrite(fs, GetType7CBytes(level.type7Cs)), unkPointer14 = SeekWrite(fs, level.unk14), unkPointer13 = SeekWrite(fs, level.unk13), occlusionPointer = SeekWrite(fs, GetOcclusionBytes(level.occlusionData)) }; //Seek to the beginning of the file to append the updated header byte[] head = gameplayHeader.Serialize(); fs.Seek(0, SeekOrigin.Begin); fs.Write(head, 0, head.Length); fs.Close(); }
private void SaveRC3(Level level, FileStream fs) { //Seek past the header fs.Seek(0xA0, SeekOrigin.Begin); GameplayHeader gameplayHeader = new GameplayHeader { unkPointer18 = SeekWrite4(fs, level.unk18), levelVarPointer = SeekWrite4(fs, level.levelVariables.Serialize(level.game)), englishPointer = SeekWrite4(fs, GetLangBytes(level.english)), ukenglishPointer = SeekWrite4(fs, GetLangBytes(level.ukenglish)), frenchPointer = SeekWrite4(fs, GetLangBytes(level.french)), germanPointer = SeekWrite4(fs, GetLangBytes(level.german)), spanishPointer = SeekWrite4(fs, GetLangBytes(level.spanish)), italianPointer = SeekWrite4(fs, GetLangBytes(level.italian)), japanesePointer = SeekWrite4(fs, GetLangBytes(level.japanese)), koreanPointer = SeekWrite4(fs, GetLangBytes(level.korean)), lightsPointer = SeekWrite4(fs, SerializeLevelObjects(level.directionalLights, DirectionalLight.ELEMENTSIZE)), type80Pointer = SeekWrite4(fs, GetType80Bytes(level.type80s)), cameraPointer = SeekWrite4(fs, SerializeLevelObjects(level.gameCameras, GameCamera.ELEMENTSIZE)), soundPointer = SeekWrite4(fs, SerializeLevelObjects(level.type0Cs, Type0C.ELEMENTSIZE)), mobyIdPointer = SeekWrite4(fs, GetIdBytes(level.mobyIds)), mobyPointer = SeekWrite4(fs, GetMobyBytes(level.mobs, level.game)), pvarSizePointer = SeekWrite4(fs, GetPvarSizeBytes(level.pVars)), pvarPointer = SeekWrite4(fs, GetPvarBytes(level.pVars)), type50Pointer = SeekWrite4(fs, GetKeyValueBytes(level.type50s)), type5CPointer = SeekWrite4(fs, GetKeyValueBytes(level.type5Cs)), mobyGroupsPointer = SeekWrite4(fs, level.unk6), type4CPointer = SeekWrite4(fs, level.unk7), tieIdPointer = SeekWrite4(fs, GetIdBytes(level.tieIds)), tiePointer = SeekWrite4(fs, level.tieData), tieGroupsPointer = SeekWrite4(fs, level.tieGroupData), shrubIdPointer = SeekWrite4(fs, GetIdBytes(level.shrubIds)), shrubPointer = SeekWrite4(fs, level.shrubData), shrubGroupsPointer = SeekWrite4(fs, level.shrubGroupData), splinePointer = SeekWrite4(fs, GetSplineBytes(level.splines)), cuboidPointer = SeekWrite4(fs, SerializeLevelObjects(level.cuboids, Cuboid.ELEMENTSIZE)), spherePointer = SeekWrite4(fs, SerializeLevelObjects(level.spheres, Sphere.ELEMENTSIZE)), cylinderPointer = SeekWrite4(fs, SerializeLevelObjects(level.cylinders, Cylinder.ELEMENTSIZE)), unkPointer12 = SeekWrite4(fs, new byte[0x10]), unkPointer17 = SeekWrite4(fs, level.unk17), unkPointer16 = SeekWrite4(fs, level.unk16), grindPathsPointer = SeekWrite4(fs, level.unk13), areasPointer = SeekWrite4(fs, level.areasData), occlusionPointer = SeekWrite4(fs, GetOcclusionBytes(level.occlusionData)) }; //Seek to the beginning of the file to append the updated header byte[] head = gameplayHeader.Serialize(level.game); fs.Seek(0, SeekOrigin.Begin); fs.Write(head, 0, head.Length); }