thief-mission-viewer/project/code/LGS/Database/Chunks/Property.cs

96 lines
2.0 KiB
C#

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<T> : IChunk where T : Property, new()
{
public ChunkHeader Header { get; set; }
public List<T> properties;
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
{
properties = new List<T>();
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();
}
}