public static EleGraphicalData ReadFromStream(int id, EleInstance instance, BigEndianReader reader) { var type = (EleGraphicalElementTypes)reader.ReadByte(); switch (type) { case EleGraphicalElementTypes.ANIMATED: return(AnimatedGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.BLENDED: return(BlendedGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.BOUNDING_BOX: return(BoundingBoxGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.ENTITY: return(EntityGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.NORMAL: return(NormalGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.PARTICLES: return(ParticlesGraphicalElementData.ReadFromStream(instance, id, reader)); default: throw new Exception("Unknown graphical data of type " + type); } }
public EleInstance ReadElements() { m_reader.Seek(0, SeekOrigin.Begin); int header = m_reader.ReadByte(); if (header != 69) { try { m_reader.Seek(0, SeekOrigin.Begin); var output = new MemoryStream(); ZipHelper.Deflate(new MemoryStream(m_reader.ReadBytes((int)m_reader.BytesAvailable)), output); var uncompress = output.ToArray(); if (uncompress.Length <= 0 || uncompress[0] != 69) { throw new FileLoadException("Wrong header file"); } ChangeStream(new MemoryStream(uncompress)); m_reader.SkipBytes(1); } catch (Exception) { throw new FileLoadException("Wrong header file"); } } var instance = EleInstance.ReadFromStream(m_reader); return(instance); }
public static EleInstance ReadFromStream(BigEndianReader reader) { var instance = new EleInstance(); int skypLen = 0; instance.Version = reader.ReadByte(); var count = reader.ReadUInt(); for (int i = 0; i < count; i++) { if (instance.Version >= 9) { skypLen = reader.ReadUShort(); } var id = reader.ReadInt(); if (instance.Version <= 8 || !instance.m_lazyLoad) { instance.m_indexes.Add(id, (int)reader.Position); var elem = EleGraphicalData.ReadFromStream(id, instance, reader); instance.GraphicalDatas.Add(elem.Id, elem); } else { // never go there atm instance.m_indexes.Add(id, (int)reader.Position); reader.SkipBytes(skypLen - 4); } } if (instance.Version >= 8) { var gfxCount = reader.ReadInt(); for (int i = 0; i < gfxCount; i++) { instance.GfxJpgMap.Add(reader.ReadInt(), true); } } return(instance); }
public EleGraphicalData(EleInstance instance, int id) { Instance = instance; Id = id; }