public override void WriteTo(BinaryWriter w, Apk.Version v) { text.WriteTo(w); w.Write(maintainTextAlignment); w.AlignStream(); w.WriteAlignedString(key); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.Write(r); w.Write(g); w.Write(b); w.Write(a); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(name); w.Write(forcedFallbackFormat); w.Write(downscaleFallback); w.Write(width); w.Write(height); w.Write(completeImageSize); w.Write(textureFormat); w.Write(mipCount); w.Write(isReadable); w.Write(streamingMips); w.AlignStream(); w.Write(streamingMipsPriority); w.Write(imageCount); w.Write(textureDimension); w.Write(filterMode); w.Write(anisotropic); w.Write(mipBias); w.Write(wrapU); w.Write(wrapV); w.Write(wrapW); w.Write(lightmapFormat); w.Write(colorSpace); w.WritePrefixedBytes(imageData); w.Write(offset); w.Write(size); w.WriteAlignedString(path); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { topPos.WriteTo(w); bottomPos.WriteTo(w); handlePos.WriteTo(w); vrController.WriteTo(w); saberTypeObject.WriteTo(w); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { gameObject.WriteTo(w); w.Write(enabled); script.WriteTo(w); w.WriteAlignedString(name); data.WriteTo(w, v); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { gameObject.WriteTo(w); localRotation.WriteTo(w); localPosition.WriteTo(w); localScale.WriteTo(w); w.WritePrefixedList(children, c => c.WriteTo(w)); parent.WriteTo(w); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { polyglotDocument.WriteTo(w); customDocument.WriteTo(w); w.WritePrefixedList(inputFiles, f => f.WriteTo(w)); w.Write(selectedLanguage); w.Write(fallbackLanguage); localize.WriteTo(w); }
public BeatmapDataBehaviorData(BinaryReader reader, int length, Apk.Version v) { jsonData = reader.ReadAlignedString(); if (v < Apk.Version.V1_1_0) { signature = reader.ReadPrefixedBytes(); projectedData = reader.ReadPrefixedBytes(); } }
private SerializedAssets TestRoundTrips(byte[] data, string name, Apk.Version v) { // File.WriteAllBytes($"../../../../testoutput/{name}.before.asset", data); SerializedAssets assets = SerializedAssets.FromBytes(data, v); Assert.NotEmpty(assets.types); Assert.NotEmpty(assets.objects); byte[] outData = assets.ToBytes(); // File.WriteAllBytes($"../../../../testoutput/{name}.after.asset", outData); Assert.True(System.Linq.Enumerable.SequenceEqual(data, outData)); return(assets); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.Write(components.Length); foreach (AssetPtr p in components) { p.WriteTo(w); } w.Write(layer); w.WriteAlignedString(name); w.Write(tag); w.Write(isActive); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(packID); w.WriteAlignedString(packName); coverImage.WriteTo(w); if (v < Apk.Version.V1_1_0) { w.Write(isPackAlwaysOwned); w.AlignStream(); } beatmapLevelCollection.WriteTo(w); }
public LevelPackBehaviorData(BinaryReader reader, int length, Apk.Version v) { packID = reader.ReadAlignedString(); packName = reader.ReadAlignedString(); coverImage = new AssetPtr(reader); if (v < Apk.Version.V1_1_0) { isPackAlwaysOwned = Convert.ToBoolean(reader.ReadByte()); reader.AlignStream(); } beatmapLevelCollection = new AssetPtr(reader); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { material.WriteTo(w); color.WriteTo(w, v); w.Write(raycastTarget); w.AlignStream(); cullState.WriteTo(w); w.WriteAlignedString(text); w.Write(rightToLeft); w.AlignStream(); fontAsset.WriteTo(w); w.Write(remainingData); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(jsonData); if (signature != null && projectedData != null) { w.WritePrefixedBytes(signature); w.WritePrefixedBytes(projectedData); } // The base game omits these, which causes a bunch of Unity // warnings, but we try to round-trip assets files so don't force them // else { // w.WritePrefixedBytes(new byte[0]); // w.WritePrefixedBytes(new byte[0]); // } }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(name); foreach (float f in floats) { w.Write(f); } w.Write(extrude); w.Write(isPolygon); w.AlignStream(); w.Write(guid); w.Write(second); w.WritePrefixedList(atlasTags, a => a.WriteTo(w)); spriteAtlas.WriteTo(w); texture.WriteTo(w); w.Write(bytesAfterTexture); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(levelID); w.WriteAlignedString(songName); w.WriteAlignedString(songSubName); w.WriteAlignedString(songAuthorName); w.WriteAlignedString(levelAuthorName); audioClip.WriteTo(w); w.Write(beatsPerMinute); w.Write(songTimeOffset); w.Write(shuffle); w.Write(shufflePeriod); w.Write(previewStartTime); w.Write(previewDuration); coverImage.WriteTo(w); environment.WriteTo(w); w.WritePrefixedList(difficultyBeatmapSets, x => x.WriteTo(w)); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(name); w.Write(loadType); w.Write(channels); w.Write(frequency); w.Write(bitsPerSample); w.Write(length); w.Write(isTracker); w.AlignStream(); w.Write(subsoundIndex); w.Write(preloadAudio); w.Write(backgroundLoad); w.Write(legacy3D); w.AlignStream(); w.WriteAlignedString(source); w.Write(offset); w.Write(size); w.Write(compressionFormat); }
public static BeatmapDataBehaviorData FromJsonFile(string path, Apk.Version v) { string jsonData = File.ReadAllText(path); if (v < Apk.Version.V1_1_0) { BeatmapSaveData saveData = JsonConvert.DeserializeObject <BeatmapSaveData>(jsonData); byte[] projectedData = saveData.SerializeToBinary(); return(new BeatmapDataBehaviorData() { jsonData = "", signature = new byte[128], // all zeros projectedData = projectedData, }); } else { return(new BeatmapDataBehaviorData() { jsonData = jsonData, }); } }
public abstract void WriteTo(BinaryWriter w, Apk.Version v);
public MonoBehaviorAssetData( BinaryReader reader, int length, SerializedAssets.TypeRef typeRef, Apk.Version version ) { int startOffset = (int)reader.BaseStream.Position; gameObject = new AssetPtr(reader); enabled = reader.ReadInt32(); script = new AssetPtr(reader); name = reader.ReadAlignedString(); int headerLen = (int)reader.BaseStream.Position - startOffset; if (typeRef.scriptID.SequenceEqual(LevelBehaviorData.ScriptID)) { data = new LevelBehaviorData(reader, length - headerLen); return; } if (typeRef.scriptID.SequenceEqual(LevelCollectionBehaviorData.ScriptID)) { data = new LevelCollectionBehaviorData(reader, length - headerLen); return; } if (typeRef.scriptID.SequenceEqual(BeatmapDataBehaviorData.ScriptID)) { data = new BeatmapDataBehaviorData(reader, length - headerLen, version); return; } if (typeRef.scriptID.SequenceEqual(LevelPackBehaviorData.ScriptID)) { data = new LevelPackBehaviorData(reader, length - headerLen, version); return; } if (typeRef.scriptID.SequenceEqual(ColorManager.ScriptID)) { data = new ColorManager(reader, length - headerLen); return; } if (typeRef.scriptID.SequenceEqual(SimpleColor.ScriptID)) { data = new SimpleColor(reader, length - headerLen); return; } if (typeRef.scriptID.SequenceEqual(BeatmapLevelPackCollection.ScriptID)) { data = new BeatmapLevelPackCollection(reader, length - headerLen); return; } if (typeRef.scriptID.SequenceEqual(AlwaysOwnedBehaviorData.ScriptID)) { data = new AlwaysOwnedBehaviorData(reader, length - headerLen); return; } switch (script.pathID) { default: data = new UnknownBehaviorData(reader, length - headerLen); break; } if (!(data is UnknownBehaviorData)) { Console.WriteLine($"Type: {data.GetType()} ScriptHash: {BitConverter.ToString(typeRef.scriptID).Replace("-", "")}"); } }
public SerializedAssets(Stream stream, Apk.Version v) { apkVersion = v; BinaryReader reader = new BinaryReader(stream); // ===== Parse Header int metadataSize = reader.ReadInt32BE(); int fileSize = reader.ReadInt32BE(); int generation = reader.ReadInt32BE(); if (generation != parsedGeneration) { throw new ParseException("Unsupported format version"); } int dataOffset = reader.ReadInt32BE(); int isBigEndian = reader.ReadInt32BE(); if (isBigEndian != 0) { throw new ParseException("Must be little endian"); } paddingLen = dataOffset - (metadataSize + headerLen); // ===== Parse Metadata version = reader.ReadStringToNull(); if (version != "2018.3.10f1") { throw new ParseException("Unsupported Unity version"); } targetPlatform = reader.ReadInt32(); enableTypeTree = reader.ReadBoolean(); if (enableTypeTree) { throw new ParseException("Type trees aren't supported"); } types = reader.ReadPrefixedList(r => new TypeRef(r)); objects = reader.ReadPrefixedList(r => new AssetObject(r)); scripts = reader.ReadPrefixedList(r => new Script(r)); externals = reader.ReadPrefixedList(r => new External(r)); // this is necessary to get headerLen+metadataSize to match up with offset if (reader.ReadByte() != 0) { throw new ParseException("Expected metadata to end with 0"); } if (!reader.ReadAllZeros(paddingLen)) { throw new ParseException("Expected zeros for padding"); } Debug.Assert(reader.BaseStream.Position == dataOffset, "Parsed metadata wrong"); // ===== Extra stuff scriptIDToScriptPtr = new Dictionary <byte[], AssetPtr>(new ByteArrayComparer()); environmentIDToPtr = new Dictionary <string, AssetPtr>(); assetTypeToTypeID = new Dictionary <Type, int>(); scriptTypeToTypeID = new Dictionary <Type, int>(); // ===== Parse Data for (int i = 0; i < objects.Count - 1; i++) { objects[i].paddingLen = objects[i + 1].offset - (objects[i].offset + objects[i].size); } // I've never seen any padding after the last object but handle it just in case AssetObject last = objects[objects.Count - 1]; int dataSize = fileSize - dataOffset; last.paddingLen = dataSize - (last.offset + last.size); foreach (AssetObject obj in objects) { // Console.WriteLine((reader.BaseStream.Position-dataOffset, obj.offset, obj.size)); if (reader.BaseStream.Position - dataOffset != obj.offset) { throw new ParseException("Objects aren't in order"); } long startOffset = reader.BaseStream.Position; if (types.Count <= obj.typeID) { // Console.WriteLine($"TypeID of SimpleColor: {objects[52].typeID} with type: {objects[52].data.GetType()}"); throw new ParseException($"Could not find typeID: {obj.typeID}, maximum is: {types.Count}"); } switch (types[obj.typeID].classID) { case MonoBehaviorAssetData.ClassID: byte[] scriptID = types[obj.typeID].scriptID; var monob = new MonoBehaviorAssetData(reader, obj.size, types[obj.typeID], apkVersion); scriptTypeToTypeID[monob.data.GetType()] = obj.typeID; scriptIDToScriptPtr[scriptID] = monob.script; obj.data = monob; break; case AudioClipAssetData.ClassID: obj.data = new AudioClipAssetData(reader, obj.size); break; case Texture2DAssetData.ClassID: obj.data = new Texture2DAssetData(reader, obj.size); break; case SpriteAssetData.ClassID: obj.data = new SpriteAssetData(reader, obj.size); break; case GameObjectAssetData.ClassID: obj.data = new GameObjectAssetData(reader, obj.size); break; case MeshFilterAssetData.ClassID: obj.data = new MeshFilterAssetData(reader, obj.size); break; case TextAssetData.ClassID: obj.data = new TextAssetData(reader, obj.size); break; default: obj.data = new UnknownAssetData(reader, obj.size); break; } assetTypeToTypeID[obj.data.GetType()] = obj.typeID; long bytesParsed = reader.BaseStream.Position - startOffset; if (bytesParsed != obj.size) { throw new ParseException($"Parsed {bytesParsed} bytes but expected {obj.size} for path ID {obj.pathID}"); } if (!reader.ReadAllZeros(obj.paddingLen)) { throw new ParseException("Expected zeros for padding"); } } FindEnvironmentPointers(); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WriteAlignedString(name); w.WriteAlignedString(script); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WritePrefixedList(levels, x => x.WriteTo(w)); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { leftSaber.WriteTo(w); rightSaber.WriteTo(w); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.WritePrefixedList(beatmapLevelPacks, a => a.WriteTo(w)); w.WritePrefixedList(previewBeatmapLevelPack, a => a.WriteTo(w)); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { gameObject.WriteTo(w); mesh.WriteTo(w); }
public static SerializedAssets FromBytes(byte[] data, Apk.Version v) { using (Stream stream = new MemoryStream(data)) { return(new SerializedAssets(stream, v)); } }
public override void WriteTo(BinaryWriter w, Apk.Version v) { playerModel.WriteTo(w); colorA.WriteTo(w); colorB.WriteTo(w); }
public override void WriteTo(BinaryWriter w, Apk.Version v) { w.Write(bytes); }