public byte[] GetFileContentBytes(FilePointer filePointer) { //This is kind of dangerous, we can reach limit of ram byte[] bytes = new byte[filePointer.FileSize]; long totalReadBytes = 0; long bytesToRead = filePointer.FileSize; using (BinaryReader binReader = new BinaryReader(_fileStream, new UTF8Encoding(), true)) { binReader.BaseStream.Seek(filePointer.FileDataOffset, SeekOrigin.Begin); while (bytesToRead > 0) { int chunk = unchecked ((int)bytesToRead); if (bytesToRead > int.MaxValue) { chunk = int.MaxValue; } bytesToRead -= chunk; byte[] readBytes = binReader.ReadBytes(chunk); Array.Copy(readBytes, 0, bytes, totalReadBytes, chunk); totalReadBytes += chunk; } } return(bytes); }
private GameMaterial FindMaterial(FilePointer fp) { if (_materialObjects.ContainsKey(fp.PathID)) { return(_materialObjects[fp.PathID]); } else { return(null); } }
public Transform(BinaryBlock b) { GameObject = new FilePointer(b.ReadInt(), b.ReadLong()); LocalRotation = new QuaternionF(b.ReadFloat(), b.ReadFloat(), b.ReadFloat(), b.ReadFloat()); LocalPosition = new Vector3F(b.ReadFloat(), b.ReadFloat(), b.ReadFloat()); LocalScale = new Vector3F(b.ReadFloat(), b.ReadFloat(), b.ReadFloat()); Children = new List <FilePointer>(); var size = b.ReadInt(); for (int i = 0; i < size; i++) { Children.Add(new FilePointer(b.ReadInt(), b.ReadLong())); } Parent = new FilePointer(b.ReadInt(), b.ReadLong()); }
public AssetBundle(BinaryBlock b) { var nameSize = b.ReadInt(); Name = b.ReadFixedString(nameSize); b.Align(4); _nameless = new List <FilePointer>(); _preload = new List <FilePointer>(); var preSize = b.ReadInt(); for (int i = 0; i < preSize; i++) { _preload.Add(new FilePointer(b.ReadInt(), b.ReadLong())); } _container = new Dictionary <string, FilePointer>(); var containerSize = b.ReadInt(); for (int i = 0; i < containerSize; i++) { var len = b.ReadInt(); var str = b.ReadFixedString(len); b.Align(4); var idx = b.ReadInt(); var size = b.ReadInt(); var file = new FilePointer(b.ReadInt(), b.ReadLong()); if (string.IsNullOrWhiteSpace(str)) { _nameless.Add(file); } else if (_container.ContainsKey(str)) { Logger.Log(LogLevel.ERROR, "Duplicate AssetBundle entry for {0} -> {1}", str, file.PathID); } else { _container[str] = file; } } // Skip MainAsset info (not used here) }
public CardDef(BinaryBlock b) { GameObject = new FilePointer(b.ReadInt(), b.ReadLong()); Enabled = b.ReadUnsignedByte() == 1 ? true : false; b.Align(4); MonoScript = new FilePointer(b.ReadInt(), b.ReadLong()); try { var unknown = b.ReadInt(); int size = b.ReadInt(); PortratitTexturePath = b.ReadFixedString(size); b.Align(4); size = b.ReadInt(); PremiumPortraitMaterialPath = b.ReadFixedString(size); b.Align(4); var unknown2 = b.ReadInt(); DeckCardBarPortrait = new FilePointer(b.ReadInt(), b.ReadLong()); EnchantmentPortrait = new FilePointer(b.ReadInt(), b.ReadLong()); HistoryTileHalfPortrait = new FilePointer(b.ReadInt(), b.ReadLong()); HistoryTileFullPortrait = new FilePointer(b.ReadInt(), b.ReadLong()); // Ignore rest of the file } catch (Exception e) { Logger.Log(LogLevel.DEBUG, $"CardDef Load failed {GameObject.PathID}, {MonoScript.PathID} ({e.Message})"); FailedToLoad = true; } }
public Material(BinaryBlock b) { int size = b.ReadInt(); Name = b.ReadFixedString(size); b.Align(4); var s1 = b.ReadInt(); //b.Align(4); var s2 = b.ReadLong(); Shader = new FilePointer(s1, s2); size = b.ReadInt(); ShaderKeywords = b.ReadFixedString(size); b.Align(4); LightmapFlags = b.ReadUnsignedInt(); CustomRenderQueue = b.ReadInt(); TagMap = new Dictionary <string, string>(); size = b.ReadInt(); for (int i = 0; i < size; i++) { var fsize = b.ReadInt(); var key = b.ReadFixedString(fsize); b.Align(4); fsize = b.ReadInt(); var value = b.ReadFixedString(fsize); b.Align(4); TagMap[key] = value; } b.Align(4); TexEnvs = new Dictionary <string, UnityTexEnv>(); size = b.ReadInt(); for (int i = 0; i < size; i++) { var ute = new UnityTexEnv(); var fsize = b.ReadInt(); var key = b.ReadFixedString(fsize); b.Align(4); ute.Texture = new FilePointer(b.ReadInt(), b.ReadLong()); ute.Scale = new Vector2F(b.ReadFloat(), b.ReadFloat()); ute.Offset = new Vector2F(b.ReadFloat(), b.ReadFloat()); TexEnvs[key] = ute; } b.Align(4); Floats = new Dictionary <string, float>(); size = b.ReadInt(); for (int i = 0; i < size; i++) { var fsize = b.ReadInt(); var key = b.ReadFixedString(fsize); b.Align(4); Floats[key] = b.ReadFloat(); } b.Align(4); Colors = new Dictionary <string, ColorRGBA>(); size = b.ReadInt(); for (int i = 0; i < size; i++) { var fsize = b.ReadInt(); var key = b.ReadFixedString(fsize); b.Align(4); var cr = b.ReadFloat(); //b.Align(4); var cg = b.ReadFloat(); //b.Align(4); var cb = b.ReadFloat(); //b.Align(4); var ca = b.ReadFloat(); //b.Align(4); Colors[key] = new ColorRGBA(cr, cg, cb, ca); } b.Align(4); }