Add additional property accessors for room

unused in logic
This commit is contained in:
Kurt 2020-05-13 12:17:10 -07:00
parent 37176b5a1a
commit 56c1cc31da
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 2, Size = SIZE)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveAudioInfo
{
public const int SIZE = 0x4;
public short PlayingAudioMusicID { get; set; }
public sbyte Unknown { get; set; }
[field: MarshalAs(UnmanagedType.I1, SizeConst = 1)]
public bool IsShuffle { get; set; }
};
}

View File

@ -19,5 +19,20 @@ public class PlayerRoom
public const int LayerCount = 8;
public RoomItemLayer[] GetItemLayers() => RoomItemLayer.GetArray(Data.Slice(0, LayerCount * RoomItemLayer.SIZE));
public void SetItemLayers(IReadOnlyList<RoomItemLayer> value) => RoomItemLayer.SetArray(value).CopyTo(Data, 0);
public bool GetIsActive(int layer, int x, int y) => FlagUtil.GetFlag(Data, 0x6400 + (layer * 0x34), (y * 20) + x);
public void SetIsActive(int layer, int x, int y, bool value = true) => FlagUtil.SetFlag(Data, 0x6400 + (layer * 0x34), (y * 20) + x, value);
public GSaveAudioInfo AudioInfo
{
get => Data.Slice(0x65A0, GSaveAudioInfo.SIZE).ToStructure<GSaveAudioInfo>();
set => value.ToBytes().CopyTo(Data, 0x65A0);
}
public GSaveRoomFloorWall RoomFloorWall
{
get => Data.Slice(0x65A4, GSaveRoomFloorWall.SIZE).ToStructure<GSaveRoomFloorWall>();
set => value.ToBytes().CopyTo(Data, 0x65A4);
}
}
}

View File

@ -17,6 +17,7 @@ public class FancyMarshalTests
[Fact] public void MarshalHandwriting() => MarshalBytesTestS<Handwriting>(Handwriting.SIZE);
[Fact] public void MarshalGSaveRoomFloorWall() => MarshalBytesTestS<GSaveRoomFloorWall>(GSaveRoomFloorWall.SIZE);
[Fact] public void MarshalGSaveAudioInfo() => MarshalBytesTestS<GSaveAudioInfo>(GSaveAudioInfo.SIZE);
[Fact] public void MarshalGSaveManpu() => MarshalBytesTestS<GSavePlayerManpu>(GSavePlayerManpu.SIZE);
[Fact] public void MarshalGSavePlayerHandleName() => MarshalBytesTestS<GSavePlayerHandleName>(GSavePlayerHandleName.SIZE);