MetaTypes rearrangement, Archetype restructuring start

This commit is contained in:
dexyfex 2017-09-28 02:24:21 +10:00
parent b6d77c9ca8
commit 7ddd88e561
9 changed files with 1210 additions and 1099 deletions

View File

@ -34,6 +34,7 @@ namespace CodeWalker.GameFiles
public string[] Strings { get; set; }
public YmapEntityDef[] AllEntities;
public YmapEntityDef[] RootEntities;
public YmapEntityDef[] MloEntities;
public YmapFile[] ChildYmaps = null;
public bool MergedWithParent = false;
@ -317,6 +318,7 @@ namespace CodeWalker.GameFiles
//build the entity hierarchy.
List<YmapEntityDef> roots = new List<YmapEntityDef>(instcount);
List<YmapEntityDef> alldefs = new List<YmapEntityDef>(instcount);
List<YmapEntityDef> mlodefs = null;
if (CEntityDefs != null)
{
@ -328,10 +330,17 @@ namespace CodeWalker.GameFiles
}
if (CMloInstanceDefs != null)
{
mlodefs = new List<YmapEntityDef>();
for (int i = 0; i < CMloInstanceDefs.Length; i++)
{
YmapEntityDef d = new YmapEntityDef(this, i, ref CMloInstanceDefs[i]);
uint[] unkuints = MetaTypes.GetUintArray(Meta, CMloInstanceDefs[i].Unk_1407157833);
if (d.MloInstance != null)
{
d.MloInstance.Unk_1407157833 = unkuints;
}
alldefs.Add(d);
mlodefs.Add(d);
}
}
@ -374,6 +383,10 @@ namespace CodeWalker.GameFiles
AllEntities = alldefs.ToArray();
RootEntities = roots.ToArray();
if (mlodefs != null)
{
MloEntities = mlodefs.ToArray();
}
foreach (var ent in AllEntities)
@ -886,8 +899,10 @@ namespace CodeWalker.GameFiles
public Quaternion Orientation { get; set; }
public Vector3 Scale { get; set; }
public bool IsMlo { get; set; }
public MloEntityData MloData { get; set; }
public MloInstanceData MloInstance { get; set; }
public YmapEntityDef MloParent { get; set; }
public Vector3 MloRefPosition { get; set; }
public Quaternion MloRefOrientation { get; set; }
public MetaWrapper[] Extensions { get; set; }
public bool ChildrenRendered; //used when rendering ymap mode to reduce LOD flashing...
@ -954,6 +969,9 @@ namespace CodeWalker.GameFiles
//}
IsMlo = true;
MloInstance = new MloInstanceData();
MloInstance.Instance = mlo;
UpdateWidgetPosition();
UpdateWidgetOrientation();
}
@ -983,8 +1001,11 @@ namespace CodeWalker.GameFiles
{
//transform interior entities into world space...
var mlod = Archetype.MloData;
MloData = new MloEntityData();
MloData.CreateYmapEntities(this, mlod);
if (MloInstance == null)
{
MloInstance = new MloInstanceData();
}
MloInstance.CreateYmapEntities(this, mlod);
if (BSRadius == 0.0f)
{
@ -1002,6 +1023,13 @@ namespace CodeWalker.GameFiles
{
//TODO: SetPosition for interior entities!
Position = pos;
var inst = MloParent.MloInstance;
if (inst != null)
{
//transform world position into mlo space
//MloRefPosition = ...
//MloRefOrientation = ...
}
}
else
{
@ -1028,6 +1056,13 @@ namespace CodeWalker.GameFiles
UpdateWidgetPosition();
}
if (MloInstance != null)
{
MloInstance.UpdateEntities();
}
}
public void SetOrientation(Quaternion ori)

View File

@ -18,26 +18,21 @@ namespace CodeWalker.GameFiles
public PsoFile Pso { get; set; }
public RbfFile Rbf { get; set; }
public CMapTypes CMapTypes { get; set; }
//public CBaseArchetypeDef[] CBaseArchetypeDefs { get; set; }
//public CTimeArchetypeDef[] CTimeArchetypeDefs { get; set; }
//public CMloArchetypeDef[] CMloArchetypeDefs { get; set; }
public CExtensionDefAudioEmitter[] AudioEmitters { get; set; }
//public CEntityDef[] CEntityDefs { get; set; }
public CCompositeEntityType[] CompositeEntityTypes { get; set; }
public uint NameHash { get; set; }
public string[] Strings { get; set; }
public CMapTypes CMapTypes { get; set; }
public Archetype[] AllArchetypes { get; set; }
public MetaWrapper[] Extensions { get; set; }
public CCompositeEntityType[] CompositeEntityTypes { get; set; }
public override string ToString()
{
@ -101,34 +96,40 @@ namespace CodeWalker.GameFiles
{
case MetaName.CBaseArchetypeDef:
var basearch = PsoTypes.ConvertDataRaw<CBaseArchetypeDef>(block.Data, offset);
ba.Init(this, basearch);
ba.Init(this, ref basearch);
ba.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions);
break;
case MetaName.CTimeArchetypeDef:
var timearch = PsoTypes.ConvertDataRaw<CTimeArchetypeDef>(block.Data, offset);
ba.Init(this, timearch);
ba.Extensions = MetaTypes.GetExtensions(Meta, timearch.CBaseArchetypeDef.extensions);
ba.Init(this, ref timearch);
ba.Extensions = MetaTypes.GetExtensions(Meta, timearch.BaseArchetypeDef.extensions);
break;
case MetaName.CMloArchetypeDef:
var mloarch = PsoTypes.ConvertDataRaw<CMloArchetypeDef>(block.Data, offset);
ba.Init(this, mloarch);
ba.Extensions = MetaTypes.GetExtensions(Meta, mloarch.CBaseArchetypeDef.extensions);
ba.Init(this, ref mloarch);
ba.Extensions = MetaTypes.GetExtensions(Meta, mloarch.BaseArchetypeDef.extensions);
MloArchetypeData mlod = new MloArchetypeData();
mlod.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mloarch.entities);
mlod.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mloarch.rooms);
mlod.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mloarch.portals);
mlod.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mloarch.entitySets);
mlod.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mloarch.timeCycleModifiers);
var mlodef = mloarch.MloArchetypeDef;
mlod.entities = MetaTypes.ConvertDataArray<CEntityDef>(Meta, MetaName.CEntityDef, mlodef.entities);
mlod.rooms = MetaTypes.ConvertDataArray<CMloRoomDef>(Meta, MetaName.CMloRoomDef, mlodef.rooms);
mlod.portals = MetaTypes.ConvertDataArray<CMloPortalDef>(Meta, MetaName.CMloPortalDef, mlodef.portals);
mlod.entitySets = MetaTypes.ConvertDataArray<CMloEntitySet>(Meta, MetaName.CMloEntitySet, mlodef.entitySets);
mlod.timeCycleModifiers = MetaTypes.ConvertDataArray<CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mlodef.timeCycleModifiers);
ba.MloData = mlod;
//if (mlod.entities != null)
//{
if (mlod.entities != null)
{
//for (int e = 0; e < mlod.entities.Length; e++)
//{
// EnsureEntityExtensions(Meta, ref mlod.entities[e]);
// if (mlod.entities[e].extensions.Count1 > 0)
// {
// var exts = MetaTypes.GetExtensions(Meta, mlod.entities[e].extensions);
// if (exts != null)
// { }
// }
//}
}
break;
default:
@ -147,12 +148,13 @@ namespace CodeWalker.GameFiles
{ }
AudioEmitters = MetaTypes.GetTypedDataArray<CExtensionDefAudioEmitter>(Meta, MetaName.CExtensionDefAudioEmitter);
if (AudioEmitters != null)
{ }
//AudioEmitters = MetaTypes.GetTypedDataArray<CExtensionDefAudioEmitter>(Meta, MetaName.CExtensionDefAudioEmitter);
//if (AudioEmitters != null)
//{ }
//CEntityDefs = MetaTypes.GetTypedDataArray<CEntityDef>(Meta, MetaName.CEntityDef);
CompositeEntityTypes = MetaTypes.ConvertDataArray<CCompositeEntityType>(Meta, MetaName.CCompositeEntityType, CMapTypes.compositeEntityTypes);
if (CompositeEntityTypes != null)
{ }
@ -181,77 +183,54 @@ namespace CodeWalker.GameFiles
}
foreach (var block in Meta.DataBlocks)
{
switch(block.StructureNameHash)
{
case MetaName.CMapTypes:
case MetaName.CTimeArchetypeDef:
case MetaName.CBaseArchetypeDef:
case MetaName.CMloArchetypeDef:
case MetaName.CMloTimeCycleModifier:
case MetaName.CMloRoomDef:
case MetaName.CMloPortalDef:
case MetaName.CMloEntitySet:
case MetaName.CEntityDef:
case MetaName.CExtensionDefParticleEffect:
case MetaName.CExtensionDefAudioCollisionSettings:
case MetaName.CExtensionDefSpawnPoint:
case MetaName.CExtensionDefSpawnPointOverride:
case MetaName.CExtensionDefExplosionEffect:
case MetaName.CExtensionDefAudioEmitter:
case MetaName.CExtensionDefLadder:
case MetaName.CExtensionDefBuoyancy:
case MetaName.CExtensionDefExpression:
case MetaName.CExtensionDefLightShaft:
case MetaName.CExtensionDefLightEffect:
case MetaName.CExtensionDefDoor:
case MetaName.CExtensionDefWindDisturbance:
case MetaName.CExtensionDefProcObject:
case MetaName.CLightAttrDef:
case MetaName.STRING:
//case MetaName.SectionUNKNOWN2:
//case MetaName.SectionUNKNOWN3:
//case MetaName.SectionUNKNOWN8:
case MetaName.POINTER:
case MetaName.UINT:
case MetaName.VECTOR4:
break;
default:
break;
}
}
//MetaTypes.ParseMetaData(Meta);
//RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
//if (resentry == null)
//foreach (var block in Meta.DataBlocks)
//{
// throw new Exception("File entry wasn't a resource! (is it binary data?)");
// switch(block.StructureNameHash)
// {
// case MetaName.CMapTypes:
// case MetaName.CTimeArchetypeDef:
// case MetaName.CBaseArchetypeDef:
// case MetaName.CMloArchetypeDef:
// case MetaName.CMloTimeCycleModifier:
// case MetaName.CMloRoomDef:
// case MetaName.CMloPortalDef:
// case MetaName.CMloEntitySet:
// case MetaName.CEntityDef:
// case MetaName.CExtensionDefParticleEffect:
// case MetaName.CExtensionDefAudioCollisionSettings:
// case MetaName.CExtensionDefSpawnPoint:
// case MetaName.CExtensionDefSpawnPointOverride:
// case MetaName.CExtensionDefExplosionEffect:
// case MetaName.CExtensionDefAudioEmitter:
// case MetaName.CExtensionDefLadder:
// case MetaName.CExtensionDefBuoyancy:
// case MetaName.CExtensionDefExpression:
// case MetaName.CExtensionDefLightShaft:
// case MetaName.CExtensionDefLightEffect:
// case MetaName.CExtensionDefDoor:
// case MetaName.CExtensionDefWindDisturbance:
// case MetaName.CExtensionDefProcObject:
// case MetaName.CLightAttrDef:
// case MetaName.STRING:
// case MetaName.POINTER:
// case MetaName.UINT:
// case MetaName.VECTOR4:
// break;
// default:
// break;
// }
//}
//ResourceDataReader rd = new ResourceDataReader(resentry, data);
//Meta = rd.ReadBlock<Meta>();
//MetaTypes.EnsureMetaTypes(Meta);
//MetaTypes.ParseMetaData(Meta);
}

