Compare commits
No commits in common. "b9172df8c3792ad30678561f59291629b55f5034" and "eaf20f7f4a7bd88dd5ea9b1fd2670ed232893ebd" have entirely different histories.
b9172df8c3
...
eaf20f7f4a
|
@ -1,125 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Numerics;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace KeepersCompound.LGS.Database.Chunks;
|
|
||||||
|
|
||||||
public class BrList : IChunk
|
|
||||||
{
|
|
||||||
// TODO: Add better handling of the different brush types
|
|
||||||
public record Brush
|
|
||||||
{
|
|
||||||
public enum Media
|
|
||||||
{
|
|
||||||
Room = 0xFB,
|
|
||||||
Flow = 0xFC,
|
|
||||||
Object = 0xFD,
|
|
||||||
Area = 0xFE,
|
|
||||||
Light = 0xFF,
|
|
||||||
FillSolid = 0x00,
|
|
||||||
FillAir = 0x01,
|
|
||||||
FillWater = 0x02,
|
|
||||||
Flood = 0x03,
|
|
||||||
Evaporate = 0x04,
|
|
||||||
SolidToWater = 0x05,
|
|
||||||
SolidToAir = 0x06,
|
|
||||||
AirToSolid = 0x07,
|
|
||||||
WaterToSolid = 0x08,
|
|
||||||
Blockable = 0x09,
|
|
||||||
};
|
|
||||||
|
|
||||||
public record TexInfo
|
|
||||||
{
|
|
||||||
public short id;
|
|
||||||
public ushort rot;
|
|
||||||
public short scale;
|
|
||||||
public ushort x;
|
|
||||||
public ushort y;
|
|
||||||
|
|
||||||
public TexInfo(BinaryReader reader)
|
|
||||||
{
|
|
||||||
id = reader.ReadInt16();
|
|
||||||
rot = reader.ReadUInt16();
|
|
||||||
scale = reader.ReadInt16();
|
|
||||||
x = reader.ReadUInt16();
|
|
||||||
y = reader.ReadUInt16();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public short id;
|
|
||||||
public short time;
|
|
||||||
public uint brushInfo;
|
|
||||||
public short textureId;
|
|
||||||
public Media media;
|
|
||||||
public sbyte flags;
|
|
||||||
public Vector3 position;
|
|
||||||
public Vector3 size;
|
|
||||||
public Vector3 angle;
|
|
||||||
public short currentFaceIndex;
|
|
||||||
public float gridLineSpacing;
|
|
||||||
public Vector3 gridPhaseShift;
|
|
||||||
public Vector3 gridOrientation;
|
|
||||||
public bool gridEnabled;
|
|
||||||
public byte numFaces;
|
|
||||||
public sbyte edgeSelected;
|
|
||||||
public sbyte pointSelected;
|
|
||||||
public sbyte useFlag;
|
|
||||||
public sbyte groupId;
|
|
||||||
public TexInfo[] txs;
|
|
||||||
|
|
||||||
public Brush(BinaryReader reader)
|
|
||||||
{
|
|
||||||
id = reader.ReadInt16();
|
|
||||||
time = reader.ReadInt16();
|
|
||||||
brushInfo = reader.ReadUInt32();
|
|
||||||
textureId = reader.ReadInt16();
|
|
||||||
media = (Media)reader.ReadByte();
|
|
||||||
flags = reader.ReadSByte();
|
|
||||||
position = reader.ReadVec3();
|
|
||||||
size = reader.ReadVec3();
|
|
||||||
angle = new Vector3(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
|
|
||||||
currentFaceIndex = reader.ReadInt16();
|
|
||||||
gridLineSpacing = reader.ReadSingle();
|
|
||||||
gridPhaseShift = reader.ReadVec3();
|
|
||||||
gridOrientation = new Vector3(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
|
|
||||||
gridEnabled = reader.ReadBoolean();
|
|
||||||
numFaces = reader.ReadByte();
|
|
||||||
edgeSelected = reader.ReadSByte();
|
|
||||||
pointSelected = reader.ReadSByte();
|
|
||||||
useFlag = reader.ReadSByte();
|
|
||||||
groupId = reader.ReadSByte();
|
|
||||||
reader.ReadBytes(4);
|
|
||||||
if ((sbyte)media >= 0)
|
|
||||||
{
|
|
||||||
txs = new TexInfo[numFaces];
|
|
||||||
for (var i = 0; i < numFaces; i++)
|
|
||||||
{
|
|
||||||
txs[i] = new TexInfo(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
txs = Array.Empty<TexInfo>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChunkHeader Header { get; set; }
|
|
||||||
public List<Brush> Brushes { get; set; }
|
|
||||||
|
|
||||||
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
|
|
||||||
{
|
|
||||||
Brushes = new List<Brush>();
|
|
||||||
while (reader.BaseStream.Position < entry.Offset + entry.Size + 24)
|
|
||||||
{
|
|
||||||
Brushes.Add(new Brush(reader));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteData(BinaryWriter writer)
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -100,7 +100,6 @@ public class DbFile
|
||||||
// "AICONVERSE" => new AiConverseChunk(),
|
// "AICONVERSE" => new AiConverseChunk(),
|
||||||
"TXLIST" => new TxList(),
|
"TXLIST" => new TxList(),
|
||||||
"WREXT" => new WorldRep(),
|
"WREXT" => new WorldRep(),
|
||||||
"BRLIST" => new BrList(),
|
|
||||||
_ => new GenericChunk(),
|
_ => new GenericChunk(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,6 @@ public partial class Mission : Node3D
|
||||||
_file = new(FileName);
|
_file = new(FileName);
|
||||||
UseChunk<TxList>("TXLIST", LoadTextures);
|
UseChunk<TxList>("TXLIST", LoadTextures);
|
||||||
UseChunk<WorldRep>("WREXT", BuildWrMeshes);
|
UseChunk<WorldRep>("WREXT", BuildWrMeshes);
|
||||||
UseChunk<BrList>("BRLIST", PlaceObjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UseChunk<T>(string name, Action<T> action)
|
private void UseChunk<T>(string name, Action<T> action)
|
||||||
|
@ -109,24 +108,6 @@ public partial class Mission : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlaceObjects(BrList brList)
|
|
||||||
{
|
|
||||||
foreach (var brush in brList.Brushes)
|
|
||||||
{
|
|
||||||
if (brush.media != BrList.Brush.Media.Object)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = brush.position.ToGodotVec3();
|
|
||||||
var cube = new CsgBox3D
|
|
||||||
{
|
|
||||||
Position = pos
|
|
||||||
};
|
|
||||||
AddChild(cube);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BuildWrMeshes(WorldRep worldRep)
|
private void BuildWrMeshes(WorldRep worldRep)
|
||||||
{
|
{
|
||||||
var cells = worldRep.Cells;
|
var cells = worldRep.Cells;
|
||||||
|
|
Loading…
Reference in New Issue