package mii2studio
// Code generated by kaitai-struct-compiler from a .ksy source file. DO NOT EDIT.

import (
	"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
	"golang.org/x/text/encoding/unicode"
)

type Gen2Wiiu3dsMiitomo struct {
	Unknown1 uint8
	CharacterSet uint64
	RegionLock uint64
	ProfanityFlag bool
	Copying bool
	Unknown2 uint64
	MiiPositionSlotIndex uint64
	MiiPositionPageIndex uint64
	Version uint64
	Unknown3 uint64
	SystemId []uint8
	AvatarId []uint8
	ClientId []uint8
	Padding uint16
	Data1 uint16
	MiiName string
	BodyHeight uint8
	BodyWeight uint8
	FaceColor uint64
	FaceType uint64
	Mingle bool
	FaceMakeup uint64
	FaceWrinkles uint64
	HairType uint8
	Unknown5 uint64
	HairFlip bool
	HairColor uint64
	Eye uint32
	Eyebrow uint32
	Nose uint16
	Mouth uint16
	Mouth2 uint16
	Beard uint16
	Glasses uint16
	Mole uint16
	CreatorName string
	Padding2 uint16
	Checksum uint16
	_io *kaitai.Stream
	_root *Gen2Wiiu3dsMiitomo
	_parent interface{}
	_f_glassesColor bool
	glassesColor int
	_f_eyebrowHorizontal bool
	eyebrowHorizontal int
	_f_eyeVertical bool
	eyeVertical int
	_f_facialHairBeard bool
	facialHairBeard int
	_f_mouthSize bool
	mouthSize int
	_f_eyebrowStretch bool
	eyebrowStretch int
	_f_noseVertical bool
	noseVertical int
	_f_eyeColor bool
	eyeColor int
	_f_birthMonth bool
	birthMonth int
	_f_mouthColor bool
	mouthColor int
	_f_moleHorizontal bool
	moleHorizontal int
	_f_facialHairMustache bool
	facialHairMustache int
	_f_eyebrowRotation bool
	eyebrowRotation int
	_f_moleVertical bool
	moleVertical int
	_f_glassesType bool
	glassesType int
	_f_eyebrowSize bool
	eyebrowSize int
	_f_moleSize bool
	moleSize int
	_f_noseSize bool
	noseSize int
	_f_facialHairVertical bool
	facialHairVertical int
	_f_eyeStretch bool
	eyeStretch int
	_f_eyeSize bool
	eyeSize int
	_f_eyeType bool
	eyeType int
	_f_eyeHorizontal bool
	eyeHorizontal int
	_f_eyebrowType bool
	eyebrowType int
	_f_mouthVertical bool
	mouthVertical int
	_f_eyebrowColor bool
	eyebrowColor int
	_f_noseType bool
	noseType int
	_f_facialHairColor bool
	facialHairColor int
	_f_eyebrowVertical bool
	eyebrowVertical int
	_f_glassesSize bool
	glassesSize int
	_f_eyeRotation bool
	eyeRotation int
	_f_gender bool
	gender int
	_f_birthDay bool
	birthDay int
	_f_mouthStretch bool
	mouthStretch int
	_f_moleEnable bool
	moleEnable int
	_f_favorite bool
	favorite int
	_f_glassesVertical bool
	glassesVertical int
	_f_favoriteColor bool
	favoriteColor int
	_f_mouthType bool
	mouthType int
	_f_facialHairSize bool
	facialHairSize int
}
func NewGen2Wiiu3dsMiitomo() *Gen2Wiiu3dsMiitomo {
	return &Gen2Wiiu3dsMiitomo{
	}
}

