Resource types cleanup

This commit is contained in:
dexy 2020-01-27 06:35:15 +11:00
parent ad61b39920
commit cedf2f73f6
2 changed files with 18 additions and 223 deletions

View File

@ -177,7 +177,7 @@ namespace CodeWalker.GameFiles
public ulong Unknown_8h; // 0x0000000000000000 public ulong Unknown_8h; // 0x0000000000000000
public ulong Unknown_10h; // 0x0000000000000000 public ulong Unknown_10h; // 0x0000000000000000
public ulong Unknown_18h = 1; // 0x0000000000000001 public ulong Unknown_18h = 1; // 0x0000000000000001
public ResourceSimpleList64<uint_r> ParticleRuleNameHashes { get; set; } public ResourceSimpleList64_s<MetaHash> ParticleRuleNameHashes { get; set; }
public ResourcePointerList64<ParticleRule> ParticleRules { get; set; } public ResourcePointerList64<ParticleRule> ParticleRules { get; set; }
@ -189,7 +189,7 @@ namespace CodeWalker.GameFiles
this.Unknown_8h = reader.ReadUInt64(); this.Unknown_8h = reader.ReadUInt64();
this.Unknown_10h = reader.ReadUInt64(); this.Unknown_10h = reader.ReadUInt64();
this.Unknown_18h = reader.ReadUInt64(); this.Unknown_18h = reader.ReadUInt64();
this.ParticleRuleNameHashes = reader.ReadBlock<ResourceSimpleList64<uint_r>>(); this.ParticleRuleNameHashes = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
this.ParticleRules = reader.ReadBlock<ResourcePointerList64<ParticleRule>>(); this.ParticleRules = reader.ReadBlock<ResourcePointerList64<ParticleRule>>();
//if (Unknown_4h != 1) //if (Unknown_4h != 1)
@ -203,6 +203,7 @@ namespace CodeWalker.GameFiles
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// write structure data // write structure data
writer.Write(this.VFT); writer.Write(this.VFT);
writer.Write(this.Unknown_4h); writer.Write(this.Unknown_4h);
@ -236,7 +237,7 @@ namespace CodeWalker.GameFiles
public ulong Unknown_8h; // 0x0000000000000000 public ulong Unknown_8h; // 0x0000000000000000
public ulong Unknown_10h; // 0x0000000000000000 public ulong Unknown_10h; // 0x0000000000000000
public ulong Unknown_18h = 1; // 0x0000000000000001 public ulong Unknown_18h = 1; // 0x0000000000000001
public ResourceSimpleList64<uint_r> EffectRuleNameHashes { get; set; } public ResourceSimpleList64_s<MetaHash> EffectRuleNameHashes { get; set; }
public ResourcePointerList64<ParticleEffectRule> EffectRules { get; set; } public ResourcePointerList64<ParticleEffectRule> EffectRules { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters) public override void Read(ResourceDataReader reader, params object[] parameters)
@ -247,7 +248,7 @@ namespace CodeWalker.GameFiles
this.Unknown_8h = reader.ReadUInt64(); this.Unknown_8h = reader.ReadUInt64();
this.Unknown_10h = reader.ReadUInt64(); this.Unknown_10h = reader.ReadUInt64();
this.Unknown_18h = reader.ReadUInt64(); this.Unknown_18h = reader.ReadUInt64();
this.EffectRuleNameHashes = reader.ReadBlock<ResourceSimpleList64<uint_r>>(); this.EffectRuleNameHashes = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
this.EffectRules = reader.ReadBlock<ResourcePointerList64<ParticleEffectRule>>(); this.EffectRules = reader.ReadBlock<ResourcePointerList64<ParticleEffectRule>>();
//if (Unknown_4h != 1) //if (Unknown_4h != 1)
@ -294,18 +295,9 @@ namespace CodeWalker.GameFiles
public ulong Unknown_8h; // 0x0000000000000000 public ulong Unknown_8h; // 0x0000000000000000
public ulong Unknown_10h; // 0x0000000000000000 public ulong Unknown_10h; // 0x0000000000000000
public ulong Unknown_18h = 1; // 0x0000000000000001 public ulong Unknown_18h = 1; // 0x0000000000000001
public ulong HashesPointer { get; set; } public ResourceSimpleList64_s<MetaHash> EmitterRuleNameHashes { get; set; }
public ushort HashesCount1 { get; set; } public ResourcePointerList64<ParticleEmitterRule> EmitterRules { get; set; }
public ushort HashesCount2 { get; set; }
public uint Unknown_2Ch; // 0x00000000
public ulong EffectRulesPointer { get; set; }
public ushort EffectRulesCount1 { get; set; }
public ushort EffectRulesCount2 { get; set; }
public uint Unknown_3Ch; // 0x00000000
// reference data
public ResourceSimpleArray<uint_r> Hashes { get; set; }
public ResourcePointerArray64<ParticleEmitterRule> EmitterRules { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters) public override void Read(ResourceDataReader reader, params object[] parameters)
{ {
@ -315,18 +307,9 @@ namespace CodeWalker.GameFiles
this.Unknown_8h = reader.ReadUInt64(); this.Unknown_8h = reader.ReadUInt64();
this.Unknown_10h = reader.ReadUInt64(); this.Unknown_10h = reader.ReadUInt64();
this.Unknown_18h = reader.ReadUInt64(); this.Unknown_18h = reader.ReadUInt64();
this.HashesPointer = reader.ReadUInt64(); this.EmitterRuleNameHashes = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
this.HashesCount1 = reader.ReadUInt16(); this.EmitterRules = reader.ReadBlock<ResourcePointerList64<ParticleEmitterRule>>();
this.HashesCount2 = reader.ReadUInt16();
this.Unknown_2Ch = reader.ReadUInt32();
this.EffectRulesPointer = reader.ReadUInt64();
this.EffectRulesCount1 = reader.ReadUInt16();
this.EffectRulesCount2 = reader.ReadUInt16();
this.Unknown_3Ch = reader.ReadUInt32();
// read reference data
this.Hashes = reader.ReadBlockAt<ResourceSimpleArray<uint_r>>(this.HashesPointer, this.HashesCount1);
this.EmitterRules = reader.ReadBlockAt<ResourcePointerArray64<ParticleEmitterRule>>(this.EffectRulesPointer, this.EffectRulesCount1);
//if (Unknown_4h != 1) //if (Unknown_4h != 1)
//{ }//no hit //{ }//no hit
@ -336,20 +319,9 @@ namespace CodeWalker.GameFiles
//{ }//no hit //{ }//no hit
//if (Unknown_18h != 1) //if (Unknown_18h != 1)
//{ }//no hit //{ }//no hit
//if (Unknown_2Ch != 0)
//{ }//no hit
//if (Unknown_3Ch != 0)
//{ }//no hit
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// update structure data
this.HashesPointer = (ulong)(this.Hashes != null ? this.Hashes.FilePosition : 0);
this.HashesCount1 = (ushort)(this.Hashes != null ? this.Hashes.Count : 0);
this.HashesCount2 = this.HashesCount1;
this.EffectRulesPointer = (ulong)(this.EmitterRules != null ? this.EmitterRules.FilePosition : 0);
this.EffectRulesCount1 = (ushort)(this.EmitterRules != null ? this.EmitterRules.Count : 0);
this.EffectRulesCount2 = this.EffectRulesCount1;
// write structure data // write structure data
writer.Write(this.VFT); writer.Write(this.VFT);
@ -357,22 +329,16 @@ namespace CodeWalker.GameFiles
writer.Write(this.Unknown_8h); writer.Write(this.Unknown_8h);
writer.Write(this.Unknown_10h); writer.Write(this.Unknown_10h);
writer.Write(this.Unknown_18h); writer.Write(this.Unknown_18h);
writer.Write(this.HashesPointer); writer.WriteBlock(this.EmitterRuleNameHashes);
writer.Write(this.HashesCount1); writer.WriteBlock(this.EmitterRules);
writer.Write(this.HashesCount2);
writer.Write(this.Unknown_2Ch);
writer.Write(this.EffectRulesPointer);
writer.Write(this.EffectRulesCount1);
writer.Write(this.EffectRulesCount2);
writer.Write(this.Unknown_3Ch);
} }
public override IResourceBlock[] GetReferences() public override Tuple<long, IResourceBlock>[] GetParts()
{ {
var list = new List<IResourceBlock>(); return new Tuple<long, IResourceBlock>[] {
if (Hashes != null) list.Add(Hashes); new Tuple<long, IResourceBlock>(0x20, EmitterRuleNameHashes),
if (EmitterRules != null) list.Add(EmitterRules); new Tuple<long, IResourceBlock>(0x30, EmitterRules)
return list.ToArray(); };
} }
} }
@ -887,7 +853,7 @@ namespace CodeWalker.GameFiles
public ulong Unknown_28h; // 0x0000000000000000 public ulong Unknown_28h; // 0x0000000000000000
public ulong Unknown_30h; // 0x0000000000000000 public ulong Unknown_30h; // 0x0000000000000000
public ulong Unknown_38h; // 0x0000000000000000 public ulong Unknown_38h; // 0x0000000000000000
public ResourceSimpleList64<uint_r> Unknown_40h { get; set; } public ResourceSimpleList64_s<MetaHash> Unknown_40h { get; set; }
public uint Unknown_50h { get; set; } public uint Unknown_50h { get; set; }
public uint Unknown_54h; // 0x00000000 public uint Unknown_54h; // 0x00000000
@ -899,7 +865,7 @@ namespace CodeWalker.GameFiles
this.Unknown_28h = reader.ReadUInt64(); this.Unknown_28h = reader.ReadUInt64();
this.Unknown_30h = reader.ReadUInt64(); this.Unknown_30h = reader.ReadUInt64();
this.Unknown_38h = reader.ReadUInt64(); this.Unknown_38h = reader.ReadUInt64();
this.Unknown_40h = reader.ReadBlock<ResourceSimpleList64<uint_r>>(); this.Unknown_40h = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
this.Unknown_50h = reader.ReadUInt32(); this.Unknown_50h = reader.ReadUInt32();
this.Unknown_54h = reader.ReadUInt32(); this.Unknown_54h = reader.ReadUInt32();

