mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-03-11 12:59:30 +08:00
Created MloArchetype and TimeArchetype subclasses, Meta pointer improvement
This commit is contained in:
parent
7ddd88e561
commit
f974c9eb49
@ -997,15 +997,15 @@ namespace CodeWalker.GameFiles
|
|||||||
////not ideal: should transform all 8 corners!
|
////not ideal: should transform all 8 corners!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Archetype.IsMloArchetype)
|
if (Archetype.Type == MetaName.CMloArchetypeDef)
|
||||||
{
|
{
|
||||||
//transform interior entities into world space...
|
//transform interior entities into world space...
|
||||||
var mlod = Archetype.MloData;
|
var mloa = Archetype as MloArchetype;
|
||||||
if (MloInstance == null)
|
if (MloInstance == null)
|
||||||
{
|
{
|
||||||
MloInstance = new MloInstanceData();
|
MloInstance = new MloInstanceData();
|
||||||
}
|
}
|
||||||
MloInstance.CreateYmapEntities(this, mlod);
|
MloInstance.CreateYmapEntities(this, mloa);
|
||||||
|
|
||||||
if (BSRadius == 0.0f)
|
if (BSRadius == 0.0f)
|
||||||
{
|
{
|
||||||
|
@ -83,61 +83,65 @@ namespace CodeWalker.GameFiles
|
|||||||
for (int i = 0; i < ptrs.Length; i++)
|
for (int i = 0; i < ptrs.Length; i++)
|
||||||
{
|
{
|
||||||
var ptr = ptrs[i];
|
var ptr = ptrs[i];
|
||||||
int blocki = ptr.BlockID - 1;
|
var offset = ptr.Offset;
|
||||||
int offset = ptr.ItemOffset * 16;//block data size...
|
var block = Meta.GetBlock(ptr.BlockID);
|
||||||
if (blocki >= Meta.DataBlocks.Count)
|
if (block == null)
|
||||||
{ continue; }
|
{ continue; }
|
||||||
var block = Meta.DataBlocks[blocki];
|
|
||||||
if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length))
|
if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length))
|
||||||
{ continue; }
|
{ continue; }
|
||||||
|
|
||||||
var ba = new Archetype();
|
Archetype a = null;
|
||||||
switch (block.StructureNameHash)
|
switch (block.StructureNameHash)
|
||||||
{
|
{
|
||||||
case MetaName.CBaseArchetypeDef:
|
case MetaName.CBaseArchetypeDef:
|
||||||
var basearch = PsoTypes.ConvertDataRaw<CBaseArchetypeDef>(block.Data, offset);
|
var basearch = PsoTypes.ConvertDataRaw<CBaseArchetypeDef>(block.Data, offset);
|
||||||
ba.Init(this, ref basearch);
|
a = new Archetype();
|
||||||
ba.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
|
a.Init(this, ref basearch);
|
||||||
|
a.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
|
||||||
break;
|
break;
|
||||||
case MetaName.CTimeArchetypeDef:
|
case MetaName.CTimeArchetypeDef:
|
||||||
var timearch = PsoTypes.ConvertDataRaw<CTimeArchetypeDef>(block.Data, offset);
|
var timearch = PsoTypes.ConvertDataRaw<CTimeArchetypeDef>(block.Data, offset);
|
||||||
ba.Init(this, ref timearch);
|
var ta = new TimeArchetype();
|
||||||
ba.Extensions = MetaTypes.GetExtensions(Meta, timearch.BaseArchetypeDef.extensions);
|
ta.Init(this, ref timearch);
|
||||||
|
ta.Extensions = MetaTypes.GetExtensions(Meta, timearch._BaseArchetypeDef.extensions);
|
||||||
|
a = ta;
|
||||||
break;
|
break;
|
||||||
case MetaName.CMloArchetypeDef:
|
case MetaName.CMloArchetypeDef:
|
||||||
var mloarch = PsoTypes.ConvertDataRaw<CMloArchetypeDef>(block.Data, offset);
|
var mloarch = PsoTypes.ConvertDataRaw<CMloArchetypeDef>(block.Data, offset);
|
||||||
ba.Init(this, ref mloarch);
|
var ma = new MloArchetype();
|
||||||
ba.Extensions = MetaTypes.GetExtensions(Meta, mloarch.BaseArchetypeDef.extensions);
|
ma.Init(this, ref mloarch);
|
||||||
|
ma.Extensions = MetaTypes.GetExtensions(Meta, mloarch._BaseArchetypeDef.extensions);
|
||||||
|
|
||||||
MloArchetypeData mlod = new MloArchetypeData();
|
|
||||||
var mlodef = mloarch.MloArchetypeDef;
|
var mlodef = mloarch.MloArchetypeDef;
|
||||||
mlod.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mlodef.entities);
|
ma.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mlodef.entities);
|
||||||
mlod.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mlodef.rooms);
|
ma.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mlodef.rooms);
|
||||||
mlod.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mlodef.portals);
|
ma.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mlodef.portals);
|
||||||
mlod.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mlodef.entitySets);
|
ma.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mlodef.entitySets);
|
||||||
mlod.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mlodef.timeCycleModifiers);
|
ma.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mlodef.timeCycleModifiers);
|
||||||
ba.MloData = mlod;
|
|
||||||
|
|
||||||
if (mlod.entities != null)
|
if (ma.entities != null)
|
||||||
{
|
{
|
||||||
//for (int e = 0; e < mlod.entities.Length; e++)
|
//for (int e = 0; e < ma.entities.Length; e++)
|
||||||
//{
|
//{
|
||||||
// if (mlod.entities[e].extensions.Count1 > 0)
|
// if (ma.entities[e].extensions.Count1 > 0)
|
||||||
// {
|
// {
|
||||||
// var exts = MetaTypes.GetExtensions(Meta, mlod.entities[e].extensions);
|
// var exts = MetaTypes.GetExtensions(Meta, ma.entities[e].extensions);
|
||||||
// if (exts != null)
|
// if (exts != null)
|
||||||
// { }
|
// { }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a = ma;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a != null)
|
||||||
allarchs.Add(ba);
|
{
|
||||||
|
allarchs.Add(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AllArchetypes = allarchs.ToArray();
|
AllArchetypes = allarchs.ToArray();
|
||||||
|
@ -2394,12 +2394,13 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
foreach (var arch in ytyp.AllArchetypes)
|
foreach (var arch in ytyp.AllArchetypes)
|
||||||
{
|
{
|
||||||
if (arch.IsTimeArchetype)
|
if (arch.Type == MetaName.CTimeArchetypeDef)
|
||||||
{
|
{
|
||||||
var t = arch.TimeArchetype.TimeArchetypeDef.timeFlags;
|
var ta = arch as TimeArchetype;
|
||||||
sb.Append(arch.TimeArchetype.BaseArchetypeDef.name.ToString());
|
var t = ta.TimeFlags;
|
||||||
|
sb.Append(arch.Name);
|
||||||
sb.Append(",");
|
sb.Append(",");
|
||||||
sb.Append(arch.TimeArchetype.BaseArchetypeDef.assetName.ToString());
|
sb.Append(arch.AssetName);
|
||||||
sb.Append(",");
|
sb.Append(",");
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
|
@ -882,7 +882,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TC(typeof(EXP))] public struct ArrayOfUshorts3 //array of 3 bytes
|
[TC(typeof(EXP))] public struct ArrayOfUshorts3 //array of 3 ushorts
|
||||||
{
|
{
|
||||||
public ushort u0, u1, u2;
|
public ushort u0, u1, u2;
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -961,22 +961,24 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[TC(typeof(EXP))] public struct MetaPOINTER //8 bytes - pointer to data item //SectionUNKNOWN10
|
[TC(typeof(EXP))] public struct MetaPOINTER //8 bytes - pointer to data item //was: SectionUNKNOWN10
|
||||||
{
|
{
|
||||||
public ushort BlockID { get; set; } //1-based ID
|
public uint Pointer { get; set; }
|
||||||
public ushort ItemOffset { get; set; } //byte offset / 16
|
|
||||||
public uint ExtraOffset { get; set; }
|
public uint ExtraOffset { get; set; }
|
||||||
|
|
||||||
public MetaPOINTER(ushort blockID, ushort itemOffset, uint extra)
|
public int BlockIndex { get { return BlockID - 1; } }
|
||||||
|
public int BlockID { get { return (int)(Pointer & 0xFFF); } set { Pointer = (Pointer & 0xFFFFF000) + ((uint)value & 0xFFF); } }
|
||||||
|
public int Offset { get { return (int)((Pointer >> 12) & 0xFFFFF); } set { Pointer = (Pointer & 0xFFF) + (((uint)value << 12) & 0xFFFFF000); } }
|
||||||
|
|
||||||
|
public MetaPOINTER(int blockID, int itemOffset, uint extra)
|
||||||
{
|
{
|
||||||
BlockID = blockID;
|
Pointer = (((uint)itemOffset << 12) & 0xFFFFF000) + ((uint)blockID & 0xFFF);
|
||||||
ItemOffset = itemOffset;
|
|
||||||
ExtraOffset = extra;
|
ExtraOffset = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return BlockID.ToString() + ", " + ItemOffset.ToString() + ", " + ExtraOffset.ToString();
|
return BlockID.ToString() + ", " + Offset.ToString() + ", " + ExtraOffset.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
int idx = block.AddItem(data);
|
int idx = block.AddItem(data);
|
||||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||||
r.Block = block.Index + 1;
|
r.BlockID = block.Index + 1;
|
||||||
r.Offset = (idx * data.Length) / 16;
|
r.Offset = (idx * data.Length);
|
||||||
r.Length = data.Length;
|
r.Length = data.Length;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -65,11 +65,11 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
byte[] newdata = new byte[newlen];
|
byte[] newdata = new byte[newlen];
|
||||||
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
||||||
int offs = block.TotalSize / 16;
|
int offs = block.TotalSize;
|
||||||
int idx = block.AddItem(newdata);
|
int idx = block.AddItem(newdata);
|
||||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||||
r.Block = block.Index + 1;
|
r.BlockID = block.Index + 1;
|
||||||
r.Offset = offs; //(idx * data.Length) / 16;
|
r.Offset = offs; //(idx * data.Length);;
|
||||||
r.Length = items.Length;
|
r.Length = items.Length;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -86,11 +86,11 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
byte[] newdata = new byte[newlen];
|
byte[] newdata = new byte[newlen];
|
||||||
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
Buffer.BlockCopy(data, 0, newdata, 0, datalen);
|
||||||
int offs = block.TotalSize / 16;
|
int offs = block.TotalSize;
|
||||||
int idx = block.AddItem(newdata);
|
int idx = block.AddItem(newdata);
|
||||||
MetaBuilderPointer r = new MetaBuilderPointer();
|
MetaBuilderPointer r = new MetaBuilderPointer();
|
||||||
r.Block = block.Index + 1;
|
r.BlockID = block.Index + 1;
|
||||||
r.Offset = offs;// (idx * data.Length) / 16;//not sure if this is correct! should also use sub-offset!
|
r.Offset = offs;// (idx * data.Length);
|
||||||
r.Length = datalen; //actual length of string.
|
r.Length = datalen; //actual length of string.
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public MetaPOINTER AddItemPtr<T>(MetaName type, T item) where T : struct //helper method for AddItem<T>
|
public MetaPOINTER AddItemPtr<T>(MetaName type, T item) where T : struct //helper method for AddItem<T>
|
||||||
{
|
{
|
||||||
var ptr = AddItem(type, item);
|
var ptr = AddItem(type, item);
|
||||||
return new MetaPOINTER((ushort)ptr.Block, (ushort)ptr.Offset, 0);
|
return new MetaPOINTER(ptr.BlockID, ptr.Offset, 0);
|
||||||
}
|
}
|
||||||
public Array_Structure AddItemArrayPtr<T>(MetaName type, T[] items) where T : struct //helper method for AddItemArray<T>
|
public Array_Structure AddItemArrayPtr<T>(MetaName type, T[] items) where T : struct //helper method for AddItemArray<T>
|
||||||
{
|
{
|
||||||
@ -207,8 +207,8 @@ namespace CodeWalker.GameFiles
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
MetaBuilderPointer mbp = new MetaBuilderPointer();
|
MetaBuilderPointer mbp = new MetaBuilderPointer();
|
||||||
mbp.Block = meptr.BlockID;
|
mbp.BlockID = meptr.BlockID;
|
||||||
mbp.Offset = meptr.ItemOffset;
|
mbp.Offset = meptr.Offset;
|
||||||
sa.Pointer = mbp.Pointer;
|
sa.Pointer = mbp.Pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,15 +359,15 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
public struct MetaBuilderPointer
|
public struct MetaBuilderPointer
|
||||||
{
|
{
|
||||||
public int Block { get; set; } //0-based index
|
public int BlockID { get; set; } //1-based id
|
||||||
public int Offset { get; set; } //(byteoffset/16)
|
public int Offset { get; set; } //byte offset
|
||||||
public int Length { get; set; } //for temp use...
|
public int Length { get; set; } //for temp use...
|
||||||
public uint Pointer
|
public uint Pointer
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
uint bidx = (((uint)Block) & 0xFFF);
|
uint bidx = (((uint)BlockID) & 0xFFF);
|
||||||
uint offs = (((uint)Offset) & 0xFFFF) << 16;
|
uint offs = (((uint)Offset) & 0xFFFFF) << 12;
|
||||||
return bidx + offs;
|
return bidx + offs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -819,12 +819,10 @@ namespace CodeWalker.GameFiles
|
|||||||
//MetaName blocktype = 0;
|
//MetaName blocktype = 0;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var sptr = ptrs[i];
|
var ptr = ptrs[i];
|
||||||
int blocki = sptr.BlockID - 1;
|
var offset = ptr.Offset;
|
||||||
int offset = sptr.ItemOffset * 16;//block data size...
|
var block = meta.GetBlock(ptr.BlockID);
|
||||||
if (blocki >= meta.DataBlocks.Count)
|
if (block == null) continue;
|
||||||
{ continue; }
|
|
||||||
var block = meta.DataBlocks[blocki];
|
|
||||||
|
|
||||||
//if (blocktype == 0)
|
//if (blocktype == 0)
|
||||||
//{ blocktype = block.StructureNameHash; }
|
//{ blocktype = block.StructureNameHash; }
|
||||||
@ -983,11 +981,8 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
MetaPOINTER[] ptrs = new MetaPOINTER[count];
|
MetaPOINTER[] ptrs = new MetaPOINTER[count];
|
||||||
int ptrsize = Marshal.SizeOf(typeof(MetaPOINTER));
|
int ptrsize = Marshal.SizeOf(typeof(MetaPOINTER));
|
||||||
//int itemsleft = (int)count; //large arrays get split into chunks...
|
int ptroffset = (int)array.PointerDataOffset;
|
||||||
uint ptr = array.Pointer;
|
var ptrblock = meta.GetBlock((int)array.PointerDataId);
|
||||||
int ptrindex = (int)(ptr & 0xFFF) - 1;
|
|
||||||
int ptroffset = (int)((ptr >> 12) & 0xFFFFF);
|
|
||||||
var ptrblock = (ptrindex < meta.DataBlocks.Count) ? meta.DataBlocks[ptrindex] : null;
|
|
||||||
if ((ptrblock == null) || (ptrblock.Data == null) || (ptrblock.StructureNameHash != MetaName.POINTER))
|
if ((ptrblock == null) || (ptrblock.Data == null) || (ptrblock.StructureNameHash != MetaName.POINTER))
|
||||||
{ return null; }
|
{ return null; }
|
||||||
|
|
||||||
@ -1204,7 +1199,7 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
var extptr = extptrs[i];
|
var extptr = extptrs[i];
|
||||||
MetaWrapper ext = null;
|
MetaWrapper ext = null;
|
||||||
var block = GetDataBlock(meta, extptr);
|
var block = meta.GetBlock(extptr.BlockID);
|
||||||
var h = block.StructureNameHash;
|
var h = block.StructureNameHash;
|
||||||
switch (h)
|
switch (h)
|
||||||
{
|
{
|
||||||
@ -1277,18 +1272,10 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static MetaDataBlock GetDataBlock(Meta meta, MetaPOINTER ptr)
|
|
||||||
{
|
|
||||||
int blocki = ptr.BlockID - 1;
|
|
||||||
if ((blocki < 0) || (blocki >= meta.DataBlocks.Count))
|
|
||||||
{ return null; }
|
|
||||||
var block = meta.DataBlocks[blocki];
|
|
||||||
return block;
|
|
||||||
}
|
|
||||||
public static int GetDataOffset(MetaDataBlock block, MetaPOINTER ptr)
|
public static int GetDataOffset(MetaDataBlock block, MetaPOINTER ptr)
|
||||||
{
|
{
|
||||||
if (block == null) return -1;
|
if (block == null) return -1;
|
||||||
int offset = ptr.ItemOffset * 16;//block data size...
|
var offset = ptr.Offset;
|
||||||
if (ptr.ExtraOffset != 0)
|
if (ptr.ExtraOffset != 0)
|
||||||
{ }
|
{ }
|
||||||
//offset += (int)ptr.ExtraOffset;
|
//offset += (int)ptr.ExtraOffset;
|
||||||
@ -1298,13 +1285,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
public static T GetData<T>(Meta meta, MetaPOINTER ptr) where T : struct
|
public static T GetData<T>(Meta meta, MetaPOINTER ptr) where T : struct
|
||||||
{
|
{
|
||||||
var block = GetDataBlock(meta, ptr);
|
var block = meta.GetBlock(ptr.BlockID);
|
||||||
var offset = GetDataOffset(block, ptr);
|
|
||||||
if (offset < 0) return new T();
|
|
||||||
return ConvertData<T>(block.Data, offset);
|
|
||||||
}
|
|
||||||
public static T GetData<T>(MetaDataBlock block, MetaPOINTER ptr) where T : struct
|
|
||||||
{
|
|
||||||
var offset = GetDataOffset(block, ptr);
|
var offset = GetDataOffset(block, ptr);
|
||||||
if (offset < 0) return new T();
|
if (offset < 0) return new T();
|
||||||
return ConvertData<T>(block.Data, offset);
|
return ConvertData<T>(block.Data, offset);
|
||||||
|
@ -285,8 +285,8 @@ namespace CodeWalker.GameFiles
|
|||||||
for (int n = 0; n < aCount; n++)
|
for (int n = 0; n < aCount; n++)
|
||||||
{
|
{
|
||||||
var ptr = ptrArr[n];
|
var ptr = ptrArr[n];
|
||||||
var eboffset = ptr.ItemOffset * 16;
|
var offset = ptr.Offset;
|
||||||
WriteNode(sb, aind, cont, ptr.BlockID, eboffset, XmlTagMode.ItemAndType);
|
WriteNode(sb, aind, cont, ptr.BlockID, offset, XmlTagMode.ItemAndType);
|
||||||
}
|
}
|
||||||
CloseTag(sb, indent, ename);
|
CloseTag(sb, indent, ename);
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,13 @@ namespace CodeWalker.GameFiles
|
|||||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||||
public class Archetype
|
public class Archetype
|
||||||
{
|
{
|
||||||
|
public virtual MetaName Type => MetaName.CBaseArchetypeDef;
|
||||||
|
|
||||||
|
public CBaseArchetypeDef _BaseArchetypeDef;
|
||||||
|
public CBaseArchetypeDef BaseArchetypeDef { get { return _BaseArchetypeDef; } set { _BaseArchetypeDef = value; } }
|
||||||
|
|
||||||
public MetaHash Hash { get; set; }
|
public MetaHash Hash { get; set; }
|
||||||
public YtypFile Ytyp { get; set; }
|
public YtypFile Ytyp { get; set; }
|
||||||
public CBaseArchetypeDef BaseArchetype { get; set; }
|
|
||||||
public CTimeArchetypeDef TimeArchetype { get; set; }
|
|
||||||
public CMloArchetypeDef MloArchetype { get; set; }
|
|
||||||
public MetaHash DrawableDict { get; set; }
|
public MetaHash DrawableDict { get; set; }
|
||||||
public MetaHash TextureDict { get; set; }
|
public MetaHash TextureDict { get; set; }
|
||||||
public MetaHash ClipDict { get; set; }
|
public MetaHash ClipDict { get; set; }
|
||||||
@ -23,35 +25,31 @@ namespace CodeWalker.GameFiles
|
|||||||
public Vector3 BBMax { get; set; }
|
public Vector3 BBMax { get; set; }
|
||||||
public Vector3 BSCenter { get; set; }
|
public Vector3 BSCenter { get; set; }
|
||||||
public float BSRadius { get; set; }
|
public float BSRadius { get; set; }
|
||||||
public bool IsTimeArchetype { get; set; }
|
|
||||||
public bool IsMloArchetype { get; set; }
|
|
||||||
public float LodDist { get; set; }
|
public float LodDist { get; set; }
|
||||||
public MloArchetypeData MloData { get; set; }
|
|
||||||
public MetaWrapper[] Extensions { get; set; }
|
public MetaWrapper[] Extensions { get; set; }
|
||||||
public TimedArchetypeTimes Times { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.name.ToString();
|
return _BaseArchetypeDef.name.ToString();
|
||||||
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.name.ToString();
|
|
||||||
return BaseArchetype.name.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string AssetName
|
public string AssetName
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.assetName.ToString();
|
return _BaseArchetypeDef.assetName.ToString();
|
||||||
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.assetName.ToString();
|
|
||||||
return BaseArchetype.assetName.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitVars(ref CBaseArchetypeDef arch)
|
|
||||||
|
protected void InitVars(ref CBaseArchetypeDef arch)
|
||||||
{
|
{
|
||||||
|
BaseArchetypeDef = arch;
|
||||||
Hash = arch.assetName;
|
Hash = arch.assetName;
|
||||||
if (Hash.Hash == 0) Hash = arch.name;
|
if (Hash.Hash == 0) Hash = arch.name;
|
||||||
DrawableDict = arch.drawableDictionary;
|
DrawableDict = arch.drawableDictionary;
|
||||||
@ -68,56 +66,86 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
Ytyp = ytyp;
|
Ytyp = ytyp;
|
||||||
InitVars(ref arch);
|
InitVars(ref arch);
|
||||||
BaseArchetype = arch;
|
|
||||||
IsTimeArchetype = false;
|
|
||||||
IsMloArchetype = false;
|
|
||||||
}
|
|
||||||
public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch)
|
|
||||||
{
|
|
||||||
Ytyp = ytyp;
|
|
||||||
InitVars(ref arch._BaseArchetypeDef);
|
|
||||||
TimeArchetype = arch;
|
|
||||||
IsTimeArchetype = true;
|
|
||||||
IsMloArchetype = false;
|
|
||||||
Times = new TimedArchetypeTimes(arch.TimeArchetypeDef.timeFlags);
|
|
||||||
}
|
|
||||||
public void Init(YtypFile ytyp, ref CMloArchetypeDef arch)
|
|
||||||
{
|
|
||||||
Ytyp = ytyp;
|
|
||||||
InitVars(ref arch._BaseArchetypeDef);
|
|
||||||
MloArchetype = arch;
|
|
||||||
IsTimeArchetype = false;
|
|
||||||
IsMloArchetype = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsActive(float hour)
|
public virtual bool IsActive(float hour)
|
||||||
{
|
{
|
||||||
if (Times == null) return true;
|
return true;
|
||||||
//if (Times.ExtraFlag) hour -= 0.5f;
|
|
||||||
//if (hour < 0.0f) hour += 24.0f;
|
|
||||||
int h = ((int)hour) % 24;
|
|
||||||
if ((h < 0) || (h > 23)) return true;
|
|
||||||
return Times.ActiveHours[h];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (IsTimeArchetype) return TimeArchetype.ToString();
|
return _BaseArchetypeDef.ToString();
|
||||||
if (IsMloArchetype) return MloArchetype.ToString();
|
|
||||||
return BaseArchetype.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||||
public class MloArchetypeData
|
public class TimeArchetype : Archetype
|
||||||
{
|
{
|
||||||
|
public override MetaName Type => MetaName.CTimeArchetypeDef;
|
||||||
|
|
||||||
|
public CTimeArchetypeDefData _TimeArchetypeDef;
|
||||||
|
public CTimeArchetypeDefData TimeArchetypeDef { get { return _TimeArchetypeDef; } set { _TimeArchetypeDef = value; } }
|
||||||
|
|
||||||
|
|
||||||
|
public uint TimeFlags { get; set; }
|
||||||
|
public bool[] ActiveHours { get; set; }
|
||||||
|
public string[] ActiveHoursText { get; set; }
|
||||||
|
public bool ExtraFlag { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public void Init(YtypFile ytyp, ref CTimeArchetypeDef arch)
|
||||||
|
{
|
||||||
|
Ytyp = ytyp;
|
||||||
|
InitVars(ref arch._BaseArchetypeDef);
|
||||||
|
TimeArchetypeDef = arch.TimeArchetypeDef;
|
||||||
|
|
||||||
|
TimeFlags = _TimeArchetypeDef.timeFlags;
|
||||||
|
ActiveHours = new bool[24];
|
||||||
|
ActiveHoursText = new string[24];
|
||||||
|
for (int i = 0; i < 24; i++)
|
||||||
|
{
|
||||||
|
bool v = ((TimeFlags >> i) & 1) == 1;
|
||||||
|
ActiveHours[i] = v;
|
||||||
|
|
||||||
|
int nxth = (i < 23) ? (i + 1) : 0;
|
||||||
|
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
|
||||||
|
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
|
||||||
|
}
|
||||||
|
ExtraFlag = ((TimeFlags >> 24) & 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsActive(float hour)
|
||||||
|
{
|
||||||
|
if (ActiveHours == null) return true;
|
||||||
|
int h = ((int)hour) % 24;
|
||||||
|
if ((h < 0) || (h > 23)) return true;
|
||||||
|
return ActiveHours[h];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MloArchetype : Archetype
|
||||||
|
{
|
||||||
|
public override MetaName Type => MetaName.CMloArchetypeDef;
|
||||||
|
|
||||||
|
public CMloArchetypeDefData _MloArchetypeDef;
|
||||||
|
public CMloArchetypeDefData MloArchetypeDef { get { return _MloArchetypeDef; } set { _MloArchetypeDef = value; } }
|
||||||
|
|
||||||
public CEntityDef[] entities { get; set; }
|
public CEntityDef[] entities { get; set; }
|
||||||
public CMloRoomDef[] rooms { get; set; }
|
public CMloRoomDef[] rooms { get; set; }
|
||||||
public CMloPortalDef[] portals { get; set; }
|
public CMloPortalDef[] portals { get; set; }
|
||||||
public CMloEntitySet[] entitySets { get; set; }
|
public CMloEntitySet[] entitySets { get; set; }
|
||||||
public CMloTimeCycleModifier[] timeCycleModifiers { get; set; }
|
public CMloTimeCycleModifier[] timeCycleModifiers { get; set; }
|
||||||
|
|
||||||
|
public void Init(YtypFile ytyp, ref CMloArchetypeDef arch)
|
||||||
|
{
|
||||||
|
Ytyp = ytyp;
|
||||||
|
InitVars(ref arch._BaseArchetypeDef);
|
||||||
|
MloArchetypeDef = arch.MloArchetypeDef;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||||||
public class MloInstanceData
|
public class MloInstanceData
|
||||||
@ -130,16 +158,16 @@ namespace CodeWalker.GameFiles
|
|||||||
public YmapEntityDef[] Entities { get; set; }
|
public YmapEntityDef[] Entities { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public void CreateYmapEntities(YmapEntityDef owner, MloArchetypeData mlod)
|
public void CreateYmapEntities(YmapEntityDef owner, MloArchetype mloa)
|
||||||
{
|
{
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
if (owner == null) return;
|
if (owner == null) return;
|
||||||
if (mlod.entities == null) return;
|
if (mloa.entities == null) return;
|
||||||
var ec = mlod.entities.Length;
|
var ec = mloa.entities.Length;
|
||||||
Entities = new YmapEntityDef[ec];
|
Entities = new YmapEntityDef[ec];
|
||||||
for (int i = 0; i < ec; i++)
|
for (int i = 0; i < ec; i++)
|
||||||
{
|
{
|
||||||
YmapEntityDef e = new YmapEntityDef(null, i, ref mlod.entities[i]);
|
YmapEntityDef e = new YmapEntityDef(null, i, ref mloa.entities[i]);
|
||||||
e.MloRefPosition = e.Position;
|
e.MloRefPosition = e.Position;
|
||||||
e.MloRefOrientation = e.Orientation;
|
e.MloRefOrientation = e.Orientation;
|
||||||
e.MloParent = owner;
|
e.MloParent = owner;
|
||||||
@ -172,31 +200,4 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
|
||||||
public class TimedArchetypeTimes
|
|
||||||
{
|
|
||||||
public uint TimeFlags { get; set; }
|
|
||||||
public bool[] ActiveHours { get; set; }
|
|
||||||
public string[] ActiveHoursText { get; set; }
|
|
||||||
public bool ExtraFlag { get; set; }
|
|
||||||
|
|
||||||
public TimedArchetypeTimes(uint timeFlags)
|
|
||||||
{
|
|
||||||
TimeFlags = timeFlags;
|
|
||||||
ActiveHours = new bool[24];
|
|
||||||
ActiveHoursText = new string[24];
|
|
||||||
for (int i = 0; i < 24; i++)
|
|
||||||
{
|
|
||||||
bool v = ((timeFlags >> i) & 1) == 1;
|
|
||||||
ActiveHours[i] = v;
|
|
||||||
|
|
||||||
int nxth = (i < 23) ? (i + 1) : 0;
|
|
||||||
string hrs = string.Format("{0:00}:00 - {1:00}:00", i, nxth);
|
|
||||||
ActiveHoursText[i] = (hrs + (v ? " - On" : " - Off"));
|
|
||||||
}
|
|
||||||
ExtraFlag = ((timeFlags >> 24) & 1) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
35
WorldForm.cs
35
WorldForm.cs
@ -2199,7 +2199,8 @@ namespace CodeWalker
|
|||||||
Archetype arch = ent.Archetype;
|
Archetype arch = ent.Archetype;
|
||||||
if (arch != null)
|
if (arch != null)
|
||||||
{
|
{
|
||||||
if (!arch.IsTimeArchetype || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
bool timed = (arch.Type == MetaName.CTimeArchetypeDef);
|
||||||
|
if (!timed || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||||
{
|
{
|
||||||
ent.CamRel = ent.Position - camera.Position;
|
ent.CamRel = ent.Position - camera.Position;
|
||||||
RenderArchetype(arch, ent);
|
RenderArchetype(arch, ent);
|
||||||
@ -2232,7 +2233,8 @@ namespace CodeWalker
|
|||||||
Archetype arch = entity.Archetype;
|
Archetype arch = entity.Archetype;
|
||||||
if (arch != null)
|
if (arch != null)
|
||||||
{
|
{
|
||||||
if (!arch.IsTimeArchetype || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
bool timed = (arch.Type == MetaName.CTimeArchetypeDef);
|
||||||
|
if (!timed || (rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday))))
|
||||||
{
|
{
|
||||||
bool usechild = false;
|
bool usechild = false;
|
||||||
entity.CamRel = entity.Position - camera.Position;
|
entity.CamRel = entity.Position - camera.Position;
|
||||||
@ -2418,23 +2420,23 @@ namespace CodeWalker
|
|||||||
var arch = ent.Archetype;
|
var arch = ent.Archetype;
|
||||||
bool isshadowproxy = false;
|
bool isshadowproxy = false;
|
||||||
bool isreflproxy = false;
|
bool isreflproxy = false;
|
||||||
uint archflags = arch.BaseArchetype.flags;
|
uint archflags = arch._BaseArchetypeDef.flags;
|
||||||
if (arch.IsTimeArchetype)
|
if (arch.Type == MetaName.CTimeArchetypeDef)
|
||||||
{
|
{
|
||||||
if (!(rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday)))) return false;
|
if (!(rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday)))) return false;
|
||||||
archflags = arch.TimeArchetype.BaseArchetypeDef.flags;
|
//archflags = arch._BaseArchetypeDef.flags;
|
||||||
}
|
}
|
||||||
else if (arch.IsMloArchetype)
|
//else if (arch.Type == MetaName.CMloArchetypeDef)
|
||||||
{
|
|
||||||
archflags = arch.MloArchetype.BaseArchetypeDef.flags;
|
|
||||||
}
|
|
||||||
//switch (archflags)
|
|
||||||
//{
|
//{
|
||||||
// //case 8192: //8192: is YTYP no shadow rendering - CP
|
// archflags = arch._BaseArchetypeDef.flags;
|
||||||
// case 2048: //000000000000000000100000000000 shadow proxies...
|
|
||||||
// case 536872960: //100000000000000000100000000000 tunnel refl/shadow prox?
|
|
||||||
// isshadowproxy = true; break;
|
|
||||||
//}
|
//}
|
||||||
|
////switch (archflags)
|
||||||
|
////{
|
||||||
|
//// //case 8192: //8192: is YTYP no shadow rendering - CP
|
||||||
|
//// case 2048: //000000000000000000100000000000 shadow proxies...
|
||||||
|
//// case 536872960: //100000000000000000100000000000 tunnel refl/shadow prox?
|
||||||
|
//// isshadowproxy = true; break;
|
||||||
|
////}
|
||||||
if ((archflags & 2048) > 0)
|
if ((archflags & 2048) > 0)
|
||||||
{
|
{
|
||||||
isshadowproxy = true;
|
isshadowproxy = true;
|
||||||
@ -2445,7 +2447,7 @@ namespace CodeWalker
|
|||||||
// isreflproxy = true;
|
// isreflproxy = true;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
switch (ent.CEntityDef.flags)
|
switch (ent._CEntityDef.flags)
|
||||||
{
|
{
|
||||||
case 135790592: //001000000110000000000000000000 prewater proxy (golf course)
|
case 135790592: //001000000110000000000000000000 prewater proxy (golf course)
|
||||||
case 135790593: //001000000110000000000000000001 water refl proxy? (mike house)
|
case 135790593: //001000000110000000000000000001 water refl proxy? (mike house)
|
||||||
@ -2503,9 +2505,6 @@ namespace CodeWalker
|
|||||||
|
|
||||||
Vector3 camrel = (entity != null) ? entity.CamRel : -camera.Position;
|
Vector3 camrel = (entity != null) ? entity.CamRel : -camera.Position;
|
||||||
|
|
||||||
if (arche.IsMloArchetype)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
Quaternion orientation = Quaternion.Identity;
|
Quaternion orientation = Quaternion.Identity;
|
||||||
Vector3 scale = Vector3.One;
|
Vector3 scale = Vector3.One;
|
||||||
Vector3 bscent = camrel;
|
Vector3 bscent = camrel;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user