feat(map): 实现地图加载和玩家进入地图功能
- 在 Player 结构中添加 MapId 字段,用于记录当前所在地图 ID - 新增地图配置解析功能,支持从 XML 文件中读取地图信息 - 实现玩家进入地图的逻辑,包括设置玩家位置和广播通知 - 更新登录逻辑,在玩家登录时自动进入默认地图 - 重构地图相关的数据结构和接口,为后续地图功能扩展做准备
This commit is contained in:
135
logic/service/maps/mapin.go
Normal file
135
logic/service/maps/mapin.go
Normal file
@@ -0,0 +1,135 @@
|
||||
package maps
|
||||
|
||||
import (
|
||||
"blazing/common/data/entity"
|
||||
"blazing/common/socket/handler"
|
||||
"blazing/logic/service/space"
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
type InInfo struct {
|
||||
Head handler.TomeeHeader `cmd:"2001" struc:"[0]pad"` //切换地图
|
||||
// 地图类型
|
||||
MapType uint32
|
||||
|
||||
MapId uint32
|
||||
// Point: 直接给坐标x,y
|
||||
Point model.Pos `fieldDesc:"直接给坐标x,y"`
|
||||
|
||||
// Reverse2: 暂定 占位字符2
|
||||
Reverse2 string `struc:"[2]byte"`
|
||||
}
|
||||
|
||||
func (t *InInfo) Broadcast(mapid uint32, o OutInfo) {
|
||||
|
||||
space.GetPlanet(mapid).Range(func(playerID uint32, player *entity.Player) bool {
|
||||
|
||||
player.SendPack(t.Head.Pack(o))
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
// 这里存储星球的map
|
||||
//var planetmap utils.SyncMap[] //= space.NewSyncMap()
|
||||
|
||||
// PeopleInfo 对应Java的PeopleInfo类,实现OutboundMessage接口
|
||||
type OutInfo struct {
|
||||
// 系统时间
|
||||
SystemTime uint32 `struc:"uint32" fieldDesc:"系统时间" json:"system_time"`
|
||||
|
||||
// 米米号
|
||||
UserID uint32 `struc:"uint32" fieldDesc:"米米号" json:"user_id"`
|
||||
|
||||
// 16字节昵称
|
||||
Nick string `struc:"[16]byte" fieldDesc:"16字节昵称" json:"nick"`
|
||||
|
||||
// 机器人人物颜色 00 rgb
|
||||
Color uint32 `struc:"uint32" fieldDesc:"机器人人物颜色 00 rgb" json:"color"`
|
||||
|
||||
// 固定值0
|
||||
Texture uint32 `struc:"uint32" fieldDesc:"固定值0" json:"texture"`
|
||||
|
||||
// 暂时不明建议先给固定值0
|
||||
Vip uint16 `struc:"uint16" fieldDesc:"暂时不明建议先给固定值0" json:"vip"`
|
||||
|
||||
// 暂时不明建议先给固定值15
|
||||
Viped uint16 `struc:"uint16" default:"15" fieldDesc:"暂时不明建议先给固定值15" json:"viped"`
|
||||
|
||||
// 暂时不明建议先给固定值1
|
||||
VipStage uint32 `struc:"uint32" fieldDesc:"暂时不明建议先给固定值1" json:"vip_stage"`
|
||||
|
||||
// 人物状态 =0 步行 !=0 飞行
|
||||
ActionType uint32 `struc:"uint32" fieldDesc:"人物状态 =0 步行 !=0 飞行" json:"action_type"`
|
||||
|
||||
// 上线的地图id
|
||||
Pos model.Pos `fieldDesc:"上线的地图id" json:"pos"`
|
||||
|
||||
// 暂时不明给0
|
||||
Action uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"action"`
|
||||
|
||||
// 暂时不明给2
|
||||
Direction uint32 `struc:"uint32" default:"2" fieldDesc:"暂时不明给2" json:"direction"`
|
||||
|
||||
// 暂时不明给0
|
||||
ChangeShape uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"change_shape"`
|
||||
|
||||
// 暂时不明给0
|
||||
SpiritTime uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"spirit_time"`
|
||||
|
||||
// 暂时不明给0
|
||||
SpiritID uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"spirit_id"`
|
||||
|
||||
// 跟随精灵的个体值
|
||||
PetDV uint32 `struc:"uint32" fieldDesc:"跟随精灵的个体值" json:"pet_dv"`
|
||||
|
||||
// 暂时不明给0
|
||||
FightFlag uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"fight_flag"`
|
||||
|
||||
// 教官ID
|
||||
TeacherID uint32 `struc:"uint32" fieldDesc:"教官ID" json:"teacher_id"`
|
||||
|
||||
// 学员ID
|
||||
StudentID uint32 `struc:"uint32" fieldDesc:"学员ID" json:"student_id"`
|
||||
|
||||
// nono状态 固定值-1
|
||||
NonoState uint32 `struc:"uint32" default:"0xFFFFFFFF" fieldDesc:"nono状态 固定值-1" json:"nono_state"`
|
||||
|
||||
// nono颜色 00 FF FF FF
|
||||
NonoColor uint32 `struc:"uint32" fieldDesc:"nono颜色 00 FF FF FF" json:"nono_color"`
|
||||
|
||||
// 是不是超能nono 固定值1
|
||||
SuperNono uint32 `struc:"uint32" default:"1" fieldDesc:"是不是超能nono 固定值1" json:"super_nono"`
|
||||
|
||||
// 暂时不明给0
|
||||
PlayerForm uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"player_form"`
|
||||
|
||||
// 暂时不明给0
|
||||
TransTime uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"trans_time"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamID uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_id"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamCoreCount uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_core_count"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamIsShow uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_is_show"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoBg int16 `struc:"int16" fieldDesc:"暂时不明给0" json:"logo_bg"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoIcon int16 `struc:"int16" fieldDesc:"暂时不明给0" json:"logo_icon"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoColor int16 `struc:"int16" fieldDesc:"暂时不明给0" json:"logo_color"`
|
||||
|
||||
// 暂时不明给0
|
||||
TxtColor int16 `struc:"int16" fieldDesc:"暂时不明给0" json:"txt_color"`
|
||||
|
||||
// 4字节
|
||||
LogoWord [4]byte `struc:"[4]byte" fieldDesc:"4字节" json:"logo_word"`
|
||||
|
||||
// 穿戴装备的信息
|
||||
Clothes []model.PeopleItemInfo `fieldDesc:"穿戴装备的信息" json:"clothes"`
|
||||
}
|
||||
Reference in New Issue
Block a user