View File

@ -36,45 +36,6 @@ namespace CodeWalker.GameFiles
{ {
[TypeConverter(typeof(ExpandableObjectConverter))] public class uint_r : ResourceSystemBlock
{
// Represents a uint that can be referenced in a resource structure.
/// <summary>
/// Gets the length of the uint.
/// </summary>
public override long BlockLength
{
get { return 4; }
}
/// <summary>
/// Gets or sets the uint value.
/// </summary>
public uint Value { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters)
{
Value = reader.ReadUInt32();
}
public override void Write(ResourceDataWriter writer, params object[] parameters)
{
writer.Write(Value);
}
public static explicit operator uint(uint_r value)
{
return value.Value;
}
public static explicit operator uint_r(uint value)
{
var x = new uint_r();
x.Value = value;
return x;
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class string_r : ResourceSystemBlock [TypeConverter(typeof(ExpandableObjectConverter))] public class string_r : ResourceSystemBlock
{ {
@ -1917,138 +1878,6 @@ namespace CodeWalker.GameFiles
} }
} }
[TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleArrayArray64<T> : ListBase<ResourceSimpleArray<T>> where T : IResourceSystemBlock, new()
{
/// <summary>
/// Gets the length of the data block.
/// </summary>
public override long BlockLength
{
get
{
long len = 8 * Data.Count;
//foreach (var f in Data)
// len += f.BlockLength;
return len;
}
}
public ResourceSimpleArrayArray64()
{
Data = new List<ResourceSimpleArray<T>>();
}
public List<ulong> ptr_list { get; private set; }
/// <summary>
/// Reads the data block.
/// </summary>
public override void Read(ResourceDataReader reader, params object[] parameters)
{
if (parameters[1] is uint[])
{
//version for raw arrays from dexy
var numEl2 = (uint[])parameters[1];
ptr_list = new List<ulong>();
for (int i = 0; i < numEl2.Length; i++)
ptr_list.Add(reader.ReadUInt64());
for (int i = 0; i < numEl2.Length; i++)
{
var xarr = reader.ReadBlockAt<ResourceSimpleArray<T>>(ptr_list[i], numEl2[i]);
Data.Add(xarr);
}
return;
}
var numEl = (ResourceSimpleArray<uint_r>)parameters[1];
ptr_list = new List<ulong>();
for (int i = 0; i < numEl.Count; i++)
ptr_list.Add(reader.ReadUInt64());
for (int i = 0; i < numEl.Count; i++)
{
var xarr = reader.ReadBlockAt<ResourceSimpleArray<T>>(ptr_list[i], (uint)numEl[i]);
Data.Add(xarr);
}
//int numElements = Convert.ToInt32(parameters[0]);
//Data = new List<T>();
//for (int i = 0; i < numElements; i++)
//{
// T item = reader.ReadBlock<T>();
// Data.Add(item);
//}
}
/// <summary>
/// Writes the data block.
/// </summary>
public override void Write(ResourceDataWriter writer, params object[] parameters)
{
//foreach (var f in Data)
// f.Write(writer);
ptr_list = new List<ulong>();
foreach (var x in Data)
ptr_list.Add((ulong)x.FilePosition);
foreach (var x in ptr_list)
writer.Write(x);
//foreach (var x in Data)
// x.Write(writer);
}
public override IResourceBlock[] GetReferences()
{
var children = new List<IResourceBlock>();
if (Data != null) children.AddRange(Data);
return children.ToArray();
}
public override Tuple<long, IResourceBlock>[] GetParts()
{
var children = new List<Tuple<long, IResourceBlock>>();
//if (Data != null)
//{
// long len = 8 * Data.Count;
// foreach (var f in Data)
// {
// children.Add(new Tuple<long, IResourceBlock>(len, f));
// len += f.BlockLength;
// }
//}
return children.ToArray();
}
public override string ToString()
{
return "(Count: " + ((ptr_list != null) ? ptr_list.Count : 0).ToString() + ")";
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleArray2<T, U> : ResourceSystemBlock where T : IResourceSystemBlock, new() where U : IResourceSystemBlock, new() [TypeConverter(typeof(ExpandableObjectConverter))] public class ResourceSimpleArray2<T, U> : ResourceSystemBlock where T : IResourceSystemBlock, new() where U : IResourceSystemBlock, new()
{ {
public ResourceSimpleArray<T> Array1 { get; private set; } public ResourceSimpleArray<T> Array1 { get; private set; }