using System.Runtime.InteropServices;
using UnityEngine;

namespace MindPowerSdk
{
    public class lwHelperInfo
    {
        /* this+0x4 */
        public uint type; // MindPower::lwHelperInfoType 

        [MarshalAs(UnmanagedType.LPArray)]
        /* this+0x8 */
        public lwHelperDummyInfo[] dummy_seq;

        [MarshalAs(UnmanagedType.LPArray)]
        /* this+0xc */
        public lwHelperBoxInfo[] box_seq;

        [MarshalAs(UnmanagedType.LPArray)]
        /* this+0x10 */
        public lwHelperMeshInfo[] mesh_seq;

        [MarshalAs(UnmanagedType.LPArray)]
        /* this+0x14 */
        public lwBoundingBoxInfo[] bbox_seq;

        [MarshalAs(UnmanagedType.LPArray)]
        /* this+0x18 */
        public lwBoundingSphereInfo[] bsphere_seq;

        /* this+0x1c */
        public uint dummy_num;

        /* this+0x20 */
        public uint box_num;

        /* this+0x24 */
        public uint mesh_num;

        /* this+0x28 */
        public uint bbox_num;

        /* this+0x2c */
        public uint bsphere_num;
    }

    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct lwHelperDummyInfo
    {
        public uint Id;
        public Matrix4x4 Mat;
        public Matrix4x4 MatLocal;
        public uint ParentType; // 0: default, 1: bone parent, 2: bone dummy parent
        public uint ParentId;
    }

    public struct lwHelperBoxInfo
    {
        public uint Id;
        public uint Type;
        public uint State;
        public Bounds Box;
        public Matrix4x4 Mat;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string Name; // 32
    }

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public class lwHelperMeshInfo
    {
        public uint Id;
        public uint Type;

        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
        public string Name;

        public uint State;
        public uint SubType;
        public Matrix4x4 Mat;
        public Bounds Box;

        [MarshalAs(UnmanagedType.LPArray)] public Vector3[] VertexSeq;

        [MarshalAs(UnmanagedType.LPArray)] public lwHelperMeshFaceInfo[] face_seq;
        public uint vertex_num;
        public uint face_num;
    }

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct lwHelperMeshFaceInfo
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public uint[] vertex;

        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
        public uint[] adj_face;

        public Plane plane;

        public Vector3 center;
    }

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct lwBoundingBoxInfo
    {
        /* this+0x0 */
        public uint id;

        /* this+0x4 */
        public Bounds box;

        /* this+0x1c */
        public Matrix4x4 mat;
    };

    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct lwBoundingSphereInfo
    {
        /* this+0x0 */
        public uint id;

        /* this+0x4 */
        public BoundingSphere sphere;

        /* this+0x14 */
        public Matrix4x4 mat;
    };
}