View File

@ -1796,9 +1796,9 @@ namespace CodeWalker.GameFiles
var arch = GetArchetype(ent.CEntityDef.archetypeName);
ent.SetArchetype(arch);
if (ent.MloData != null)
if (ent.MloInstance != null)
{
var entities = ent.MloData.AllEntities;
var entities = ent.MloInstance.Entities;
if (entities != null)
{
for (int j = 0; j < entities.Length; j++)
@ -2396,10 +2396,10 @@ namespace CodeWalker.GameFiles
{
if (arch.IsTimeArchetype)
{
var t = arch.TimeArchetype.timeFlags;
sb.Append(arch.TimeArchetype.CBaseArchetypeDef.name.ToString());
var t = arch.TimeArchetype.TimeArchetypeDef.timeFlags;
sb.Append(arch.TimeArchetype.BaseArchetypeDef.name.ToString());
sb.Append(",");
sb.Append(arch.TimeArchetype.CBaseArchetypeDef.assetName.ToString());
sb.Append(arch.TimeArchetype.BaseArchetypeDef.assetName.ToString());
sb.Append(",");
for (int i = 0; i < 32; i++)
{

View File

@ -5,13 +5,17 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using TC = System.ComponentModel.TypeConverterAttribute;
using EXP = System.ComponentModel.ExpandableObjectConverter;
namespace CodeWalker.GameFiles
{
[TypeConverter(typeof(ExpandableObjectConverter))] public class Meta : ResourceFileBase
[TC(typeof(EXP))] public class Meta : ResourceFileBase
{
public override long BlockLength
{
@ -202,7 +206,7 @@ namespace CodeWalker.GameFiles
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class MetaStructureInfo : ResourceSystemBlock
[TC(typeof(EXP))] public class MetaStructureInfo : ResourceSystemBlock
{
public override long BlockLength
{
@ -365,7 +369,7 @@ namespace CodeWalker.GameFiles
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public struct MetaStructureEntryInfo_s
[TC(typeof(EXP))] public struct MetaStructureEntryInfo_s
{
// structure data
public MetaName EntryNameHash { get; set; }
@ -391,7 +395,7 @@ namespace CodeWalker.GameFiles
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class MetaEnumInfo : ResourceSystemBlock
[TC(typeof(EXP))] public class MetaEnumInfo : ResourceSystemBlock
{
public override long BlockLength
{
@ -484,7 +488,7 @@ namespace CodeWalker.GameFiles
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public struct MetaEnumEntryInfo_s
[TC(typeof(EXP))] public struct MetaEnumEntryInfo_s
{
// structure data
public MetaName EntryNameHash { get; set; }
@ -502,7 +506,7 @@ namespace CodeWalker.GameFiles
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class MetaDataBlock : ResourceSystemBlock
[TC(typeof(EXP))] public class MetaDataBlock : ResourceSystemBlock
{
public override long BlockLength
{
@ -572,7 +576,420 @@ namespace CodeWalker.GameFiles
[TypeConverter(typeof(ExpandableObjectConverter))] public struct MetaHash
//derived types - manually created (array & pointer structs)
[TC(typeof(EXP))] public struct Array_StructurePointer //16 bytes - pointer for a structure pointer array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_StructurePointer: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_Structure //16 bytes - pointer for a structure array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public Array_Structure(uint ptr, int cnt)
{
Pointer = ptr;
Unk0 = 0;
Count1 = (ushort)cnt;
Count2 = Count1;
Unk1 = 0;
}
public Array_Structure(MetaBuilderPointer ptr)
{
Pointer = ptr.Pointer;
Unk0 = 0;
Count1 = (ushort)ptr.Length;
Count2 = Count1;
Unk1 = 0;
}
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_Structure: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_uint //16 bytes - pointer for a uint array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public Array_uint(uint ptr, int cnt)
{
Pointer = ptr;
Unk0 = 0;
Count1 = (ushort)cnt;
Count2 = Count1;
Unk1 = 0;
}
public Array_uint(MetaBuilderPointer ptr)
{
Pointer = ptr.Pointer;
Unk0 = 0;
Count1 = (ushort)ptr.Length;
Count2 = Count1;
Unk1 = 0;
}
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_uint: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_ushort //16 bytes - pointer for a ushort array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public Array_ushort(uint ptr, int cnt)
{
Pointer = ptr;
Unk0 = 0;
Count1 = (ushort)cnt;
Count2 = Count1;
Unk1 = 0;
}
public Array_ushort(MetaBuilderPointer ptr)
{
Pointer = ptr.Pointer;
Unk0 = 0;
Count1 = (ushort)ptr.Length;
Count2 = Count1;
Unk1 = 0;
}
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_ushort: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_byte //16 bytes - pointer for a byte array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_byte: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_float //16 bytes - pointer for a float array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_float: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct Array_Vector3 //16 bytes - pointer for a Vector3 array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "Array_Vector3: " + PointerDataIndex.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct CharPointer //16 bytes - pointer for a char array
{
public uint Pointer { get; set; }
public uint Unk0 { get; set; }
public ushort Count1 { get; set; }
public ushort Count2 { get; set; }
public uint Unk1 { get; set; }
public uint PointerDataId { get { return (Pointer & 0xFFF); } }
public uint PointerDataIndex { get { return (Pointer & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Pointer >> 12) & 0xFFFFF); } }
public CharPointer(uint ptr, int len)
{
Pointer = ptr;
Unk0 = 0;
Count1 = (ushort)len;
Count2 = Count1;
Unk1 = 0;
}
public CharPointer(MetaBuilderPointer ptr)
{
Pointer = ptr.Pointer;
Unk0 = 0;
Count1 = (ushort)ptr.Length;
Count2 = Count1;
Unk1 = 0;
}
public void SwapEnd()
{
Pointer = MetaTypes.SwapBytes(Pointer);
Unk0 = MetaTypes.SwapBytes(Unk0);
Count1 = MetaTypes.SwapBytes(Count1);
Count2 = MetaTypes.SwapBytes(Count2);
Unk1 = MetaTypes.SwapBytes(Unk1);
}
public override string ToString()
{
return "CharPointer: " + Pointer.ToString() + " (" + Count1.ToString() + "/" + Count2.ToString() + ")";
}
}
[TC(typeof(EXP))] public struct DataBlockPointer //8 bytes - pointer to data block
{
public uint Ptr0 { get; set; }
public uint Ptr1 { get; set; }
public uint PointerDataId { get { return (Ptr0 & 0xFFF); } }
public uint PointerDataIndex { get { return (Ptr0 & 0xFFF) - 1; } }
public uint PointerDataOffset { get { return ((Ptr0 >> 12) & 0xFFFFF); } }
public override string ToString()
{
return "DataBlockPointer: " + Ptr0.ToString() + ", " + Ptr1.ToString();
}
public void SwapEnd()
{
Ptr0 = MetaTypes.SwapBytes(Ptr0);
Ptr1 = MetaTypes.SwapBytes(Ptr1);
}
}
[TC(typeof(EXP))] public struct ArrayOfUshorts3 //array of 3 bytes
{
public ushort u0, u1, u2;
public override string ToString()
{
return u0.ToString() + ", " + u1.ToString() + ", " + u2.ToString();
}
}
[TC(typeof(EXP))] public struct ArrayOfBytes3 //array of 3 bytes
{
public byte b0, b1, b2;
public override string ToString()
{
return b0.ToString() + ", " + b1.ToString() + ", " + b2.ToString();
}
}
[TC(typeof(EXP))] public struct ArrayOfBytes4 //array of 4 bytes
{
public byte b0, b1, b2, b3;
public override string ToString()
{
return b0.ToString() + ", " + b1.ToString() + ", " + b2.ToString() + ", " + b3.ToString();
}
}
[TC(typeof(EXP))] public struct ArrayOfBytes5 //array of 5 bytes
{
public byte b0, b1, b2, b3, b4;
}
[TC(typeof(EXP))] public struct ArrayOfBytes6 //array of 6 bytes
{
public byte b0, b1, b2, b3, b4, b5;
}
[TC(typeof(EXP))] public struct ArrayOfBytes12 //array of 12 bytes
{
public byte b00, b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11;
}
[TC(typeof(EXP))] public struct ArrayOfChars64 //array of 64 chars (bytes)
{
public byte
b00, b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19,
b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39,
b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56, b57, b58, b59,
b60, b61, b62, b63;
public override string ToString()
{
byte[] bytes =
{
b00, b01, b02, b03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19,
b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39,
b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52, b53, b54, b55, b56, b57, b58, b59,
b60, b61, b62, b63
};
StringBuilder sb = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
if (bytes[i] == 0) break;
sb.Append((char)bytes[i]);
}
return sb.ToString();
}
}
[TC(typeof(EXP))] public struct MetaVECTOR3 //12 bytes, Key:2751397072
{
public float x { get; set; } //0 0: Float: 0: x
public float y { get; set; } //4 4: Float: 0: y
public float z { get; set; } //8 8: Float: 0: z
public override string ToString()
{
return x.ToString() + ", " + y.ToString() + ", " + z.ToString();
}
public Vector3 ToVector3()
{
return new Vector3(x, y, z);
}
}
[TC(typeof(EXP))] public struct MetaPOINTER //8 bytes - pointer to data item //SectionUNKNOWN10
{
public ushort BlockID { get; set; } //1-based ID
public ushort ItemOffset { get; set; } //byte offset / 16
public uint ExtraOffset { get; set; }
public MetaPOINTER(ushort blockID, ushort itemOffset, uint extra)
{
BlockID = blockID;
ItemOffset = itemOffset;
ExtraOffset = extra;
}
public override string ToString()
{
return BlockID.ToString() + ", " + ItemOffset.ToString() + ", " + ExtraOffset.ToString();
}
}
[TC(typeof(EXP))] public struct MetaHash
{
public uint Hash { get; set; }
@ -606,7 +1023,7 @@ namespace CodeWalker.GameFiles
}
[TypeConverter(typeof(ExpandableObjectConverter))] public struct TextHash
[TC(typeof(EXP))] public struct TextHash
{
public uint Hash { get; set; }
@ -638,4 +1055,10 @@ namespace CodeWalker.GameFiles
}
}

View File

@ -6648,6 +6648,9 @@ zRotation";
ActivateVehicleSiren = 3401359988,
AerialVehiclePoint = 1653545417,
MoveFollowMaster = 3724117664,
AggressiveVehicleDriving = 2626064871,
UseSearchlight = 1524211135,
IgnoreWeatherRestrictions = 176469077,

File diff suppressed because it is too large Load Diff

View File

@ -35,8 +35,8 @@ namespace CodeWalker.GameFiles
{
get
{
if (IsTimeArchetype) return TimeArchetype.CBaseArchetypeDef.name.ToString();
if (IsMloArchetype) return MloArchetype.CBaseArchetypeDef.name.ToString();
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.name.ToString();
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.name.ToString();
return BaseArchetype.name.ToString();
}
}
@ -44,18 +44,16 @@ namespace CodeWalker.GameFiles
{
get
{
if (IsTimeArchetype) return TimeArchetype.CBaseArchetypeDef.assetName.ToString();
if (IsMloArchetype) return MloArchetype.CBaseArchetypeDef.assetName.ToString();
if (IsTimeArchetype) return TimeArchetype.BaseArchetypeDef.assetName.ToString();
if (IsMloArchetype) return MloArchetype.BaseArchetypeDef.assetName.ToString();
return BaseArchetype.assetName.ToString();
}
}
public void Init(YtypFile ytyp, CBaseArchetypeDef arch)
private void InitVars(ref CBaseArchetypeDef arch)
{
Hash = arch.assetName;
if (Hash.Hash == 0) Hash = arch.name;
Ytyp = ytyp;
BaseArchetype = arch;
DrawableDict = arch.drawableDictionary;
TextureDict = arch.textureDictionary;
ClipDict = arch.clipDictionary;
@ -63,44 +61,33 @@ namespace CodeWalker.GameFiles
BBMax = arch.bbMax;
BSCenter = arch.bsCentre;
BSRadius = arch.bsRadius;
IsTimeArchetype = false;
IsMloArchetype = false;
LodDist = arch.lodDist;
}
public void Init(YtypFile ytyp, CTimeArchetypeDef arch)
public void Init(YtypFile ytyp, ref CBaseArchetypeDef arch)
{
Hash = arch.CBaseArchetypeDef.assetName;
if (Hash.Hash == 0) Hash = arch.CBaseArchetypeDef.name;
Ytyp = ytyp;
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;
DrawableDict = arch.CBaseArchetypeDef.drawableDictionary;
TextureDict = arch.CBaseArchetypeDef.textureDictionary;
ClipDict = arch.CBaseArchetypeDef.clipDictionary;
BBMin = arch.CBaseArchetypeDef.bbMin;
BBMax = arch.CBaseArchetypeDef.bbMax;
BSCenter = arch.CBaseArchetypeDef.bsCentre;
BSRadius = arch.CBaseArchetypeDef.bsRadius;
IsTimeArchetype = true;
IsMloArchetype = false;
LodDist = arch.CBaseArchetypeDef.lodDist;
Times = new TimedArchetypeTimes(arch.timeFlags);
Times = new TimedArchetypeTimes(arch.TimeArchetypeDef.timeFlags);
}
public void Init(YtypFile ytyp, CMloArchetypeDef arch)
public void Init(YtypFile ytyp, ref CMloArchetypeDef arch)
{
Hash = arch.CBaseArchetypeDef.assetName;
if (Hash.Hash == 0) Hash = arch.CBaseArchetypeDef.name;
Ytyp = ytyp;
InitVars(ref arch._BaseArchetypeDef);
MloArchetype = arch;
DrawableDict = arch.CBaseArchetypeDef.drawableDictionary;
TextureDict = arch.CBaseArchetypeDef.textureDictionary;
ClipDict = arch.CBaseArchetypeDef.clipDictionary;
BBMin = arch.CBaseArchetypeDef.bbMin;
BBMax = arch.CBaseArchetypeDef.bbMax;
BSCenter = arch.CBaseArchetypeDef.bsCentre;
BSRadius = arch.CBaseArchetypeDef.bsRadius;
IsTimeArchetype = false;
IsMloArchetype = true;
LodDist = arch.CBaseArchetypeDef.lodDist;
}
public bool IsActive(float hour)
@ -133,34 +120,58 @@ namespace CodeWalker.GameFiles
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public class MloEntityData
public class MloInstanceData
{
public YmapEntityDef[] AllEntities { get; set; }
public YmapEntityDef Owner { get; set; }
public CMloInstanceDef _Instance;
public CMloInstanceDef Instance { get { return _Instance; } set { _Instance = value; } }
public uint[] Unk_1407157833 { get; set; }
public YmapEntityDef[] Entities { get; set; }
public void CreateYmapEntities(YmapEntityDef owner, MloArchetypeData mlod)
{
Owner = owner;
if (owner == null) return;
if (mlod.entities == null) return;
AllEntities = new YmapEntityDef[mlod.entities.Length];
for (int i = 0; i < mlod.entities.Length; i++)
var ec = mlod.entities.Length;
Entities = new YmapEntityDef[ec];
for (int i = 0; i < ec; i++)
{
YmapEntityDef e = new YmapEntityDef(null, i, ref mlod.entities[i]);
e.MloRefPosition = e.Position;
e.MloRefOrientation = e.Orientation;
e.MloParent = owner;
e.Position = owner.Position + owner.Orientation.Multiply(e.Position);
e.Orientation = Quaternion.Multiply(owner.Orientation, e.Orientation);
e.Position = owner.Position + owner.Orientation.Multiply(e.MloRefPosition);
e.Orientation = Quaternion.Multiply(owner.Orientation, e.MloRefOrientation);
e.UpdateWidgetPosition();
e.UpdateWidgetOrientation();
Entities[i] = e;
}
}
if ((owner.Orientation != Quaternion.Identity)&&(owner.Orientation.Z!=1.0f))
{ }
AllEntities[i] = e;
public void UpdateEntities()
{
if (Entities == null) return;
if (Owner == null) return;
for (int i = 0; i < Entities.Length; i++)
{
YmapEntityDef e = Entities[i];
e.Position = Owner.Position + Owner.Orientation.Multiply(e.MloRefPosition);
e.Orientation = Quaternion.Multiply(Owner.Orientation, e.MloRefOrientation);
e.UpdateWidgetPosition();
e.UpdateWidgetOrientation();
}
}
}
[TypeConverter(typeof(ExpandableObjectConverter))]
public class TimedArchetypeTimes
{

View File

@ -664,12 +664,14 @@
this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
this.ScenarioAddToProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ScenarioRemoveFromProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsImportMenyooXmlMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsHideGTAVMapMenu = new System.Windows.Forms.ToolStripMenuItem();
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.ToolsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsImportMenyooXmlMenu = new System.Windows.Forms.ToolStripMenuItem();
this.YmapMloInstanceTabPage = new System.Windows.Forms.TabPage();
this.YmapTimecycleModifierTabPage = new System.Windows.Forms.TabPage();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -1027,7 +1029,6 @@
this.ProjectManifestTextBox.CommentPrefix = null;
this.ProjectManifestTextBox.Cursor = System.Windows.Forms.Cursors.IBeam;
this.ProjectManifestTextBox.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
this.ProjectManifestTextBox.Font = new System.Drawing.Font("Courier New", 9.75F);
this.ProjectManifestTextBox.IsReplaceMode = false;
this.ProjectManifestTextBox.Language = FastColoredTextBoxNS.Language.XML;
this.ProjectManifestTextBox.LeftBracket = '<';
@ -1062,6 +1063,8 @@
this.YmapTabControl.Controls.Add(this.YmapYmapTabPage);
this.YmapTabControl.Controls.Add(this.YmapEntityTabPage);
this.YmapTabControl.Controls.Add(this.YmapCarGenTabPage);
this.YmapTabControl.Controls.Add(this.YmapMloInstanceTabPage);
this.YmapTabControl.Controls.Add(this.YmapTimecycleModifierTabPage);
this.YmapTabControl.Location = new System.Drawing.Point(0, 3);
this.YmapTabControl.Name = "YmapTabControl";
this.YmapTabControl.SelectedIndex = 0;
@ -5296,7 +5299,7 @@
"8 - Unk",
"16 - Unk",
"32 - ActivateVehicleSiren",
"64 - Unk",
"64 - AggressiveVehicleDriving",
"128 - Unk",
"256 - Unk",
"512 - Unk",
@ -5316,11 +5319,11 @@
"8388608 - ShortRange",
"16777216 - HighPriority",
"33554432 - IgnoreLoitering",
"67108864 - Unk",
"67108864 - UseSearchlight",
"134217728 - ResetNoCollisionOnCleanUp",
"268435456 - Unk",
"536870912 - Unk",
"1073741824 - Unk"});
"1073741824 - IgnoreWeatherRestrictions"});
this.ScenarioPointFlagsCheckedListBox.Location = new System.Drawing.Point(195, 167);
this.ScenarioPointFlagsCheckedListBox.Name = "ScenarioPointFlagsCheckedListBox";
this.ScenarioPointFlagsCheckedListBox.Size = new System.Drawing.Size(214, 244);
@ -5977,7 +5980,7 @@
"8 - Unk",
"16 - Unk",
"32 - ActivateVehicleSiren",
"64 - Unk",
"64 - AggressiveVehicleDriving",
"128 - Unk",
"256 - Unk",
"512 - Unk",
@ -5997,11 +6000,11 @@
"8388608 - ShortRange",
"16777216 - HighPriority",
"33554432 - IgnoreLoitering",
"67108864 - Unk",
"67108864 - UseSearchlight",
"134217728 - ResetNoCollisionOnCleanUp",
"268435456 - Unk",
"536870912 - Unk",
"1073741824 - Unk"});
"1073741824 - IgnoreWeatherRestrictions"});
this.ScenarioEntityPointFlagsCheckedListBox.Location = new System.Drawing.Point(269, 193);
this.ScenarioEntityPointFlagsCheckedListBox.Name = "ScenarioEntityPointFlagsCheckedListBox";
this.ScenarioEntityPointFlagsCheckedListBox.Size = new System.Drawing.Size(214, 214);
@ -7199,7 +7202,7 @@
"8 - Unk",
"16 - Unk",
"32 - ActivateVehicleSiren",
"64 - Unk",
"64 - AggressiveVehicleDriving",
"128 - Unk",
"256 - Unk",
"512 - Unk",
@ -7219,11 +7222,11 @@
"8388608 - ShortRange",
"16777216 - HighPriority",
"33554432 - IgnoreLoitering",
"67108864 - Unk",
"67108864 - UseSearchlight",
"134217728 - ResetNoCollisionOnCleanUp",
"268435456 - Unk",
"536870912 - Unk",
"1073741824 - Unk"});
"1073741824 - IgnoreWeatherRestrictions"});
this.ScenarioClusterPointFlagsCheckedListBox.Location = new System.Drawing.Point(195, 167);
this.ScenarioClusterPointFlagsCheckedListBox.Name = "ScenarioClusterPointFlagsCheckedListBox";
this.ScenarioClusterPointFlagsCheckedListBox.Size = new System.Drawing.Size(214, 244);
@ -8018,6 +8021,21 @@
this.ScenarioRemoveFromProjectMenu.Text = "Remove from Project";
this.ScenarioRemoveFromProjectMenu.Click += new System.EventHandler(this.ScenarioRemoveFromProjectMenu_Click);
//
// ToolsMenu
//
this.ToolsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolsImportMenyooXmlMenu});
this.ToolsMenu.Name = "ToolsMenu";
this.ToolsMenu.Size = new System.Drawing.Size(47, 20);
this.ToolsMenu.Text = "Tools";
//
// ToolsImportMenyooXmlMenu
//
this.ToolsImportMenyooXmlMenu.Name = "ToolsImportMenyooXmlMenu";
this.ToolsImportMenyooXmlMenu.Size = new System.Drawing.Size(193, 22);
this.ToolsImportMenyooXmlMenu.Text = "Import Menyoo XML...";
this.ToolsImportMenyooXmlMenu.Click += new System.EventHandler(this.ToolsImportMenyooXmlMenu_Click);
//
// OptionsMenu
//
this.OptionsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -8041,20 +8059,23 @@
//
this.OpenFileDialog.Filter = "CodeWalker Projects|*.cwproj";
//
// ToolsMenu
// YmapMloInstanceTabPage
//
this.ToolsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolsImportMenyooXmlMenu});
this.ToolsMenu.Name = "ToolsMenu";
this.ToolsMenu.Size = new System.Drawing.Size(47, 20);
this.ToolsMenu.Text = "Tools";
this.YmapMloInstanceTabPage.Location = new System.Drawing.Point(4, 22);
this.YmapMloInstanceTabPage.Name = "YmapMloInstanceTabPage";
this.YmapMloInstanceTabPage.Size = new System.Drawing.Size(510, 443);
this.YmapMloInstanceTabPage.TabIndex = 3;
this.YmapMloInstanceTabPage.Text = "Mlo Instance";
this.YmapMloInstanceTabPage.UseVisualStyleBackColor = true;
//
// ToolsImportMenyooXmlMenu
// YmapTimecycleModifierTabPage
//
this.ToolsImportMenyooXmlMenu.Name = "ToolsImportMenyooXmlMenu";
this.ToolsImportMenyooXmlMenu.Size = new System.Drawing.Size(193, 22);
this.ToolsImportMenyooXmlMenu.Text = "Import Menyoo XML...";
this.ToolsImportMenyooXmlMenu.Click += new System.EventHandler(this.ToolsImportMenyooXmlMenu_Click);
this.YmapTimecycleModifierTabPage.Location = new System.Drawing.Point(4, 22);
this.YmapTimecycleModifierTabPage.Name = "YmapTimecycleModifierTabPage";
this.YmapTimecycleModifierTabPage.Size = new System.Drawing.Size(510, 443);
this.YmapTimecycleModifierTabPage.TabIndex = 4;
this.YmapTimecycleModifierTabPage.Text = "Time Cycle Modifier";
this.YmapTimecycleModifierTabPage.UseVisualStyleBackColor = true;
//
// ProjectForm
//
@ -8904,5 +8925,7 @@
private System.Windows.Forms.CheckedListBox EntityFlagsCheckedListBox;
private System.Windows.Forms.ToolStripMenuItem ToolsMenu;
private System.Windows.Forms.ToolStripMenuItem ToolsImportMenyooXmlMenu;
private System.Windows.Forms.TabPage YmapMloInstanceTabPage;
private System.Windows.Forms.TabPage YmapTimecycleModifierTabPage;
}
}

