Split many-struct defines into separate files

This commit is contained in:
Kurt
2020-05-01 22:06:28 -07:00
parent 8fefa220e5
commit 34c9742bce
8 changed files with 111 additions and 68 deletions

View File

@@ -60,18 +60,6 @@ public struct GSaveBBS
public uint UniqueId { get; set; } // @0x77c8 size 0x4, align 4
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveDate
{
public const int SIZE = 4;
public override string ToString() => $"{Year:0000}-{Month:00}-{Day:00}";
public ushort Year { get; set; }
public byte Month { get; set; }
public byte Day { get; set; }
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct Handwriting
@@ -89,52 +77,5 @@ public struct Handwriting
public uint VerticesNum { get; set; }
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSavePlayerId
{
public const int SIZE = 0x38;
public override string ToString() => $"{BaseId.Name}-{LandId.Name}";
public GSaveLandId LandId { get; set; }
public GSavePlayerBaseId BaseId { get; set; }
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveLandId
{
public const int SIZE = 0x1C;
public override string ToString() => Name;
public uint Id { get; set; }
[field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Name { get; set; }
public byte IslandRubyType { get; set; }
}
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSavePlayerBaseId
{
public const int SIZE = 0x1C;
public override string ToString() => Name;
public uint Id { get; set; }
[field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Name { get; set; }
public Gender Gender { get; set; }
}
public enum Gender
{
Masculine = 0,
Feminine = 1,
}
}
#pragma warning restore CS8618, CA1815, CA1819, IDE1006

View File

@@ -0,0 +1,18 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveDate
{
public const int SIZE = 4;
public override string ToString() => $"{Year:0000}-{Month:00}-{Day:00}";
public ushort Year { get; set; }
public byte Month { get; set; }
public byte Day { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Explicit, Size = SIZE, Pack = 1)]
@@ -8,18 +9,11 @@ namespace NHSE.Core
public struct GSaveItemName
{
public const int SIZE = 0x08;
public override string ToString() => UniqueID.ToString();
[field: FieldOffset(0x00)] public ushort UniqueID { get; set; }
[field: FieldOffset(0x02)] public byte SystemParam { get; set; }
[field: FieldOffset(0x03)] public byte AdditionalParam { get; set; }
[field: FieldOffset(0x04)] public uint FreeParam { get; set; }
// ReSharper disable once NonReadonlyMemberInGetHashCode
public override int GetHashCode() => UniqueID;
public override bool Equals(object obj) => obj is GSaveItemName i && i.Equals(this);
public bool Equals(GSaveItemName obj) => obj.UniqueID == UniqueID && obj.SystemParam == SystemParam && obj.AdditionalParam == AdditionalParam;
public static bool operator ==(GSaveItemName left, GSaveItemName right) => left.Equals(right);
public static bool operator !=(GSaveItemName left, GSaveItemName right) => !(left == right);
public override string ToString() => UniqueID.ToString();
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveLandId
{
public const int SIZE = 0x1C;
public override string ToString() => Name;
public uint Id { get; set; }
[field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Name { get; set; }
public byte IslandRubyType { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSavePlayerBaseId
{
public const int SIZE = 0x1C;
public override string ToString() => Name;
public uint Id { get; set; }
[field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string Name { get; set; }
public Gender Gender { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSavePlayerId
{
public const int SIZE = 0x38;
public override string ToString() => $"{BaseId.Name}-{LandId.Name}";
public GSaveLandId LandId { get; set; }
public GSavePlayerBaseId BaseId { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = SIZE)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveRoomFloorWall
{
public const int SIZE = 0x24;
public GSaveItemName AccentWallItem { get; set; } // @0x0 size 0x8, align 4
public GSaveItemName WallItem { get; set; } // @0x8 size 0x8, align 4
public GSaveItemName FloorItem { get; set; } // @0x10 size 0x8, align 4
public ushort AccentWallMyDesignID { get; set; } // @0x18 size 0x2, align 2
public ushort WallMyDesignID { get; set; } // @0x1a size 0x2, align 2
public ushort FloorMyDesignID { get; set; } // @0x1c size 0x2, align 2
public byte AccentWallDirection { get; set; } // @0x1e size 0x1, align 1
public byte InfoBit { get; set; } // @0x1f size 0x1, align 1
public byte FloorDirection { get; set; } // @0x20 size 0x1, align 1
}
}

View File

@@ -0,0 +1,8 @@
namespace NHSE.Core
{
public enum Gender
{
Masculine = 0,
Feminine = 1,
}
}