using Godot;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace AvatarDoll
{
	[Flags]
	public enum PartScope : short
	{
		Body = 1 << 0,
		Head = 1 << 1,
		Hair = 1 << 2,
		Face = 1 << 3,
		Cloth = 1 << 4,
		
		All = Body | Head | Hair | Face | Cloth
	}
	
	#region BodySlot
	// ##############################################################################

	public enum EBodySlot_Type1 : short
	{
		_头发 = 0, // BodySlot_Type2_Hair
		_脸部 = 1, // BodySlot_Type2_Face
		_颈部 = 2, // BodySlot_Type2_Neck
		_上身 = 3, // BodySlot_Type2_UpperBody
		_手部 = 4, // BodySlot_Type2_Hand
		_下身 = 5, // BodySlot_Type2_LowerBody
		_腿部 = 6, // BodySlot_Type2_Leg
		_脚部 = 7, // BodySlot_Type2_Foot
		_漂浮物 = 8, // BodySlot_Type2_Floating
	}

	public enum EBodySlot_Type2_Hair : short
	{
		_发型 = 0,
		_头顶 = 1,
		_发侧L = 2,
		_发侧R = 3,
		_发后 = 4,
		_额头 = 5,
	}

	public enum EBodySlot_Type2_Face : short
	{
		_眼L = 0,
		_眼R = 1,
		_耳廓L = 2,
		_耳廓R = 3,
		_耳垂L = 4,
		_耳垂R = 5,
		_鼻子 = 6,
		_嘴巴 = 7,
		_下巴 = 8,
		_脸颊L = 9,
		_脸颊R = 10,
	}

	public enum EBodySlot_Type2_Neck : short
	{
		_脖子 = 0,
		_胸前 = 1,
	}

	public enum EBodySlot_Type2_UpperBody : short
	{
		_前胸L = 0,
		_前胸R = 1,
		_肩膀L = 2,
		_肩膀R = 3,
		_后背L = 4,
		_后背R = 5,
		_大臂L = 6,
		_大臂R = 7,
		_小臂L = 8,
		_小臂R = 9,
	}

	public enum EBodySlot_Type2_Hand : short
	{
		_手腕L = 0,
		_手背L = 1,
		_手掌L = 2,
		_手上L = 3,
		_手指L_拇指 = 4,
		_手指L_食指 = 5,
		_手指L_中指 = 6,
		_手指L_无名指 = 7,
		_手指L_尾指 = 8,
		_指甲L_拇指 = 9,
		_指甲L_食指 = 10,
		_指甲L_中指 = 11,
		_指甲L_无名指 = 12,
		_指甲L_尾指 = 13,

		_手腕R = 14,
		_手背R = 15,
		_手掌R = 16,
		_手上R = 17,
		_手指R_拇指 = 18,
		_手指R_食指 = 19,
		_手指R_中指 = 20,
		_手指R_无名指 = 21,
		_手指R_尾指 = 22,
		_指甲R_拇指 = 23,
		_指甲R_食指 = 24,
		_指甲R_中指 = 25,
		_指甲R_无名指 = 26,
		_指甲R_尾指 = 27,
	}

	public enum EBodySlot_Type2_LowerBody : short
	{
		_腰部 = 0,
		_后腰 = 1,
		_腹部 = 2,
		_胯部 = 3,
	}

	public enum EBodySlot_Type2_Leg : short
	{
		_大腿L = 0,
		_大腿R = 1,
		_膝盖L = 2,
		_膝盖R = 3,
		_小腿L = 4,
		_小腿R = 5,
	}

	public enum EBodySlot_Type2_Foot : short
	{
		_脚踝L = 0,
		_脚背L = 1,
		_脚底L = 2,
		_趾甲L = 3,
		_脚踝R = 4,
		_脚背R = 5,
		_脚底R = 6,
		_趾甲R = 7,
	}

	public enum EBodySlot_Type2_Floating : short
	{
		_头顶上方 = 0,
		_头后方 = 1,
		_背后方 = 2,
		_背景 = 3,
		_前方 = 4,
		_前景 = 5,
	}

	public struct BodySlot
	{
		private int _hash;

		public EBodySlot_Type1 Type1
		{
			get => (EBodySlot_Type1)((_hash >> 16) & 0xFFFF);
			set => _hash = ((_hash & 0x0000FFFF) | (((short)value & 0xFFFF) << 16));
		}

		public short Type2
		{
			get => (short)(_hash & 0xFFFF);
			set => _hash = (int)((_hash & 0xFFFF0000u) | (uint)(value & 0xFFFF));
		}

		public int Hash => _hash;

		public BodySlot(EClothClasses_Type1 type1, short type2)
		{
			_hash = (((short)type1 & 0xFFFF) << 16) | (type2 & 0xFFFF);
		}

		public override bool Equals(object obj)
		{
			return obj is BodySlot other && this._hash == other._hash;
		}

		public override int GetHashCode() => _hash;
	}

	#endregion

	# region ClothClasses
	// ##############################################################################
	
	public enum EClothClasses_Type1 : short
	{
		_纹身 = 0, // ClothClasses_Type2_Tattoo
		_衣服 = 1, // ClothClasses_Type2_Cloth
		_饰品 = 2, // ClothClasses_Type2_Accessory
		_武器 = 3, // ClothClasses_Type2_Weapon
		_特效装饰 = 4, // ClothClasses_Type2_Effect
	}

	public enum EClothClasses_Type2_Tattoo : short
	{
		_脸部纹身 = 0,
		_身体纹身 = 1,
	}

	public enum EClothClasses_Type2_Cloth : short
	{
		_套服 = 0,
		_上衣 = 1,
		_裤子 = 2,
		_裙子 = 3,
		_手套 = 4,
		_袜子 = 5,
		_鞋子 = 6,
		_披风 = 7,
	}

	public enum EClothClasses_Type2_Accessory : short
	{
		_发饰 = 0,
		_耳饰 = 1,
		_脸饰 = 2,
		_首饰 = 3,
		_手饰 = 4,
		_脚饰 = 5,
		_指甲 = 6,
		_趾甲 = 7,
	}

	public enum EClothClasses_Type2_Weapon : short
	{
		_单手武器 = 0,
		_双手武器 = 1,
	}

	public enum EClothClasses_Type2_Effect : short
	{
		_光环 = 0,
		_翅膀 = 1,
		_特效 = 2,
		_前景 = 3,
		_背景 = 4,
	}

	#endregion

	public enum ThemeColor: byte
	{
		Black = 0,			// 黑色		000000	0,0,0
		White = 1,			// 白色		ffffff	255,255,255
		Grey = 2,			// 灰色		808080	128,128,128
		Red = 3,			// 红色		cc0000	204,0,0
		Orange = 4,			// 橙色		ff9900	255,153,0
		Yellow = 5,			// 黄色		ffcc00	255,204,0
		AppleGreen = 6,		// 嫩绿		99cc33	153,204,51
		GrassGreen = 7,		// 草绿		009944	0,153,68
		MikuGreen = 8,		// 葱绿		009999	0,153,153
		SkyBlue = 9,		// 天蓝		0099ff	0,153,255
		Blue = 10,			// 蓝色		0000cc	0,0,204
		NavyBlue = 11,		// 深蓝		003366	0,51,102
		BlueViolet = 12,	// 蓝紫色	6633ff	102,51,255
		Purple = 13,		// 紫色		660099	102,0,153
		DarkPurple = 14,	// 葡萄紫	990099	153,0,153
		HotPink = 15,		// 爱心粉	ff99cc	255,153,204
		LightPink = 16,		// 淡粉色	FFCCCC	255,204,204
		Brown = 17,			// 棕色		663300	102,51,0
	}

	public enum ClothTag
	{
		_基础款,
		
	}
	
	public enum ClothSetTheme
	{
		_基础款,
		
	}
} 