using System; using System.Collections.Generic; using System.IO; using System.Numerics; using System.Text; namespace KeepersCompound.LGS.Database.Chunks; public class Property { public int objectId; public int length; public virtual void Read(BinaryReader reader) { objectId = reader.ReadInt32(); length = (int)reader.ReadUInt32(); } } public class PropertyChunk : IChunk where T : Property, new() { public ChunkHeader Header { get; set; } public List properties; public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry) { properties = new List(); while (reader.BaseStream.Position < entry.Offset + entry.Size + 24) { var prop = new T(); prop.Read(reader); properties.Add(prop); } } public void WriteData(BinaryWriter writer) { throw new System.NotImplementedException(); } } public class PropGeneric : Property { public byte[] data; public override void Read(BinaryReader reader) { base.Read(reader); data = reader.ReadBytes(length); } } public class PropModelName : Property { public string modelName; public override void Read(BinaryReader reader) { base.Read(reader); var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); modelName = tmpName[..Math.Min(length - 1, tmpName.Length)]; } } public class PropScale : Property { public Vector3 scale; public override void Read(BinaryReader reader) { base.Read(reader); scale = reader.ReadVec3(); } } public class PropRenderType : Property { public enum Mode { Normal, NotRendered, Unlit, EditorOnly, CoronaOnly, } public Mode mode; public override void Read(BinaryReader reader) { base.Read(reader); mode = (Mode)reader.ReadUInt32(); } } public class PropString : Property { public string value; public override void Read(BinaryReader reader) { base.Read(reader); value = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty); } }