2024-08-24 10:33:35 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
2024-08-25 10:53:50 +00:00
|
|
|
using System.Numerics;
|
2024-08-24 10:33:35 +00:00
|
|
|
|
|
|
|
namespace KeepersCompound.LGS.Database.Chunks;
|
|
|
|
|
2024-08-25 12:07:49 +00:00
|
|
|
public class Property
|
2024-08-24 10:33:35 +00:00
|
|
|
{
|
2024-08-25 12:07:49 +00:00
|
|
|
public int objectId;
|
|
|
|
public int length;
|
2024-08-24 10:33:35 +00:00
|
|
|
|
2024-08-25 12:07:49 +00:00
|
|
|
public virtual void Read(BinaryReader reader)
|
|
|
|
{
|
|
|
|
objectId = reader.ReadInt32();
|
|
|
|
length = (int)reader.ReadUInt32();
|
2024-08-24 10:33:35 +00:00
|
|
|
}
|
2024-08-25 12:07:49 +00:00
|
|
|
}
|
2024-08-24 10:33:35 +00:00
|
|
|
|
2024-09-07 08:05:45 +00:00
|
|
|
public class PropertyChunk<T> : IChunk, IMergable where T : Property, new()
|
2024-08-25 12:07:49 +00:00
|
|
|
{
|
2024-08-24 10:33:35 +00:00
|
|
|
public ChunkHeader Header { get; set; }
|
2024-08-25 12:07:49 +00:00
|
|
|
public List<T> properties;
|
2024-08-24 10:33:35 +00:00
|
|
|
|
|
|
|
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
|
|
|
|
{
|
2024-08-25 12:07:49 +00:00
|
|
|
properties = new List<T>();
|
2024-08-24 10:33:35 +00:00
|
|
|
while (reader.BaseStream.Position < entry.Offset + entry.Size + 24)
|
|
|
|
{
|
2024-08-25 12:07:49 +00:00
|
|
|
var prop = new T();
|
|
|
|
prop.Read(reader);
|
|
|
|
properties.Add(prop);
|
2024-08-24 10:33:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-25 10:53:50 +00:00
|
|
|
public void WriteData(BinaryWriter writer)
|
|
|
|
{
|
|
|
|
throw new System.NotImplementedException();
|
|
|
|
}
|
2024-09-07 08:05:45 +00:00
|
|
|
|
|
|
|
public void Merge(IMergable other)
|
|
|
|
{
|
|
|
|
properties.AddRange(((PropertyChunk<T>)other).properties);
|
|
|
|
}
|
2024-08-25 10:53:50 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 12:09:45 +00:00
|
|
|
public class PropGeneric : Property
|
|
|
|
{
|
|
|
|
public byte[] data;
|
|
|
|
|
|
|
|
public override void Read(BinaryReader reader)
|
|
|
|
{
|
|
|
|
base.Read(reader);
|
|
|
|
data = reader.ReadBytes(length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-07 09:48:30 +00:00
|
|
|
public class PropLabel : Property
|
2024-08-25 10:53:50 +00:00
|
|
|
{
|
2024-09-07 09:48:30 +00:00
|
|
|
public string value;
|
2024-08-25 10:53:50 +00:00
|
|
|
|
2024-08-25 12:07:49 +00:00
|
|
|
public override void Read(BinaryReader reader)
|
2024-08-25 10:53:50 +00:00
|
|
|
{
|
2024-08-25 12:07:49 +00:00
|
|
|
base.Read(reader);
|
2024-09-07 09:48:30 +00:00
|
|
|
value = reader.ReadNullString(length);
|
2024-08-25 10:53:50 +00:00
|
|
|
}
|
2024-08-25 12:07:49 +00:00
|
|
|
}
|
2024-08-25 10:53:50 +00:00
|
|
|
|
2024-09-07 09:48:30 +00:00
|
|
|
public class PropString : Property
|
2024-08-25 12:07:49 +00:00
|
|
|
{
|
2024-09-07 09:48:30 +00:00
|
|
|
public int stringLength;
|
|
|
|
public string value;
|
2024-08-25 12:07:49 +00:00
|
|
|
|
|
|
|
public override void Read(BinaryReader reader)
|
2024-08-24 10:33:35 +00:00
|
|
|
{
|
2024-08-25 12:07:49 +00:00
|
|
|
base.Read(reader);
|
2024-09-07 09:48:30 +00:00
|
|
|
stringLength = reader.ReadInt32();
|
|
|
|
value = reader.ReadNullString(stringLength);
|
2024-08-24 10:33:35 +00:00
|
|
|
}
|
2024-08-25 12:07:49 +00:00
|
|
|
}
|
2024-08-25 12:21:27 +00:00
|
|
|
|
2024-09-07 09:48:30 +00:00
|
|
|
public class PropFloat : Property
|
2024-08-25 12:21:27 +00:00
|
|
|
{
|
2024-09-07 09:48:30 +00:00
|
|
|
public float value;
|
2024-08-25 12:21:27 +00:00
|
|
|
|
|
|
|
public override void Read(BinaryReader reader)
|
|
|
|
{
|
|
|
|
base.Read(reader);
|
2024-09-07 09:48:30 +00:00
|
|
|
value = reader.ReadSingle();
|
2024-08-25 12:21:27 +00:00
|
|
|
}
|
|
|
|
}
|
2024-08-31 08:34:18 +00:00
|
|
|
|
2024-09-07 09:48:30 +00:00
|
|
|
public class PropScale : Property
|
2024-08-31 08:34:18 +00:00
|
|
|
{
|
2024-09-07 09:48:30 +00:00
|
|
|
public Vector3 scale;
|
2024-08-31 08:34:18 +00:00
|
|
|
|
|
|
|
public override void Read(BinaryReader reader)
|
|
|
|
{
|
|
|
|
base.Read(reader);
|
2024-09-07 09:48:30 +00:00
|
|
|
scale = reader.ReadVec3();
|
2024-08-31 08:34:18 +00:00
|
|
|
}
|
|
|
|
}
|
2024-09-07 07:30:26 +00:00
|
|
|
|
2024-09-07 09:48:30 +00:00
|
|
|
public class PropRenderType : Property
|
2024-09-07 07:30:26 +00:00
|
|
|
{
|
2024-09-07 09:48:30 +00:00
|
|
|
public enum Mode
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
NotRendered,
|
|
|
|
Unlit,
|
|
|
|
EditorOnly,
|
|
|
|
CoronaOnly,
|
|
|
|
}
|
|
|
|
|
|
|
|
public Mode mode;
|
2024-09-07 07:30:26 +00:00
|
|
|
|
|
|
|
public override void Read(BinaryReader reader)
|
|
|
|
{
|
|
|
|
base.Read(reader);
|
2024-09-07 09:48:30 +00:00
|
|
|
mode = (Mode)reader.ReadUInt32();
|
2024-09-07 07:30:26 +00:00
|
|
|
}
|
2024-09-07 09:48:30 +00:00
|
|
|
}
|