View File

@ -1625,11 +1625,11 @@ namespace CodeWalker
if (renderinteriors && ent.IsMlo) //render Mlo child entities...
{
if ((ent.MloData != null) && (ent.MloData.AllEntities != null))
if ((ent.MloInstance != null) && (ent.MloInstance.Entities != null))
{
for (int j = 0; j < ent.MloData.AllEntities.Length; j++)
for (int j = 0; j < ent.MloInstance.Entities.Length; j++)
{
var intent = ent.MloData.AllEntities[j];
var intent = ent.MloInstance.Entities[j];
var intarch = intent.Archetype;
if (intarch == null) continue; //missing archetype...
@ -2279,11 +2279,11 @@ namespace CodeWalker
if (renderinteriors && entity.IsMlo) //render Mlo child entities...
{
if ((entity.MloData != null) && (entity.MloData.AllEntities != null))
if ((entity.MloInstance != null) && (entity.MloInstance.Entities != null))
{
for (int j = 0; j < entity.MloData.AllEntities.Length; j++)
for (int j = 0; j < entity.MloInstance.Entities.Length; j++)
{
var intent = entity.MloData.AllEntities[j];
var intent = entity.MloInstance.Entities[j];
var intarch = intent.Archetype;
if (intarch == null) continue; //missing archetype...
@ -2422,11 +2422,11 @@ namespace CodeWalker
if (arch.IsTimeArchetype)
{
if (!(rendertimedents && (rendertimedentsalways || arch.IsActive(timeofday)))) return false;
archflags = arch.TimeArchetype.CBaseArchetypeDef.flags;
archflags = arch.TimeArchetype.BaseArchetypeDef.flags;
}
else if (arch.IsMloArchetype)
{
archflags = arch.MloArchetype.CBaseArchetypeDef.flags;
archflags = arch.MloArchetype.BaseArchetypeDef.flags;
}
//switch (archflags)
//{
@ -4318,14 +4318,13 @@ namespace CodeWalker
}
}
}
if ((SelectionMode == MapSelectionMode.MloInstance) && (ymap.CMloInstanceDefs != null))
if ((SelectionMode == MapSelectionMode.MloInstance) && (ymap.MloEntities != null))
{
for (int i = 0; i < ymap.CMloInstanceDefs.Length; i++)
for (int i = 0; i < ymap.MloEntities.Length; i++)
{
var ent = (i < ymap.AllEntities.Length) ? ymap.AllEntities[i] : null;
var mlo = ymap.CMloInstanceDefs[i];
var ent = ymap.MloEntities[i];
MapBox mb = new MapBox();
mb.CamRelPos = mlo.CEntityDef.position - camera.Position;
mb.CamRelPos = ent.Position - camera.Position;
mb.BBMin = /*ent?.BBMin ??*/ new Vector3(-1.5f);
mb.BBMax = /*ent?.BBMax ??*/ new Vector3(1.5f);
mb.Orientation = ent?.Orientation ?? Quaternion.Identity;