Skip to content

Commit

Permalink
Merge pull request #598 from monkeyman192/add_field_index
Browse files Browse the repository at this point in the history
Add index attributes to all classes
  • Loading branch information
monkeyman192 authored Apr 26, 2024
2 parents ea608bc + b96951c commit a094a15
Show file tree
Hide file tree
Showing 2,205 changed files with 19,686 additions and 641 deletions.
4 changes: 4 additions & 0 deletions Tools/auto_extract/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
EXTRA_ATTRIBUTES = {
'GcPlayerClothComponentData': ', Alignment = 0x10',
'GcClothComponentData': ', Alignment = 0x10',
'GcMultiColouriseComponentData': ', Alignment = 0x10',
'GcScanEffectComponentData': ', Alignment = 0x10',
'GcSpringAttachmentComponentData': ', Alignment = 0x10',
}
# List of classes to avoid overwriting as the have custom deserialisation
# methods.
Expand All @@ -144,6 +147,7 @@
'TkAnimNodeFrameHalfData',
'TkGeometryData',
'TkMeshData',
'TkAnimNodeData',
]

SUMMARY_FILE = op.join(op.dirname(__file__), 'summary.txt')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

namespace libMBIN.NMS.Toolkit
{
[NMS(GUID = 0x201D028F2C6CBDB7, NameHash = 0x6E19250A34E2CE86)]
public class TkAnimNodeData : NMSTemplate
{
[NMS(Index = 2)]
/* 0x00 */ public int RotIndex;
[NMS(Index = 4)]
/* 0x04 */ public int ScaleIndex;
[NMS(Index = 3)]
/* 0x08 */ public int TransIndex;
[NMS(Index = 0, Size = 0x40, Padding = 0xFE)]
/* 0x0C */ public string Node;
[NMS(Index = 1)]
/* 0x4C */ public bool CanCompress;

public override bool CustomSerialize(BinaryWriter writer, Type field, object fieldData, NMSAttribute settings, FieldInfo fieldInfo, ref List<Tuple<long, object>> additionalData, ref int addtDataIndex)
{
string fieldName = fieldInfo.Name;
switch (fieldName)
{
// This seems to always be 0xFEFEFEFE...
// This values doesn't seem to be used in the exe from what I can tell so I think
// it's safe to always set it as this value.
case nameof(CanCompress):
writer.Write((UInt32) 0xFEFEFEFE);
return true;
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ namespace libMBIN.NMS.Toolkit
[NMS(GUID = 0xC4C8B7669C8C9D44, NameHash = 0x270204EDCEE4DB62)]
public class TkAnimNodeFrameData : NMSTemplate
{
/* 0x00 */ public List<ushort> Rotations;
[NMS(Index = 0)]
/* 0x00 */ public List<Quaternion> Rotations;
[NMS(Index = 2)]
/* 0x10 */ public List<Vector3f> Scales;
[NMS(Index = 1)]
/* 0x20 */ public List<Vector3f> Translations;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ namespace libMBIN.NMS.Toolkit
[NMS(GUID = 0x1F03D88C79D4545B, NameHash = 0xFD9A1D5E0981C57C)]
public class TkAnimNodeFrameHalfData : NMSTemplate
{
[NMS(Index = 0)]
/* 0x00 */ public List<Quaternion> Rotations;
[NMS(Index = 2)]
/* 0x10 */ public List<Vector3f> Scales;
[NMS(Index = 1)]
/* 0x20 */ public List<Vector3f> Translations;

public override object CustomDeserialize(BinaryReader reader, Type field, NMSAttribute settings, FieldInfo fieldInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,47 @@ namespace libMBIN.NMS.Toolkit
[NMS(GUID = 0x3705D946A3B218D4, NameHash = 0xA74EA06001E7577E)]
public class TkGeometryData : NMSTemplate
{
[NMS(Index = 18)]
/* 0x000 */ public TkVertexLayout SmallVertexLayout;
[NMS(Index = 17)]
/* 0x020 */ public TkVertexLayout VertexLayout;
[NMS(Index = 12)]
/* 0x040 */ public List<int> BoundHullVertEd;
[NMS(Index = 16)]
/* 0x050 */ public List<Vector4f> BoundHullVerts;
[NMS(Index = 11)]
/* 0x060 */ public List<int> BoundHullVertSt;
[NMS(Index = 19)]
/* 0x070 */ public List<int> IndexBuffer;
[NMS(Index = 4)]
/* 0x080 */ public List<TkJointBindingData> JointBindings;
[NMS(Index = 5)]
/* 0x090 */ public List<TkJointExtentData> JointExtents;
[NMS(Index = 7)]
/* 0x0A0 */ public List<TkJointMirrorAxis> JointMirrorAxes;
[NMS(Index = 6)]
/* 0x0B0 */ public List<int> JointMirrorPairs;
[NMS(Index = 15)]
/* 0x0C0 */ public List<Vector4f> MeshAABBMax;
[NMS(Index = 14)]
/* 0x0D0 */ public List<Vector4f> MeshAABBMin;
[NMS(Index = 13)]
/* 0x0E0 */ public List<int> MeshBaseSkinMat;
[NMS(Index = 10)]
/* 0x0F0 */ public List<int> MeshVertREnd;
[NMS(Index = 9)]
/* 0x100 */ public List<int> MeshVertRStart;
[NMS(Index = 8)]
/* 0x110 */ public List<int> SkinMatrixLayout;
[NMS(Index = 20)]
/* 0x120 */ public List<TkMeshMetaData> StreamMetaDataArray;
[NMS(Index = 3)]
/* 0x130 */ public int CollisionIndexCount;
[NMS(Index = 1)]
/* 0x134 */ public int IndexCount;
[NMS(Index = 2)]
/* 0x138 */ public int Indices16Bit;
[NMS(Index = 0)]
/* 0x13C */ public int VertexCount;

// TODO: add the list ending to this??
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;

Expand All @@ -11,11 +9,15 @@ namespace libMBIN.NMS.Toolkit
[NMS(GUID = 0xD3AC8F6F7A4D55FC, NameHash = 0xF671716161E708E3)]
public class TkMeshData : NMSTemplate
{
[NMS(Index = 4)]
/* 0x00 */ public byte[] MeshDataStream;
[NMS(Index = 1)]
/* 0x10 */ public ulong Hash;
[NMS(Index = 3)]
/* 0x18 */ public int IndexDataSize;
[NMS(Index = 2)]
/* 0x1C */ public int VertexDataSize;
[NMS(Size = 0x80, Padding = 0xFE)]
[NMS(Index = 0, Size = 0x80, Padding = 0xFE)]
/* 0x20 */ public string IdString;

public override object CustomDeserialize( BinaryReader reader, Type field, NMSAttribute settings, FieldInfo fieldInfo ) {
Expand Down
2 changes: 2 additions & 0 deletions libMBIN/Source/Common/BinaryStreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public static void WriteString( this BinaryWriter writer, string str, Encoding e
Array.Resize(ref stringBytes, stringBytes.Length + 1);
byte[] paddingArray = Enumerable.Repeat(padding, (size ?? default(int)) - stringBytes.Length - 1).ToArray(); // I don't like the null-coalescence here, but it won't ever be default(int) because of the check beforehand...
stringBytes = stringBytes.Concat(paddingArray).ToArray();
// Add the one null byte after the padding.
Array.Resize(ref stringBytes, stringBytes.Length + 1);
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions libMBIN/Source/NMS/GameComponents/AxisSpecification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xE064B06A0D53FBE6, NameHash = 0xE46A33ECA1AA62F7)]
public class AxisSpecification : NMSTemplate
{
[NMS(Index = 1)]
/* 0x00 */ public Vector3f CustomAxis;
// size: 0x7
public enum AxisEnum : uint {
Expand All @@ -14,6 +15,7 @@ public enum AxisEnum : uint {
NegativeZ,
CustomAxis,
}
[NMS(Index = 0)]
/* 0x10 */ public AxisEnum Axis;
}
}
13 changes: 13 additions & 0 deletions libMBIN/Source/NMS/GameComponents/GcAIShipDebugSpawnData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xD616A0433497617, NameHash = 0xDFA8A7A9DD3ACC08)]
public class GcAIShipDebugSpawnData : NMSTemplate
{
[NMS(Index = 1)]
/* 0x00 */ public Vector3f Facing;
[NMS(Index = 3)]
/* 0x10 */ public Vector3f FlightDir;
[NMS(Index = 0)]
/* 0x20 */ public Vector3f Position;
[NMS(Index = 2)]
/* 0x30 */ public Vector3f Up;
[NMS(Index = 12)]
/* 0x40 */ public GcSeed Seed;
[NMS(Index = 8)]
/* 0x50 */ public float HoverHeight;
[NMS(Index = 7)]
/* 0x54 */ public float HoverTime;
[NMS(Index = 5)]
/* 0x58 */ public float IgnitionDelay;
[NMS(Index = 4)]
/* 0x5C */ public float Speed;
[NMS(Index = 6)]
/* 0x60 */ public float TakeOffDelay;
[NMS(Index = 9)]
/* 0x64 */ public float WarpOutTime;
[NMS(Index = 11)]
/* 0x68 */ public NMSString0x80 SpecificModel;
[NMS(Index = 10)]
/* 0xE8 */ public bool Wingman;
}
}
20 changes: 20 additions & 0 deletions libMBIN/Source/NMS/GameComponents/GcAIShipSpawnData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,51 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xBEFE1C3015A6B9AA, NameHash = 0x35C91009067A6431)]
public class GcAIShipSpawnData : NMSTemplate
{
[NMS(Index = 14)]
/* 0x000 */ public Vector3f OffsetSphereOffset;
[NMS(Index = 10)]
/* 0x010 */ public GcAIShipSpawnMarkerData MarkerData;
[NMS(Index = 1)]
/* 0x0C8 */ public NMSString0x20A CombatMessage;
[NMS(Index = 0)]
/* 0x0E8 */ public NMSString0x20A Message;
[NMS(Index = 2)]
/* 0x108 */ public NMSString0x20A OSDMessage;
[NMS(Index = 9)]
/* 0x128 */ public NMSString0x20A RewardMessage;
[NMS(Index = 12)]
/* 0x148 */ public NMSString0x10 AttackDefinition;
[NMS(Index = 19)]
/* 0x158 */ public List<GcAIShipSpawnData> ChildSpawns;
[NMS(Index = 18)]
/* 0x168 */ public GcShipAIPerformanceArray Performances;
[NMS(Index = 8)]
/* 0x178 */ public NMSString0x10 Reward;
[NMS(Index = 15)]
/* 0x188 */ public Vector2f Count;
[NMS(Index = 7)]
/* 0x190 */ public Vector2f Scale;
[NMS(Index = 13)]
/* 0x198 */ public Vector2f Spread;
[NMS(Index = 16)]
/* 0x1A0 */ public Vector2f StartTime;
[NMS(Index = 6)]
/* 0x1A8 */ public float MinRange;
[NMS(Index = 5)]
/* 0x1AC */ public GcAISpaceshipRoles Role;
[NMS(Index = 3)]
/* 0x1B0 */ public TkInputEnum Shortcut;
// size: 0x3
public enum SpawnShapeEnum : uint {
Sphere,
Cone,
OffsetSphere,
}
[NMS(Index = 17)]
/* 0x1B4 */ public SpawnShapeEnum SpawnShape;
[NMS(Index = 11)]
/* 0x1B8 */ public bool AttackFreighter;
[NMS(Index = 4)]
/* 0x1B9 */ public bool WarpIn;
}
}
7 changes: 7 additions & 0 deletions libMBIN/Source/NMS/GameComponents/GcAIShipSpawnMarkerData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x103B4E1E1547DE0E, NameHash = 0xDB40771B3EB38336)]
public class GcAIShipSpawnMarkerData : NMSTemplate
{
[NMS(Index = 1)]
/* 0x00 */ public NMSString0x20A MarkerLabel;
[NMS(Index = 0)]
/* 0x20 */ public TkTextureResource MarkerIcon;
[NMS(Index = 4)]
/* 0xA4 */ public float MaxVisibleRange;
[NMS(Index = 5)]
/* 0xA8 */ public float MinAngleVisible;
[NMS(Index = 3)]
/* 0xAC */ public float MinVisibleRange;
// size: 0x3
public enum ShipsToMarkEnum : uint {
None,
Leader,
All,
}
[NMS(Index = 6)]
/* 0xB0 */ public ShipsToMarkEnum ShipsToMark;
[NMS(Index = 2)]
/* 0xB4 */ public bool HideDuringCombat;
}
}
1 change: 1 addition & 0 deletions libMBIN/Source/NMS/GameComponents/GcAIShipWeapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum AIShipWeaponEnum : uint {
Laser,
MiningLaser,
}
[NMS(Index = 0)]
/* 0x0 */ public AIShipWeaponEnum AIShipWeapon;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x7EB99A1C11C3D004, NameHash = 0x4F5433BCFC028B49)]
public class GcAISpaceshipComponentData : NMSTemplate
{
[NMS(Index = 5)]
/* 0x00 */ public NMSString0x10 CombatDefinitionID;
[NMS(Index = 3)]
/* 0x10 */ public TkModelResource Hangar;
[NMS(Index = 2)]
/* 0x94 */ public GcPrimaryAxis Axis;
[NMS(Index = 1)]
/* 0x98 */ public GcSpaceshipClasses Class;
[NMS(Index = 0)]
/* 0x9C */ public GcAISpaceshipTypes Type;
[NMS(Index = 4)]
/* 0xA0 */ public bool IsSpaceAnomaly;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x8E57C9F9C9C00FE0, NameHash = 0xADEC3C497457F525)]
public class GcAISpaceshipInstanceData : NMSTemplate
{
[NMS(Index = 0)]
/* 0x0 */ public NMSString0x80 File;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x7C6FE3E5B5CFA87E, NameHash = 0x785665CB6C017B4C)]
public class GcAISpaceshipManagerData : NMSTemplate
{
[NMS(Size = 0x5, EnumType = typeof(GcRealityCommonFactions.AIFactionEnum))]
[NMS(Index = 0, Size = 0x5, EnumType = typeof(GcRealityCommonFactions.AIFactionEnum))]
/* 0x00 */ public GcAISpaceshipModelDataArray[] SystemSpaceships;
[NMS(Index = 1)]
/* 0x50 */ public GcAISpaceshipModelData SentinelCrashSiteShip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xD03B9535BB7B5056, NameHash = 0xD67478E5FA6B9871)]
public class GcAISpaceshipMappingData : NMSTemplate
{
[NMS(Size = 0x7, EnumType = typeof(GcAISpaceshipRoles.AIShipRoleEnum))]
[NMS(Index = 0, Size = 0x7, EnumType = typeof(GcAISpaceshipRoles.AIShipRoleEnum))]
/* 0x0 */ public GcAISpaceshipInstanceData[] ClassMap;
}
}
4 changes: 4 additions & 0 deletions libMBIN/Source/NMS/GameComponents/GcAISpaceshipModelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xC56C33DA8B63CF8D, NameHash = 0xA1AD260BA61A04EE)]
public class GcAISpaceshipModelData : NMSTemplate
{
[NMS(Index = 2)]
/* 0x0 */ public GcAISpaceshipRoles AIRole;
[NMS(Index = 1)]
/* 0x4 */ public GcSpaceshipClasses Class;
[NMS(Index = 3)]
/* 0x8 */ public GcFrigateClass FrigateClass;
[NMS(Index = 0)]
/* 0xC */ public NMSString0x80 Filename;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0xBA40C1CA4622577, NameHash = 0x5CA5E4883985A60B)]
public class GcAISpaceshipModelDataArray : NMSTemplate
{
[NMS(Index = 0)]
/* 0x0 */ public List<GcAISpaceshipModelData> Spaceships;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x3C57930CC9E6FEFB, NameHash = 0x74723646531009E2)]
public class GcAISpaceshipPreloadCacheData : NMSTemplate
{
[NMS(Index = 5)]
/* 0x00 */ public NMSString0x20A TextureDescriptorHint;
[NMS(Index = 4)]
/* 0x20 */ public GcSeed Seed;
[NMS(Index = 0)]
/* 0x30 */ public GcRealityCommonFactions Faction;
[NMS(Index = 3)]
/* 0x34 */ public GcFrigateClass FrigateClass;
[NMS(Index = 2)]
/* 0x38 */ public GcSpaceshipClasses ShipClass;
[NMS(Index = 1)]
/* 0x3C */ public GcAISpaceshipRoles ShipRole;
}
}
2 changes: 2 additions & 0 deletions libMBIN/Source/NMS/GameComponents/GcAISpaceshipPreloadList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ namespace libMBIN.NMS.GameComponents
[NMS(GUID = 0x62AF5ABD2941E17E, NameHash = 0xC546551B048ACC33)]
public class GcAISpaceshipPreloadList : NMSTemplate
{
[NMS(Index = 1)]
/* 0x00 */ public List<GcAISpaceshipPreloadCacheData> Cache;
[NMS(Index = 0)]
/* 0x10 */ public GcRealityCommonFactions Faction;
}
}
Loading

0 comments on commit a094a15

Please sign in to comment.