| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package pb
- import cstring "github.com/cherry-game/cherry/extend/string"
- func (m *StrStrList) Add(key string, value any) {
- m.List = append(m.List, &StrStr{
- Key: key,
- Value: cstring.ToString(value),
- })
- }
- func (m *OrderDeliver) GetExtraI32(key string) (int32, bool) {
- value, found := m.Extra[key]
- if !found {
- return 0, false
- }
- return cstring.ToInt32(value, 0)
- }
- func (m *MapData) PointToTileID(x, y int32) (int32, bool) {
- if m.IsPointOutOfBound(x, y) {
- return 0, false
- }
- tileID := (y * m.MapInfo.Width) + x
- return tileID, true
- }
- func (m *MapData) TileIDToPoint(tileID int32) (int32, int32) {
- x := tileID % m.MapInfo.Width
- y := tileID / m.MapInfo.Width
- return x, y
- }
- func (m *MapData) IsTileBlock(tileID int32) bool {
- tile := m.Tiles[tileID]
- return tile == nil || tile.BlockType == MapWalkableTag_mwt_disable
- }
- func (m *MapData) IsPointBlock(x, y int32) bool {
- tileID, ok := m.PointToTileID(x, y)
- if !ok {
- return true
- }
- return m.IsTileBlock(tileID)
- }
- func (m *MapData) IsPointOutOfBound(x int32, y int32) bool {
- return x < 0 || x >= m.MapInfo.Width || y < 0 || y >= m.MapInfo.Height
- }
- // 获取坐标点所在的州省县
- func (m *MapData) GetTileLocateInfo(tileID int32) (state, province, county int32) {
- tile := m.Tiles[tileID]
- if tile == nil {
- return 0, 0, 0
- }
- // 最高位是州ID
- state = tile.CountyId / 1_000_000
- // 中间三位是省ID
- province = (tile.CountyId % 1_000_000) / 1_000
- // 最低三位是县ID
- county = tile.CountyId % 1_000
- return
- }
- func (p *TileData) IsBlock() bool {
- return p.BlockType == MapWalkableTag_mwt_disable
- }
|