func (this *Gen2Wiiu3dsMiitomo) Read(io *kaitai.Stream, parent interface{}, root *Gen2Wiiu3dsMiitomo) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp1, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.Unknown1 = tmp1
	tmp2, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.CharacterSet = tmp2
	tmp3, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.RegionLock = tmp3
	tmp4, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.ProfanityFlag = tmp4 != 0
	tmp5, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Copying = tmp5 != 0
	tmp6, err := this._io.ReadBitsIntBe(2)
	if err != nil {
		return err
	}
	this.Unknown2 = tmp6
	tmp7, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.MiiPositionSlotIndex = tmp7
	tmp8, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.MiiPositionPageIndex = tmp8
	tmp9, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.Version = tmp9
	tmp10, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.Unknown3 = tmp10
	this._io.AlignToByte()
	for i := 0; i < int(8); i++ {
		_ = i
		tmp11, err := this._io.ReadU1()
		if err != nil {
			return err
		}
		this.SystemId = append(this.SystemId, tmp11)
	}
	for i := 0; i < int(4); i++ {
		_ = i
		tmp12, err := this._io.ReadU1()
		if err != nil {
			return err
		}
		this.AvatarId = append(this.AvatarId, tmp12)
	}
	for i := 0; i < int(6); i++ {
		_ = i
		tmp13, err := this._io.ReadU1()
		if err != nil {
			return err
		}
		this.ClientId = append(this.ClientId, tmp13)
	}
	tmp14, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Padding = uint16(tmp14)
	tmp15, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Data1 = uint16(tmp15)
	tmp16, err := this._io.ReadBytes(int(20))
	if err != nil {
		return err
	}
	tmp16 = tmp16
	tmp17, err := kaitai.BytesToStr(tmp16, unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM).NewDecoder())
	if err != nil {
		return err
	}
	this.MiiName = tmp17
	tmp18, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.BodyHeight = tmp18
	tmp19, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.BodyWeight = tmp19
	tmp20, err := this._io.ReadBitsIntBe(3)
	if err != nil {
		return err
	}
	this.FaceColor = tmp20
	tmp21, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.FaceType = tmp21
	tmp22, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.Mingle = tmp22 != 0
	tmp23, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.FaceMakeup = tmp23
	tmp24, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.FaceWrinkles = tmp24
	this._io.AlignToByte()
	tmp25, err := this._io.ReadU1()
	if err != nil {
		return err
	}
	this.HairType = tmp25
	tmp26, err := this._io.ReadBitsIntBe(4)
	if err != nil {
		return err
	}
	this.Unknown5 = tmp26
	tmp27, err := this._io.ReadBitsIntBe(1)
	if err != nil {
		return err
	}
	this.HairFlip = tmp27 != 0
	tmp28, err := this._io.ReadBitsIntBe(3)
	if err != nil {
		return err
	}
	this.HairColor = tmp28
	this._io.AlignToByte()
	tmp29, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.Eye = uint32(tmp29)
	tmp30, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.Eyebrow = uint32(tmp30)
	tmp31, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Nose = uint16(tmp31)
	tmp32, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Mouth = uint16(tmp32)
	tmp33, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Mouth2 = uint16(tmp33)
	tmp34, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Beard = uint16(tmp34)
	tmp35, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Glasses = uint16(tmp35)
	tmp36, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Mole = uint16(tmp36)
	tmp37, err := this._io.ReadBytes(int(20))
	if err != nil {
		return err
	}
	tmp37 = tmp37
	tmp38, err := kaitai.BytesToStr(tmp37, unicode.UTF16(unicode.LittleEndian, unicode.IgnoreBOM).NewDecoder())
	if err != nil {
		return err
	}
	this.CreatorName = tmp38
	tmp39, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Padding2 = uint16(tmp39)
	tmp40, err := this._io.ReadU2le()
	if err != nil {
		return err
	}
	this.Checksum = uint16(tmp40)
	return err
}
func (this *Gen2Wiiu3dsMiitomo) GlassesColor() (v int, err error) {
	if (this._f_glassesColor) {
		return this.glassesColor, nil
	}
	this.glassesColor = int(((this.Glasses >> 4) & 7))
	this._f_glassesColor = true
	return this.glassesColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowHorizontal() (v int, err error) {
	if (this._f_eyebrowHorizontal) {
		return this.eyebrowHorizontal, nil
	}
	this.eyebrowHorizontal = int(((this.Eyebrow >> 21) & 15))
	this._f_eyebrowHorizontal = true
	return this.eyebrowHorizontal, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeVertical() (v int, err error) {
	if (this._f_eyeVertical) {
		return this.eyeVertical, nil
	}
	this.eyeVertical = int(((this.Eye >> 25) & 31))
	this._f_eyeVertical = true
	return this.eyeVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) FacialHairBeard() (v int, err error) {
	if (this._f_facialHairBeard) {
		return this.facialHairBeard, nil
	}
	this.facialHairBeard = int((this.Beard & 7))
	this._f_facialHairBeard = true
	return this.facialHairBeard, nil
}
func (this *Gen2Wiiu3dsMiitomo) MouthSize() (v int, err error) {
	if (this._f_mouthSize) {
		return this.mouthSize, nil
	}
	this.mouthSize = int(((this.Mouth >> 9) & 15))
	this._f_mouthSize = true
	return this.mouthSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowStretch() (v int, err error) {
	if (this._f_eyebrowStretch) {
		return this.eyebrowStretch, nil
	}
	this.eyebrowStretch = int(((this.Eyebrow >> 12) & 7))
	this._f_eyebrowStretch = true
	return this.eyebrowStretch, nil
}
func (this *Gen2Wiiu3dsMiitomo) NoseVertical() (v int, err error) {
	if (this._f_noseVertical) {
		return this.noseVertical, nil
	}
	this.noseVertical = int(((this.Nose >> 9) & 31))
	this._f_noseVertical = true
	return this.noseVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeColor() (v int, err error) {
	if (this._f_eyeColor) {
		return this.eyeColor, nil
	}
	this.eyeColor = int(((this.Eye >> 6) & 7))
	this._f_eyeColor = true
	return this.eyeColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) BirthMonth() (v int, err error) {
	if (this._f_birthMonth) {
		return this.birthMonth, nil
	}
	this.birthMonth = int(((this.Data1 >> 1) & 15))
	this._f_birthMonth = true
	return this.birthMonth, nil
}
func (this *Gen2Wiiu3dsMiitomo) MouthColor() (v int, err error) {
	if (this._f_mouthColor) {
		return this.mouthColor, nil
	}
	this.mouthColor = int(((this.Mouth >> 6) & 7))
	this._f_mouthColor = true
	return this.mouthColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) MoleHorizontal() (v int, err error) {
	if (this._f_moleHorizontal) {
		return this.moleHorizontal, nil
	}
	this.moleHorizontal = int(((this.Mole >> 5) & 31))
	this._f_moleHorizontal = true
	return this.moleHorizontal, nil
}
func (this *Gen2Wiiu3dsMiitomo) FacialHairMustache() (v int, err error) {
	if (this._f_facialHairMustache) {
		return this.facialHairMustache, nil
	}
	this.facialHairMustache = int(((this.Mouth2 >> 5) & 7))
	this._f_facialHairMustache = true
	return this.facialHairMustache, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowRotation() (v int, err error) {
	if (this._f_eyebrowRotation) {
		return this.eyebrowRotation, nil
	}
	this.eyebrowRotation = int(((this.Eyebrow >> 16) & 15))
	this._f_eyebrowRotation = true
	return this.eyebrowRotation, nil
}
func (this *Gen2Wiiu3dsMiitomo) MoleVertical() (v int, err error) {
	if (this._f_moleVertical) {
		return this.moleVertical, nil
	}
	this.moleVertical = int(((this.Mole >> 10) & 31))
	this._f_moleVertical = true
	return this.moleVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) GlassesType() (v int, err error) {
	if (this._f_glassesType) {
		return this.glassesType, nil
	}
	this.glassesType = int((this.Glasses & 15))
	this._f_glassesType = true
	return this.glassesType, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowSize() (v int, err error) {
	if (this._f_eyebrowSize) {
		return this.eyebrowSize, nil
	}
	this.eyebrowSize = int(((this.Eyebrow >> 8) & 15))
	this._f_eyebrowSize = true
	return this.eyebrowSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) MoleSize() (v int, err error) {
	if (this._f_moleSize) {
		return this.moleSize, nil
	}
	this.moleSize = int(((this.Mole >> 1) & 15))
	this._f_moleSize = true
	return this.moleSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) NoseSize() (v int, err error) {
	if (this._f_noseSize) {
		return this.noseSize, nil
	}
	this.noseSize = int(((this.Nose >> 5) & 15))
	this._f_noseSize = true
	return this.noseSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) FacialHairVertical() (v int, err error) {
	if (this._f_facialHairVertical) {
		return this.facialHairVertical, nil
	}
	this.facialHairVertical = int(((this.Beard >> 10) & 31))
	this._f_facialHairVertical = true
	return this.facialHairVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeStretch() (v int, err error) {
	if (this._f_eyeStretch) {
		return this.eyeStretch, nil
	}
	this.eyeStretch = int(((this.Eye >> 13) & 7))
	this._f_eyeStretch = true
	return this.eyeStretch, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeSize() (v int, err error) {
	if (this._f_eyeSize) {
		return this.eyeSize, nil
	}
	this.eyeSize = int(((this.Eye >> 9) & 7))
	this._f_eyeSize = true
	return this.eyeSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeType() (v int, err error) {
	if (this._f_eyeType) {
		return this.eyeType, nil
	}
	this.eyeType = int((this.Eye & 63))
	this._f_eyeType = true
	return this.eyeType, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeHorizontal() (v int, err error) {
	if (this._f_eyeHorizontal) {
		return this.eyeHorizontal, nil
	}
	this.eyeHorizontal = int(((this.Eye >> 21) & 15))
	this._f_eyeHorizontal = true
	return this.eyeHorizontal, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowType() (v int, err error) {
	if (this._f_eyebrowType) {
		return this.eyebrowType, nil
	}
	this.eyebrowType = int((this.Eyebrow & 31))
	this._f_eyebrowType = true
	return this.eyebrowType, nil
}
func (this *Gen2Wiiu3dsMiitomo) MouthVertical() (v int, err error) {
	if (this._f_mouthVertical) {
		return this.mouthVertical, nil
	}
	this.mouthVertical = int((this.Mouth2 & 31))
	this._f_mouthVertical = true
	return this.mouthVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowColor() (v int, err error) {
	if (this._f_eyebrowColor) {
		return this.eyebrowColor, nil
	}
	this.eyebrowColor = int(((this.Eyebrow >> 5) & 7))
	this._f_eyebrowColor = true
	return this.eyebrowColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) NoseType() (v int, err error) {
	if (this._f_noseType) {
		return this.noseType, nil
	}
	this.noseType = int((this.Nose & 31))
	this._f_noseType = true
	return this.noseType, nil
}
func (this *Gen2Wiiu3dsMiitomo) FacialHairColor() (v int, err error) {
	if (this._f_facialHairColor) {
		return this.facialHairColor, nil
	}
	this.facialHairColor = int(((this.Beard >> 3) & 7))
	this._f_facialHairColor = true
	return this.facialHairColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyebrowVertical() (v int, err error) {
	if (this._f_eyebrowVertical) {
		return this.eyebrowVertical, nil
	}
	this.eyebrowVertical = int(((this.Eyebrow >> 25) & 31))
	this._f_eyebrowVertical = true
	return this.eyebrowVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) GlassesSize() (v int, err error) {
	if (this._f_glassesSize) {
		return this.glassesSize, nil
	}
	this.glassesSize = int(((this.Glasses >> 7) & 15))
	this._f_glassesSize = true
	return this.glassesSize, nil
}
func (this *Gen2Wiiu3dsMiitomo) EyeRotation() (v int, err error) {
	if (this._f_eyeRotation) {
		return this.eyeRotation, nil
	}
	this.eyeRotation = int(((this.Eye >> 16) & 31))
	this._f_eyeRotation = true
	return this.eyeRotation, nil
}
func (this *Gen2Wiiu3dsMiitomo) Gender() (v int, err error) {
	if (this._f_gender) {
		return this.gender, nil
	}
	this.gender = int((this.Data1 & 1))
	this._f_gender = true
	return this.gender, nil
}
func (this *Gen2Wiiu3dsMiitomo) BirthDay() (v int, err error) {
	if (this._f_birthDay) {
		return this.birthDay, nil
	}
	this.birthDay = int(((this.Data1 >> 5) & 31))
	this._f_birthDay = true
	return this.birthDay, nil
}
func (this *Gen2Wiiu3dsMiitomo) MouthStretch() (v int, err error) {
	if (this._f_mouthStretch) {
		return this.mouthStretch, nil
	}
	this.mouthStretch = int(((this.Mouth >> 13) & 7))
	this._f_mouthStretch = true
	return this.mouthStretch, nil
}
func (this *Gen2Wiiu3dsMiitomo) MoleEnable() (v int, err error) {
	if (this._f_moleEnable) {
		return this.moleEnable, nil
	}
	this.moleEnable = int(((this.Mole >> 0) & 1))
	this._f_moleEnable = true
	return this.moleEnable, nil
}
func (this *Gen2Wiiu3dsMiitomo) Favorite() (v int, err error) {
	if (this._f_favorite) {
		return this.favorite, nil
	}
	this.favorite = int(((this.Data1 >> 14) & 1))
	this._f_favorite = true
	return this.favorite, nil
}
func (this *Gen2Wiiu3dsMiitomo) GlassesVertical() (v int, err error) {
	if (this._f_glassesVertical) {
		return this.glassesVertical, nil
	}
	this.glassesVertical = int(((this.Glasses >> 11) & 31))
	this._f_glassesVertical = true
	return this.glassesVertical, nil
}
func (this *Gen2Wiiu3dsMiitomo) FavoriteColor() (v int, err error) {
	if (this._f_favoriteColor) {
		return this.favoriteColor, nil
	}
	this.favoriteColor = int(((this.Data1 >> 10) & 15))
	this._f_favoriteColor = true
	return this.favoriteColor, nil
}
func (this *Gen2Wiiu3dsMiitomo) MouthType() (v int, err error) {
	if (this._f_mouthType) {
		return this.mouthType, nil
	}
	this.mouthType = int((this.Mouth & 63))
	this._f_mouthType = true
	return this.mouthType, nil
}
func (this *Gen2Wiiu3dsMiitomo) FacialHairSize() (v int, err error) {
	if (this._f_facialHairSize) {
		return this.facialHairSize, nil
	}
	this.facialHairSize = int(((this.Beard >> 6) & 15))
	this._f_facialHairSize = true
	return this.facialHairSize, nil
}

/**
 * Always 3?
 */

/**
 * 0=JPN+USA+EUR, 1=CHN, 2=KOR, 3=TWN
 */

/**
 * 0=no lock, 1=JPN, 2=USA, 3=EUR
 */
