package space

import (
	fmt "fmt"
	geometry "github.com/elojah/game_02/pkg/geometry"
	github_com_elojah_game_02_pkg_ulid "github.com/elojah/game_02/pkg/ulid"
	_ "github.com/gogo/protobuf/gogoproto"
	proto "github.com/gogo/protobuf/proto"
	github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
	io "io"
	math "math"
	math_bits "math/bits"
	reflect "reflect"
	strings "strings"
)

var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

const _ = proto.GoGoProtoPackageIsVersion3 

type Sector struct {
	ID        github_com_elojah_game_02_pkg_ulid.ID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=github.com/elojah/game_02/pkg/ulid.ID" json:"ID"`
	Dim       geometry.Vec3                         `protobuf:"bytes,2,opt,name=Dim,proto3" json:"Dim"`
	Adjacents map[string]geometry.Vec3              `protobuf:"bytes,3,rep,name=Adjacents,proto3" json:"Adjacents" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
	TileMap   TileMap                               `protobuf:"bytes,4,opt,name=TileMap,proto3" json:"TileMap"`
}

func (m *Sector) Reset()      { *m = Sector{} }
func (*Sector) ProtoMessage() {}
func (*Sector) Descriptor() ([]byte, []int) {
	return fileDescriptor_1d2ba01984712cee, []int{0}
}
func (m *Sector) XXX_Unmarshal(b []byte) error {
	return m.Unmarshal(b)
}
func (m *Sector) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	if deterministic {
		return xxx_messageInfo_Sector.Marshal(b, m, deterministic)
	} else {
		b = b[:cap(b)]
		n, err := m.MarshalToSizedBuffer(b)
		if err != nil {
			return nil, err
		}
		return b[:n], nil
	}
}
func (m *Sector) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Sector.Merge(m, src)
}
func (m *Sector) XXX_Size() int {
	return m.Size()
}
func (m *Sector) XXX_DiscardUnknown() {
	xxx_messageInfo_Sector.DiscardUnknown(m)
}

var xxx_messageInfo_Sector proto.InternalMessageInfo

func (m *Sector) GetDim() geometry.Vec3 {
	if m != nil {
		return m.Dim
	}
	return geometry.Vec3{}
}

func (m *Sector) GetAdjacents() map[string]geometry.Vec3 {
	if m != nil {
		return m.Adjacents
	}
	return nil
}

func (m *Sector) GetTileMap() TileMap {
	if m != nil {
		return m.TileMap
	}
	return TileMap{}
}

func init() {
	proto.RegisterType((*Sector)(nil), "space.Sector")
	proto.RegisterMapType((map[string]geometry.Vec3)(nil), "space.Sector.AdjacentsEntry")
}

func init() {
	proto.RegisterFile("github.com/elojah/game_02/pkg/space/sector.proto", fileDescriptor_1d2ba01984712cee)
}

var fileDescriptor_1d2ba01984712cee = []byte{

	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0xcf, 0x2c, 0xc9,
	0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcd, 0xc9, 0xcf, 0x4a, 0xcc, 0xd0, 0x4f, 0x4f,
	0xcc, 0x4d, 0x8d, 0x37, 0x30, 0xd2, 0x2f, 0xc8, 0x4e, 0xd7, 0x2f, 0x2e, 0x48, 0x4c, 0x4e, 0xd5,
	0x2f, 0x4e, 0x4d, 0x2e, 0xc9, 0x2f, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x8b,
	0x49, 0xe9, 0x22, 0x69, 0x4c, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0xcb, 0x26, 0x95, 0xa6, 0x81, 0x79,
	0x60, 0x0e, 0x98, 0x05, 0xd1, 0x25, 0x65, 0x8a, 0xdf, 0x9e, 0xf4, 0xd4, 0xfc, 0xdc, 0xd4, 0x92,
	0xa2, 0x4a, 0x38, 0x03, 0xaa, 0x4d, 0x8f, 0x18, 0xe7, 0x95, 0x64, 0xe6, 0xa4, 0x42, 0xd4, 0x2b,
	0xad, 0x67, 0xe2, 0x62, 0x0b, 0x06, 0xbb, 0x56, 0xc8, 0x96, 0x8b, 0xc9, 0xd3, 0x45, 0x82, 0x51,
	0x81, 0x51, 0x83, 0xc7, 0x49, 0xf7, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, 0xe4, 0x55, 0xf1, 0x1b,
	0x57, 0x9a, 0x93, 0x99, 0xa2, 0xe7, 0xe9, 0x12, 0xc4, 0xe4, 0xe9, 0x22, 0xa4, 0xc6, 0xc5, 0xec,
	0x92, 0x99, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0xc4, 0xa7, 0x07, 0x77, 0x57, 0x58, 0x6a,
	0xb2, 0xb1, 0x13, 0x0b, 0xc8, 0xbc, 0x20, 0x90, 0x02, 0x21, 0x07, 0x2e, 0x4e, 0xc7, 0x94, 0xac,
	0xc4, 0xe4, 0xd4, 0xbc, 0x92, 0x62, 0x09, 0x66, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x19, 0x3d, 0xb0,
	0xbb, 0xf4, 0x20, 0x0e, 0xd1, 0x83, 0x4b, 0xbb, 0xe6, 0x95, 0x14, 0x55, 0x42, 0xf5, 0x22, 0x34,
	0x09, 0xe9, 0x71, 0xb1, 0x87, 0x64, 0xe6, 0xa4, 0xfa, 0x26, 0x16, 0x48, 0xb0, 0x40, 0x6d, 0x83,
	0xe8, 0x87, 0x8a, 0x42, 0x75, 0xc0, 0x14, 0x49, 0xf9, 0x70, 0xf1, 0xa1, 0x1a, 0x29, 0x24, 0xc0,
	0xc5, 0x9c, 0x9d, 0x5a, 0x09, 0xf6, 0x2b, 0x67, 0x10, 0x88, 0x29, 0xa4, 0xc2, 0xc5, 0x5a, 0x96,
	0x98, 0x53, 0x9a, 0x8a, 0xdd, 0xfd, 0x41, 0x10, 0x49, 0x2b, 0x26, 0x0b, 0x46, 0x27, 0x87, 0x0b,
	0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94, 0x63, 0xf8, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6,
	0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0xee, 0x78, 0x24, 0xc7, 0x78, 0xe0, 0x91, 0x1c,
	0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0xf8, 0xe2, 0x91,
	0x1c, 0xc3, 0x87, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3,
	0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0xe8, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x8f,
	0xf4, 0x21, 0x4b, 0x02, 0x00, 0x00,
}

func (this *Sector) Equal(that interface{}) bool {
	if that == nil {
		return this == nil
	}

	that1, ok := that.(*Sector)
	if !ok {
		that2, ok := that.(Sector)
		if ok {
			that1 = &that2
		} else {
			return false
		}
	}
	if that1 == nil {
		return this == nil
	} else if this == nil {
		return false
	}
	if !this.ID.Equal(that1.ID) {
		return false
	}
	if !this.Dim.Equal(&that1.Dim) {
		return false
	}
	if len(this.Adjacents) != len(that1.Adjacents) {
		return false
	}
	for i := range this.Adjacents {
		a := this.Adjacents[i]
		b := that1.Adjacents[i]
		if !(&a).Equal(&b) {
			return false
		}
	}
	if !this.TileMap.Equal(&that1.TileMap) {
		return false
	}
	return true
}
func (this *Sector) GoString() string {
	if this == nil {
		return "nil"
	}
	s := make([]string, 0, 8)
	s = append(s, "&space.Sector{")
	s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n")
	s = append(s, "Dim: "+strings.Replace(this.Dim.GoString(), `&`, ``, 1)+",\n")
	keysForAdjacents := make([]string, 0, len(this.Adjacents))
	for k, _ := range this.Adjacents {
		keysForAdjacents = append(keysForAdjacents, k)
	}
	github_com_gogo_protobuf_sortkeys.Strings(keysForAdjacents)
	mapStringForAdjacents := "map[string]geometry.Vec3{"
	for _, k := range keysForAdjacents {
		mapStringForAdjacents += fmt.Sprintf("%#v: %#v,", k, this.Adjacents[k])
	}
	mapStringForAdjacents += "}"
	if this.Adjacents != nil {
		s = append(s, "Adjacents: "+mapStringForAdjacents+",\n")
	}
	s = append(s, "TileMap: "+strings.Replace(this.TileMap.GoString(), `&`, ``, 1)+",\n")
	s = append(s, "}")
	return strings.Join(s, "")
}
func valueToGoStringSector(v interface{}, typ string) string {
	rv := reflect.ValueOf(v)
	if rv.IsNil() {
		return "nil"
	}
	pv := reflect.Indirect(rv).Interface()
	return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func (m *Sector) Marshal() (dAtA []byte, err error) {
	size := m.Size()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBuffer(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *Sector) MarshalTo(dAtA []byte) (int, error) {
	size := m.Size()
	return m.MarshalToSizedBuffer(dAtA[:size])
}

func (m *Sector) MarshalToSizedBuffer(dAtA []byte) (int, error) {
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	{
		size, err := m.TileMap.MarshalToSizedBuffer(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0x22
	if len(m.Adjacents) > 0 {
		for k := range m.Adjacents {
			v := m.Adjacents[k]
			baseI := i
			{
				size, err := (&v).MarshalToSizedBuffer(dAtA[:i])
				if err != nil {
					return 0, err
				}
				i -= size
				i = encodeVarintSector(dAtA, i, uint64(size))
			}
			i--
			dAtA[i] = 0x12
			i -= len(k)
			copy(dAtA[i:], k)
			i = encodeVarintSector(dAtA, i, uint64(len(k)))
			i--
			dAtA[i] = 0xa
			i = encodeVarintSector(dAtA, i, uint64(baseI-i))
			i--
			dAtA[i] = 0x1a
		}
	}
	{
		size, err := m.Dim.MarshalToSizedBuffer(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0x12
	{
		size := m.ID.Size()
		i -= size
		if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil {
			return 0, err
		}
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0xa
	return len(dAtA) - i, nil
}

func encodeVarintSector(dAtA []byte, offset int, v uint64) int {
	offset -= sovSector(v)
	base := offset
	for v >= 1<<7 {
		dAtA[offset] = uint8(v&0x7f | 0x80)
		v >>= 7
		offset++
	}
	dAtA[offset] = uint8(v)
	return base
}
func NewPopulatedSector(r randySector, easy bool) *Sector {
	this := &Sector{}
	v1 := github_com_elojah_game_02_pkg_ulid.NewPopulatedID(r)
	this.ID = *v1
	v2 := geometry.NewPopulatedVec3(r, easy)
	this.Dim = *v2
	if r.Intn(5) != 0 {
		v3 := r.Intn(10)
		this.Adjacents = make(map[string]geometry.Vec3)
		for i := 0; i < v3; i++ {
			this.Adjacents[randStringSector(r)] = *geometry.NewPopulatedVec3(r, easy)
		}
	}
	v4 := NewPopulatedTileMap(r, easy)
	this.TileMap = *v4
	if !easy && r.Intn(10) != 0 {
	}
	return this
}

type randySector interface {
	Float32() float32
	Float64() float64
	Int63() int64
	Int31() int32
	Uint32() uint32
	Intn(n int) int
}

func randUTF8RuneSector(r randySector) rune {
	ru := r.Intn(62)
	if ru < 10 {
		return rune(ru + 48)
	} else if ru < 36 {
		return rune(ru + 55)
	}
	return rune(ru + 61)
}
func randStringSector(r randySector) string {
	v5 := r.Intn(100)
	tmps := make([]rune, v5)
	for i := 0; i < v5; i++ {
		tmps[i] = randUTF8RuneSector(r)
	}
	return string(tmps)
}
func randUnrecognizedSector(r randySector, maxFieldNumber int) (dAtA []byte) {
	l := r.Intn(5)
	for i := 0; i < l; i++ {
		wire := r.Intn(4)
		if wire == 3 {
			wire = 5
		}
		fieldNumber := maxFieldNumber + r.Intn(100)
		dAtA = randFieldSector(dAtA, r, fieldNumber, wire)
	}
	return dAtA
}
func randFieldSector(dAtA []byte, r randySector, fieldNumber int, wire int) []byte {
	key := uint32(fieldNumber)<<3 | uint32(wire)
	switch wire {
	case 0:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		v6 := r.Int63()
		if r.Intn(2) == 0 {
			v6 *= -1
		}
		dAtA = encodeVarintPopulateSector(dAtA, uint64(v6))
	case 1:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	case 2:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		ll := r.Intn(100)
		dAtA = encodeVarintPopulateSector(dAtA, uint64(ll))
		for j := 0; j < ll; j++ {
			dAtA = append(dAtA, byte(r.Intn(256)))
		}
	default:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	}
	return dAtA
}
func encodeVarintPopulateSector(dAtA []byte, v uint64) []byte {
	for v >= 1<<7 {
		dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
		v >>= 7
	}
	dAtA = append(dAtA, uint8(v))
	return dAtA
}
func (m *Sector) Size() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = m.ID.Size()
	n += 1 + l + sovSector(uint64(l))
	l = m.Dim.Size()
	n += 1 + l + sovSector(uint64(l))
	if len(m.Adjacents) > 0 {
		for k, v := range m.Adjacents {
			_ = k
			_ = v
			l = v.Size()
			mapEntrySize := 1 + len(k) + sovSector(uint64(len(k))) + 1 + l + sovSector(uint64(l))
			n += mapEntrySize + 1 + sovSector(uint64(mapEntrySize))
		}
	}
	l = m.TileMap.Size()
	n += 1 + l + sovSector(uint64(l))
	return n
}

func sovSector(x uint64) (n int) {
	return (math_bits.Len64(x|1) + 6) / 7
}
func sozSector(x uint64) (n int) {
	return sovSector(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Sector) String() string {
	if this == nil {
		return "nil"
	}
	keysForAdjacents := make([]string, 0, len(this.Adjacents))
	for k, _ := range this.Adjacents {
		keysForAdjacents = append(keysForAdjacents, k)
	}
	github_com_gogo_protobuf_sortkeys.Strings(keysForAdjacents)
	mapStringForAdjacents := "map[string]geometry.Vec3{"
	for _, k := range keysForAdjacents {
		mapStringForAdjacents += fmt.Sprintf("%v: %v,", k, this.Adjacents[k])
	}
	mapStringForAdjacents += "}"
	s := strings.Join([]string{`&Sector{`,
		`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
		`Dim:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Dim), "Vec3", "geometry.Vec3", 1), `&`, ``, 1) + `,`,
		`Adjacents:` + mapStringForAdjacents + `,`,
		`TileMap:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.TileMap), "TileMap", "TileMap", 1), `&`, ``, 1) + `,`,
		`}`,
	}, "")
	return s
}
func valueToStringSector(v interface{}) string {
	rv := reflect.ValueOf(v)
	if rv.IsNil() {
		return "nil"
	}
	pv := reflect.Indirect(rv).Interface()
	return fmt.Sprintf("*%v", pv)
}
func (m *Sector) Unmarshal(dAtA []byte) error {
	l := len(dAtA)
	iNdEx := 0
	for iNdEx < l {
		preIndex := iNdEx
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return ErrIntOverflowSector
			}
			if iNdEx >= l {
				return io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= uint64(b&0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		fieldNum := int32(wire >> 3)
		wireType := int(wire & 0x7)
		if wireType == 4 {
			return fmt.Errorf("proto: Sector: wiretype end group for non-group")
		}
		if fieldNum <= 0 {
			return fmt.Errorf("proto: Sector: illegal tag %d (wire type %d)", fieldNum, wire)
		}
		switch fieldNum {
		case 1:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
			}
			var byteLen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				byteLen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if byteLen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + byteLen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		case 2:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Dim", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.Dim.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		case 3:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Adjacents", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if m.Adjacents == nil {
				m.Adjacents = make(map[string]geometry.Vec3)
			}
			var mapkey string
			mapvalue := &geometry.Vec3{}
			for iNdEx < postIndex {
				entryPreIndex := iNdEx
				var wire uint64
				for shift := uint(0); ; shift += 7 {
					if shift >= 64 {
						return ErrIntOverflowSector
					}
					if iNdEx >= l {
						return io.ErrUnexpectedEOF
					}
					b := dAtA[iNdEx]
					iNdEx++
					wire |= uint64(b&0x7F) << shift
					if b < 0x80 {
						break
					}
				}
				fieldNum := int32(wire >> 3)
				if fieldNum == 1 {
					var stringLenmapkey uint64
					for shift := uint(0); ; shift += 7 {
						if shift >= 64 {
							return ErrIntOverflowSector
						}
						if iNdEx >= l {
							return io.ErrUnexpectedEOF
						}
						b := dAtA[iNdEx]
						iNdEx++
						stringLenmapkey |= uint64(b&0x7F) << shift
						if b < 0x80 {
							break
						}
					}
					intStringLenmapkey := int(stringLenmapkey)
					if intStringLenmapkey < 0 {
						return ErrInvalidLengthSector
					}
					postStringIndexmapkey := iNdEx + intStringLenmapkey
					if postStringIndexmapkey < 0 {
						return ErrInvalidLengthSector
					}
					if postStringIndexmapkey > l {
						return io.ErrUnexpectedEOF
					}
					mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
					iNdEx = postStringIndexmapkey
				} else if fieldNum == 2 {
					var mapmsglen int
					for shift := uint(0); ; shift += 7 {
						if shift >= 64 {
							return ErrIntOverflowSector
						}
						if iNdEx >= l {
							return io.ErrUnexpectedEOF
						}
						b := dAtA[iNdEx]
						iNdEx++
						mapmsglen |= int(b&0x7F) << shift
						if b < 0x80 {
							break
						}
					}
					if mapmsglen < 0 {
						return ErrInvalidLengthSector
					}
					postmsgIndex := iNdEx + mapmsglen
					if postmsgIndex < 0 {
						return ErrInvalidLengthSector
					}
					if postmsgIndex > l {
						return io.ErrUnexpectedEOF
					}
					mapvalue = &geometry.Vec3{}
					if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
						return err
					}
					iNdEx = postmsgIndex
				} else {
					iNdEx = entryPreIndex
					skippy, err := skipSector(dAtA[iNdEx:])
					if err != nil {
						return err
					}
					if skippy < 0 {
						return ErrInvalidLengthSector
					}
					if (iNdEx + skippy) > postIndex {
						return io.ErrUnexpectedEOF
					}
					iNdEx += skippy
				}
			}
			m.Adjacents[mapkey] = *mapvalue
			iNdEx = postIndex
		case 4:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field TileMap", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.TileMap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		default:
			iNdEx = preIndex
			skippy, err := skipSector(dAtA[iNdEx:])
			if err != nil {
				return err
			}
			if skippy < 0 {
				return ErrInvalidLengthSector
			}
			if (iNdEx + skippy) < 0 {
				return ErrInvalidLengthSector
			}
			if (iNdEx + skippy) > l {
				return io.ErrUnexpectedEOF
			}
			iNdEx += skippy
		}
	}

	if iNdEx > l {
		return io.ErrUnexpectedEOF
	}
	return nil
}
func skipSector(dAtA []byte) (n int, err error) {
	l := len(dAtA)
	iNdEx := 0
	depth := 0
	for iNdEx < l {
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return 0, ErrIntOverflowSector
			}
			if iNdEx >= l {
				return 0, io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= (uint64(b) & 0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		wireType := int(wire & 0x7)
		switch wireType {
		case 0:
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowSector
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				iNdEx++
				if dAtA[iNdEx-1] < 0x80 {
					break
				}
			}
		case 1:
			iNdEx += 8
		case 2:
			var length int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowSector
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				length |= (int(b) & 0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if length < 0 {
				return 0, ErrInvalidLengthSector
			}
			iNdEx += length
		case 3:
			depth++
		case 4:
			if depth == 0 {
				return 0, ErrUnexpectedEndOfGroupSector
			}
			depth--
		case 5:
			iNdEx += 4
		default:
			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
		}
		if iNdEx < 0 {
			return 0, ErrInvalidLengthSector
		}
		if depth == 0 {
			return iNdEx, nil
		}
	}
	return 0, io.ErrUnexpectedEOF
}

var (
	ErrInvalidLengthSector        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSector          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupSector = fmt.Errorf("proto: unexpected end of group")
)
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/elojah/game_02/pkg/space/sector.proto

package space

import (
	fmt "fmt"
	geometry "github.com/elojah/game_02/pkg/geometry"
	github_com_elojah_game_02_pkg_ulid "github.com/elojah/game_02/pkg/ulid"
	_ "github.com/gogo/protobuf/gogoproto"
	proto "github.com/gogo/protobuf/proto"
	github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys"
	io "io"
	math "math"
	math_bits "math/bits"
	reflect "reflect"
	strings "strings"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package

type Sector struct {
	ID        github_com_elojah_game_02_pkg_ulid.ID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=github.com/elojah/game_02/pkg/ulid.ID" json:"ID"`
	Dim       geometry.Vec3                         `protobuf:"bytes,2,opt,name=Dim,proto3" json:"Dim"`
	Adjacents map[string]geometry.Vec3              `protobuf:"bytes,3,rep,name=Adjacents,proto3" json:"Adjacents" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
	TileMap   TileMap                               `protobuf:"bytes,4,opt,name=TileMap,proto3" json:"TileMap"`
}

func (m *Sector) Reset()      { *m = Sector{} }
func (*Sector) ProtoMessage() {}
func (*Sector) Descriptor() ([]byte, []int) {
	return fileDescriptor_1d2ba01984712cee, []int{0}
}
func (m *Sector) XXX_Unmarshal(b []byte) error {
	return m.Unmarshal(b)
}
func (m *Sector) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	if deterministic {
		return xxx_messageInfo_Sector.Marshal(b, m, deterministic)
	} else {
		b = b[:cap(b)]
		n, err := m.MarshalToSizedBuffer(b)
		if err != nil {
			return nil, err
		}
		return b[:n], nil
	}
}
func (m *Sector) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Sector.Merge(m, src)
}
func (m *Sector) XXX_Size() int {
	return m.Size()
}
func (m *Sector) XXX_DiscardUnknown() {
	xxx_messageInfo_Sector.DiscardUnknown(m)
}

var xxx_messageInfo_Sector proto.InternalMessageInfo

func (m *Sector) GetDim() geometry.Vec3 {
	if m != nil {
		return m.Dim
	}
	return geometry.Vec3{}
}

func (m *Sector) GetAdjacents() map[string]geometry.Vec3 {
	if m != nil {
		return m.Adjacents
	}
	return nil
}

func (m *Sector) GetTileMap() TileMap {
	if m != nil {
		return m.TileMap
	}
	return TileMap{}
}

func init() {
	proto.RegisterType((*Sector)(nil), "space.Sector")
	proto.RegisterMapType((map[string]geometry.Vec3)(nil), "space.Sector.AdjacentsEntry")
}

func init() {
	proto.RegisterFile("github.com/elojah/game_02/pkg/space/sector.proto", fileDescriptor_1d2ba01984712cee)
}

var fileDescriptor_1d2ba01984712cee = []byte{
	// 374 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0xcf, 0x2c, 0xc9,
	0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcd, 0xc9, 0xcf, 0x4a, 0xcc, 0xd0, 0x4f, 0x4f,
	0xcc, 0x4d, 0x8d, 0x37, 0x30, 0xd2, 0x2f, 0xc8, 0x4e, 0xd7, 0x2f, 0x2e, 0x48, 0x4c, 0x4e, 0xd5,
	0x2f, 0x4e, 0x4d, 0x2e, 0xc9, 0x2f, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x8b,
	0x49, 0xe9, 0x22, 0x69, 0x4c, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0xcb, 0x26, 0x95, 0xa6, 0x81, 0x79,
	0x60, 0x0e, 0x98, 0x05, 0xd1, 0x25, 0x65, 0x8a, 0xdf, 0x9e, 0xf4, 0xd4, 0xfc, 0xdc, 0xd4, 0x92,
	0xa2, 0x4a, 0x38, 0x03, 0xaa, 0x4d, 0x8f, 0x18, 0xe7, 0x95, 0x64, 0xe6, 0xa4, 0x42, 0xd4, 0x2b,
	0xad, 0x67, 0xe2, 0x62, 0x0b, 0x06, 0xbb, 0x56, 0xc8, 0x96, 0x8b, 0xc9, 0xd3, 0x45, 0x82, 0x51,
	0x81, 0x51, 0x83, 0xc7, 0x49, 0xf7, 0xc4, 0x3d, 0x79, 0x86, 0x5b, 0xf7, 0xe4, 0x55, 0xf1, 0x1b,
	0x57, 0x9a, 0x93, 0x99, 0xa2, 0xe7, 0xe9, 0x12, 0xc4, 0xe4, 0xe9, 0x22, 0xa4, 0xc6, 0xc5, 0xec,
	0x92, 0x99, 0x2b, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, 0xc4, 0xa7, 0x07, 0x77, 0x57, 0x58, 0x6a,
	0xb2, 0xb1, 0x13, 0x0b, 0xc8, 0xbc, 0x20, 0x90, 0x02, 0x21, 0x07, 0x2e, 0x4e, 0xc7, 0x94, 0xac,
	0xc4, 0xe4, 0xd4, 0xbc, 0x92, 0x62, 0x09, 0x66, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x19, 0x3d, 0xb0,
	0xbb, 0xf4, 0x20, 0x0e, 0xd1, 0x83, 0x4b, 0xbb, 0xe6, 0x95, 0x14, 0x55, 0x42, 0xf5, 0x22, 0x34,
	0x09, 0xe9, 0x71, 0xb1, 0x87, 0x64, 0xe6, 0xa4, 0xfa, 0x26, 0x16, 0x48, 0xb0, 0x40, 0x6d, 0x83,
	0xe8, 0x87, 0x8a, 0x42, 0x75, 0xc0, 0x14, 0x49, 0xf9, 0x70, 0xf1, 0xa1, 0x1a, 0x29, 0x24, 0xc0,
	0xc5, 0x9c, 0x9d, 0x5a, 0x09, 0xf6, 0x2b, 0x67, 0x10, 0x88, 0x29, 0xa4, 0xc2, 0xc5, 0x5a, 0x96,
	0x98, 0x53, 0x9a, 0x8a, 0xdd, 0xfd, 0x41, 0x10, 0x49, 0x2b, 0x26, 0x0b, 0x46, 0x27, 0x87, 0x0b,
	0x0f, 0xe5, 0x18, 0x6e, 0x3c, 0x94, 0x63, 0xf8, 0xf0, 0x50, 0x8e, 0xf1, 0xc7, 0x43, 0x39, 0xc6,
	0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0xee, 0x78, 0x24, 0xc7, 0x78, 0xe0, 0x91, 0x1c,
	0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0xf8, 0xe2, 0x91,
	0x1c, 0xc3, 0x87, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3,
	0xb1, 0x1c, 0x43, 0x12, 0x1b, 0x38, 0xe8, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x8f,
	0xf4, 0x21, 0x4b, 0x02, 0x00, 0x00,
}

func (this *Sector) Equal(that interface{}) bool {
	if that == nil {
		return this == nil
	}

	that1, ok := that.(*Sector)
	if !ok {
		that2, ok := that.(Sector)
		if ok {
			that1 = &that2
		} else {
			return false
		}
	}
	if that1 == nil {
		return this == nil
	} else if this == nil {
		return false
	}
	if !this.ID.Equal(that1.ID) {
		return false
	}
	if !this.Dim.Equal(&that1.Dim) {
		return false
	}
	if len(this.Adjacents) != len(that1.Adjacents) {
		return false
	}
	for i := range this.Adjacents {
		a := this.Adjacents[i]
		b := that1.Adjacents[i]
		if !(&a).Equal(&b) {
			return false
		}
	}
	if !this.TileMap.Equal(&that1.TileMap) {
		return false
	}
	return true
}
func (this *Sector) GoString() string {
	if this == nil {
		return "nil"
	}
	s := make([]string, 0, 8)
	s = append(s, "&space.Sector{")
	s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n")
	s = append(s, "Dim: "+strings.Replace(this.Dim.GoString(), `&`, ``, 1)+",\n")
	keysForAdjacents := make([]string, 0, len(this.Adjacents))
	for k, _ := range this.Adjacents {
		keysForAdjacents = append(keysForAdjacents, k)
	}
	github_com_gogo_protobuf_sortkeys.Strings(keysForAdjacents)
	mapStringForAdjacents := "map[string]geometry.Vec3{"
	for _, k := range keysForAdjacents {
		mapStringForAdjacents += fmt.Sprintf("%#v: %#v,", k, this.Adjacents[k])
	}
	mapStringForAdjacents += "}"
	if this.Adjacents != nil {
		s = append(s, "Adjacents: "+mapStringForAdjacents+",\n")
	}
	s = append(s, "TileMap: "+strings.Replace(this.TileMap.GoString(), `&`, ``, 1)+",\n")
	s = append(s, "}")
	return strings.Join(s, "")
}
func valueToGoStringSector(v interface{}, typ string) string {
	rv := reflect.ValueOf(v)
	if rv.IsNil() {
		return "nil"
	}
	pv := reflect.Indirect(rv).Interface()
	return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
}
func (m *Sector) Marshal() (dAtA []byte, err error) {
	size := m.Size()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBuffer(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *Sector) MarshalTo(dAtA []byte) (int, error) {
	size := m.Size()
	return m.MarshalToSizedBuffer(dAtA[:size])
}

func (m *Sector) MarshalToSizedBuffer(dAtA []byte) (int, error) {
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	{
		size, err := m.TileMap.MarshalToSizedBuffer(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0x22
	if len(m.Adjacents) > 0 {
		for k := range m.Adjacents {
			v := m.Adjacents[k]
			baseI := i
			{
				size, err := (&v).MarshalToSizedBuffer(dAtA[:i])
				if err != nil {
					return 0, err
				}
				i -= size
				i = encodeVarintSector(dAtA, i, uint64(size))
			}
			i--
			dAtA[i] = 0x12
			i -= len(k)
			copy(dAtA[i:], k)
			i = encodeVarintSector(dAtA, i, uint64(len(k)))
			i--
			dAtA[i] = 0xa
			i = encodeVarintSector(dAtA, i, uint64(baseI-i))
			i--
			dAtA[i] = 0x1a
		}
	}
	{
		size, err := m.Dim.MarshalToSizedBuffer(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0x12
	{
		size := m.ID.Size()
		i -= size
		if _, err := m.ID.MarshalTo(dAtA[i:]); err != nil {
			return 0, err
		}
		i = encodeVarintSector(dAtA, i, uint64(size))
	}
	i--
	dAtA[i] = 0xa
	return len(dAtA) - i, nil
}

func encodeVarintSector(dAtA []byte, offset int, v uint64) int {
	offset -= sovSector(v)
	base := offset
	for v >= 1<<7 {
		dAtA[offset] = uint8(v&0x7f | 0x80)
		v >>= 7
		offset++
	}
	dAtA[offset] = uint8(v)
	return base
}
func NewPopulatedSector(r randySector, easy bool) *Sector {
	this := &Sector{}
	v1 := github_com_elojah_game_02_pkg_ulid.NewPopulatedID(r)
	this.ID = *v1
	v2 := geometry.NewPopulatedVec3(r, easy)
	this.Dim = *v2
	if r.Intn(5) != 0 {
		v3 := r.Intn(10)
		this.Adjacents = make(map[string]geometry.Vec3)
		for i := 0; i < v3; i++ {
			this.Adjacents[randStringSector(r)] = *geometry.NewPopulatedVec3(r, easy)
		}
	}
	v4 := NewPopulatedTileMap(r, easy)
	this.TileMap = *v4
	if !easy && r.Intn(10) != 0 {
	}
	return this
}

type randySector interface {
	Float32() float32
	Float64() float64
	Int63() int64
	Int31() int32
	Uint32() uint32
	Intn(n int) int
}

func randUTF8RuneSector(r randySector) rune {
	ru := r.Intn(62)
	if ru < 10 {
		return rune(ru + 48)
	} else if ru < 36 {
		return rune(ru + 55)
	}
	return rune(ru + 61)
}
func randStringSector(r randySector) string {
	v5 := r.Intn(100)
	tmps := make([]rune, v5)
	for i := 0; i < v5; i++ {
		tmps[i] = randUTF8RuneSector(r)
	}
	return string(tmps)
}
func randUnrecognizedSector(r randySector, maxFieldNumber int) (dAtA []byte) {
	l := r.Intn(5)
	for i := 0; i < l; i++ {
		wire := r.Intn(4)
		if wire == 3 {
			wire = 5
		}
		fieldNumber := maxFieldNumber + r.Intn(100)
		dAtA = randFieldSector(dAtA, r, fieldNumber, wire)
	}
	return dAtA
}
func randFieldSector(dAtA []byte, r randySector, fieldNumber int, wire int) []byte {
	key := uint32(fieldNumber)<<3 | uint32(wire)
	switch wire {
	case 0:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		v6 := r.Int63()
		if r.Intn(2) == 0 {
			v6 *= -1
		}
		dAtA = encodeVarintPopulateSector(dAtA, uint64(v6))
	case 1:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	case 2:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		ll := r.Intn(100)
		dAtA = encodeVarintPopulateSector(dAtA, uint64(ll))
		for j := 0; j < ll; j++ {
			dAtA = append(dAtA, byte(r.Intn(256)))
		}
	default:
		dAtA = encodeVarintPopulateSector(dAtA, uint64(key))
		dAtA = append(dAtA, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)))
	}
	return dAtA
}
func encodeVarintPopulateSector(dAtA []byte, v uint64) []byte {
	for v >= 1<<7 {
		dAtA = append(dAtA, uint8(uint64(v)&0x7f|0x80))
		v >>= 7
	}
	dAtA = append(dAtA, uint8(v))
	return dAtA
}
func (m *Sector) Size() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = m.ID.Size()
	n += 1 + l + sovSector(uint64(l))
	l = m.Dim.Size()
	n += 1 + l + sovSector(uint64(l))
	if len(m.Adjacents) > 0 {
		for k, v := range m.Adjacents {
			_ = k
			_ = v
			l = v.Size()
			mapEntrySize := 1 + len(k) + sovSector(uint64(len(k))) + 1 + l + sovSector(uint64(l))
			n += mapEntrySize + 1 + sovSector(uint64(mapEntrySize))
		}
	}
	l = m.TileMap.Size()
	n += 1 + l + sovSector(uint64(l))
	return n
}

func sovSector(x uint64) (n int) {
	return (math_bits.Len64(x|1) + 6) / 7
}
func sozSector(x uint64) (n int) {
	return sovSector(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *Sector) String() string {
	if this == nil {
		return "nil"
	}
	keysForAdjacents := make([]string, 0, len(this.Adjacents))
	for k, _ := range this.Adjacents {
		keysForAdjacents = append(keysForAdjacents, k)
	}
	github_com_gogo_protobuf_sortkeys.Strings(keysForAdjacents)
	mapStringForAdjacents := "map[string]geometry.Vec3{"
	for _, k := range keysForAdjacents {
		mapStringForAdjacents += fmt.Sprintf("%v: %v,", k, this.Adjacents[k])
	}
	mapStringForAdjacents += "}"
	s := strings.Join([]string{`&Sector{`,
		`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
		`Dim:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Dim), "Vec3", "geometry.Vec3", 1), `&`, ``, 1) + `,`,
		`Adjacents:` + mapStringForAdjacents + `,`,
		`TileMap:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.TileMap), "TileMap", "TileMap", 1), `&`, ``, 1) + `,`,
		`}`,
	}, "")
	return s
}
func valueToStringSector(v interface{}) string {
	rv := reflect.ValueOf(v)
	if rv.IsNil() {
		return "nil"
	}
	pv := reflect.Indirect(rv).Interface()
	return fmt.Sprintf("*%v", pv)
}
func (m *Sector) Unmarshal(dAtA []byte) error {
	l := len(dAtA)
	iNdEx := 0
	for iNdEx < l {
		preIndex := iNdEx
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return ErrIntOverflowSector
			}
			if iNdEx >= l {
				return io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= uint64(b&0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		fieldNum := int32(wire >> 3)
		wireType := int(wire & 0x7)
		if wireType == 4 {
			return fmt.Errorf("proto: Sector: wiretype end group for non-group")
		}
		if fieldNum <= 0 {
			return fmt.Errorf("proto: Sector: illegal tag %d (wire type %d)", fieldNum, wire)
		}
		switch fieldNum {
		case 1:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
			}
			var byteLen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				byteLen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if byteLen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + byteLen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.ID.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		case 2:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Dim", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.Dim.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		case 3:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field Adjacents", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if m.Adjacents == nil {
				m.Adjacents = make(map[string]geometry.Vec3)
			}
			var mapkey string
			mapvalue := &geometry.Vec3{}
			for iNdEx < postIndex {
				entryPreIndex := iNdEx
				var wire uint64
				for shift := uint(0); ; shift += 7 {
					if shift >= 64 {
						return ErrIntOverflowSector
					}
					if iNdEx >= l {
						return io.ErrUnexpectedEOF
					}
					b := dAtA[iNdEx]
					iNdEx++
					wire |= uint64(b&0x7F) << shift
					if b < 0x80 {
						break
					}
				}
				fieldNum := int32(wire >> 3)
				if fieldNum == 1 {
					var stringLenmapkey uint64
					for shift := uint(0); ; shift += 7 {
						if shift >= 64 {
							return ErrIntOverflowSector
						}
						if iNdEx >= l {
							return io.ErrUnexpectedEOF
						}
						b := dAtA[iNdEx]
						iNdEx++
						stringLenmapkey |= uint64(b&0x7F) << shift
						if b < 0x80 {
							break
						}
					}
					intStringLenmapkey := int(stringLenmapkey)
					if intStringLenmapkey < 0 {
						return ErrInvalidLengthSector
					}
					postStringIndexmapkey := iNdEx + intStringLenmapkey
					if postStringIndexmapkey < 0 {
						return ErrInvalidLengthSector
					}
					if postStringIndexmapkey > l {
						return io.ErrUnexpectedEOF
					}
					mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
					iNdEx = postStringIndexmapkey
				} else if fieldNum == 2 {
					var mapmsglen int
					for shift := uint(0); ; shift += 7 {
						if shift >= 64 {
							return ErrIntOverflowSector
						}
						if iNdEx >= l {
							return io.ErrUnexpectedEOF
						}
						b := dAtA[iNdEx]
						iNdEx++
						mapmsglen |= int(b&0x7F) << shift
						if b < 0x80 {
							break
						}
					}
					if mapmsglen < 0 {
						return ErrInvalidLengthSector
					}
					postmsgIndex := iNdEx + mapmsglen
					if postmsgIndex < 0 {
						return ErrInvalidLengthSector
					}
					if postmsgIndex > l {
						return io.ErrUnexpectedEOF
					}
					mapvalue = &geometry.Vec3{}
					if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil {
						return err
					}
					iNdEx = postmsgIndex
				} else {
					iNdEx = entryPreIndex
					skippy, err := skipSector(dAtA[iNdEx:])
					if err != nil {
						return err
					}
					if skippy < 0 {
						return ErrInvalidLengthSector
					}
					if (iNdEx + skippy) > postIndex {
						return io.ErrUnexpectedEOF
					}
					iNdEx += skippy
				}
			}
			m.Adjacents[mapkey] = *mapvalue
			iNdEx = postIndex
		case 4:
			if wireType != 2 {
				return fmt.Errorf("proto: wrong wireType = %d for field TileMap", wireType)
			}
			var msglen int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return ErrIntOverflowSector
				}
				if iNdEx >= l {
					return io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				msglen |= int(b&0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if msglen < 0 {
				return ErrInvalidLengthSector
			}
			postIndex := iNdEx + msglen
			if postIndex < 0 {
				return ErrInvalidLengthSector
			}
			if postIndex > l {
				return io.ErrUnexpectedEOF
			}
			if err := m.TileMap.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
				return err
			}
			iNdEx = postIndex
		default:
			iNdEx = preIndex
			skippy, err := skipSector(dAtA[iNdEx:])
			if err != nil {
				return err
			}
			if skippy < 0 {
				return ErrInvalidLengthSector
			}
			if (iNdEx + skippy) < 0 {
				return ErrInvalidLengthSector
			}
			if (iNdEx + skippy) > l {
				return io.ErrUnexpectedEOF
			}
			iNdEx += skippy
		}
	}

	if iNdEx > l {
		return io.ErrUnexpectedEOF
	}
	return nil
}
func skipSector(dAtA []byte) (n int, err error) {
	l := len(dAtA)
	iNdEx := 0
	depth := 0
	for iNdEx < l {
		var wire uint64
		for shift := uint(0); ; shift += 7 {
			if shift >= 64 {
				return 0, ErrIntOverflowSector
			}
			if iNdEx >= l {
				return 0, io.ErrUnexpectedEOF
			}
			b := dAtA[iNdEx]
			iNdEx++
			wire |= (uint64(b) & 0x7F) << shift
			if b < 0x80 {
				break
			}
		}
		wireType := int(wire & 0x7)
		switch wireType {
		case 0:
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowSector
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				iNdEx++
				if dAtA[iNdEx-1] < 0x80 {
					break
				}
			}
		case 1:
			iNdEx += 8
		case 2:
			var length int
			for shift := uint(0); ; shift += 7 {
				if shift >= 64 {
					return 0, ErrIntOverflowSector
				}
				if iNdEx >= l {
					return 0, io.ErrUnexpectedEOF
				}
				b := dAtA[iNdEx]
				iNdEx++
				length |= (int(b) & 0x7F) << shift
				if b < 0x80 {
					break
				}
			}
			if length < 0 {
				return 0, ErrInvalidLengthSector
			}
			iNdEx += length
		case 3:
			depth++
		case 4:
			if depth == 0 {
				return 0, ErrUnexpectedEndOfGroupSector
			}
			depth--
		case 5:
			iNdEx += 4
		default:
			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
		}
		if iNdEx < 0 {
			return 0, ErrInvalidLengthSector
		}
		if depth == 0 {
			return iNdEx, nil
		}
	}
	return 0, io.ErrUnexpectedEOF
}

var (
	ErrInvalidLengthSector        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSector          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupSector = fmt.Errorf("proto: unexpected end of group")
)
