feat(space): 添加地图模型配置支持并优化BOSS信息结构 添加MapModel字段到MapBossInfo结构体中,用于存储更完整的BOSS模型数据, 修改初始化逻辑从新的MapModel服务获取数据,并更新HP恢复逻辑使用新模型数据。 同时优化MapNode配置表结构,移除冗余字段并调整数据查询逻辑, 将IsBroadcast字段类型改为uint32以
This commit is contained in:
@@ -41,10 +41,11 @@ type MapBossInfo struct {
|
||||
Region uint32 `json:"region" protobuf:"2,req,name=region"` //index,直接给boss的节点ID
|
||||
Hp int32 `struc:"uint32" json:"hp" protobuf:"3,req,name=hp"` // HP值(蘑菇怪为A,其他BOSS暂未明确用途,可能无实际作用)
|
||||
Pos model.Pos
|
||||
IsShow int32 `struc:"uint32" json:"is_show"` // 雷伊首次出现的时候给2,正常精灵给1,雷伊是否首次出现的判断是否首次刷新,
|
||||
PosInfo []model.Pos `struc:"skip"`
|
||||
PosIndex uint32 `struc:"skip"`
|
||||
Config configm.MapNode `struc:"skip"`
|
||||
IsShow int32 `struc:"uint32" json:"is_show"` // 雷伊首次出现的时候给2,正常精灵给1,雷伊是否首次出现的判断是否首次刷新,
|
||||
PosInfo []model.Pos `struc:"skip"`
|
||||
PosIndex uint32 `struc:"skip"`
|
||||
Config configm.MapNode `struc:"skip"`
|
||||
Model configm.MapModel `struc:"skip"`
|
||||
}
|
||||
|
||||
// 这里存储星球的map
|
||||
|
||||
@@ -202,12 +202,17 @@ func (ret *Space) init() {
|
||||
}
|
||||
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
|
||||
|
||||
r := service.NewMapmodelService().GetDataByModelId(v.IsBroadcast)
|
||||
if r == nil {
|
||||
continue
|
||||
}
|
||||
info := info.MapBossInfo{
|
||||
Id: v.TriggerID,
|
||||
Id: uint32(r.ID),
|
||||
Region: v.NodeID, //这个是注册的index
|
||||
Hp: v.HP,
|
||||
PosInfo: ParseCoordinateString(v.Pos),
|
||||
Hp: r.HP,
|
||||
PosInfo: ParseCoordinateString(r.Pos),
|
||||
Config: v,
|
||||
Model: *r,
|
||||
}
|
||||
|
||||
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
|
||||
@@ -275,7 +280,7 @@ func (ret *Space) GenBoss(isfrist bool) *info.MapBossSInfo {
|
||||
func (ret *Space) HealHP() {
|
||||
|
||||
for _, v := range ret.MapBossSInfo.INFO {
|
||||
atomic.StoreInt32(&v.Hp, int32(v.Config.HP))
|
||||
atomic.StoreInt32(&v.Hp, int32(v.Model.HP))
|
||||
}
|
||||
}
|
||||
func (ret *Space) GenWer() {
|
||||
|
||||
22
modules/config/controller/admin/map_model.go
Normal file
22
modules/config/controller/admin/map_model.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
type MapModelController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
// 注册路由
|
||||
cool.RegisterController(&MapModelController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/config/mapmodel",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewMapmodelService(),
|
||||
},
|
||||
})
|
||||
}
|
||||
65
modules/config/model/map_model.go
Normal file
65
modules/config/model/map_model.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名统一改为 map_model
|
||||
const (
|
||||
TableNameMapModel = "map_model"
|
||||
)
|
||||
|
||||
// 模型类型常量 (1:NPC, 2:精灵)
|
||||
const (
|
||||
MapModelTypeNPC = 1
|
||||
MapModelTypePet = 2
|
||||
)
|
||||
|
||||
// MapModelBroadcastNode 地图模型广播节点配置
|
||||
type MapModelBroadcastNode struct {
|
||||
TriggerID uint32 `gorm:"comment:'触发器ID'" json:"trigger_id" description:"触发器ID"`
|
||||
Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos" description:"位置"`
|
||||
HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"`
|
||||
Direction int32 `gorm:"type:int;default:0;comment:'方向'" json:"direction" description:"方向"`
|
||||
}
|
||||
|
||||
// MapModel 地图模型配置表(NPC/宠物)
|
||||
type MapModel struct {
|
||||
*cool.Model // 保留通用Model(ID/创建时间/更新时间等)
|
||||
*MapModelBroadcastNode
|
||||
|
||||
MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
|
||||
|
||||
NodeID uint32 `gorm:"not null;default:0;comment:'节点ID'" json:"node_id" description:"节点ID"`
|
||||
|
||||
ModelID uint32 `gorm:"not null;default:0;comment:'模型ID(NPCID或精灵ID)'" json:"model_id" description:"模型ID"`
|
||||
|
||||
ModelType int32 `gorm:"type:int;default:1;comment:'模型类型(1:NPC,2:精灵)'" json:"model_type" description:"模型类型"`
|
||||
|
||||
ModelName string `gorm:"type:varchar(100);default:'';comment:'模型名称'" json:"model_name" description:"模型名称"`
|
||||
|
||||
HeadTalk string `gorm:"type:varchar(255);default:'';comment:'头顶对话框内容'" json:"head_talk" description:"头顶对话框内容"`
|
||||
|
||||
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID(0表示无剧情)'" json:"trigger_plot_id" description:"触发剧情ID"`
|
||||
Cloths []uint32 `gorm:"type:varchar(255);default:'';comment:'服装'" json:"cloths" description:"服装"`
|
||||
Shinyid int32 `gorm:"type:int;default:0;comment:'是否发光'" json:"shiny" description:"是否发光"`
|
||||
}
|
||||
|
||||
func (*MapModel) TableName() string {
|
||||
return TableNameMapModel
|
||||
}
|
||||
|
||||
func (*MapModel) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
func NewMapModel() *MapModel {
|
||||
return &MapModel{
|
||||
Model: cool.NewModel(),
|
||||
MapModelBroadcastNode: &MapModelBroadcastNode{},
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cool.CreateTable(&MapModel{})
|
||||
}
|
||||
@@ -4,40 +4,23 @@ import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 这个是替换盖亚的实现,因为是单独类的
|
||||
const (
|
||||
|
||||
// 新增地图节点表常量
|
||||
TableNameMapNode = "config_map_node" // 地图节点配置表(记录地图各节点的类型、绑定BOSS、剧情等信息)
|
||||
TableNameMapNode = "config_map_node"
|
||||
)
|
||||
|
||||
// 节点类型常量定义
|
||||
const (
|
||||
MapNodeTypeBoss = 1 // BOSS节点
|
||||
MapNodeTypeNPC = 2 // NPC节点
|
||||
MapNodeTypeScene = 3 // 场景触发节点
|
||||
MapNodeTypePortal = 4 // 传送门节点
|
||||
MapNodeTypeBoss = 1
|
||||
MapNodeTypeNPC = 2
|
||||
MapNodeTypeScene = 3
|
||||
MapNodeTypePortal = 4
|
||||
)
|
||||
|
||||
type BroadcastNode struct {
|
||||
//节点激活脚本
|
||||
TriggerID uint32 `gorm:"comment:'触发器ID'" json:"trigger_id" description:"触发器ID"`
|
||||
//BOSS位置,多位置就是循环触发,固定点就是单位置,如果要实现原地动,就用2个固定位置来做
|
||||
//0:固定点,1:多位置,2:循环触发 赛有随机的boss和伪装的boss,如果是伪装boss,就触发剧情后实现boss的切换后再操作
|
||||
Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos"`
|
||||
HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"`
|
||||
//方向BroadcastNode
|
||||
Direction int32 `gorm:"type:int;default:0;comment:'方向'" json:"direction" description:"方向"`
|
||||
}
|
||||
|
||||
// MapNode 地图节点配置模型
|
||||
// MapNode stores map node config used by the existing boss/node flow.
|
||||
type MapNode struct {
|
||||
*BaseConfig
|
||||
*Event // 嵌入BOSS事件配置
|
||||
*BroadcastNode
|
||||
// 基础关联字段
|
||||
*Event
|
||||
|
||||
MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
|
||||
//可以是精灵也可以是NPC ,到时候npc用高ID去控制就行
|
||||
|
||||
NodeID uint32 `gorm:"not null;default:0;comment:'节点ID'" json:"node_id" description:"节点ID"`
|
||||
|
||||
@@ -45,42 +28,30 @@ type MapNode struct {
|
||||
|
||||
WinBonusID int `gorm:"type:int;default:0;comment:'胜利奖励ID'" json:"win_bonus_id"`
|
||||
FailBonusID int `gorm:"type:int;default:0;comment:'失败奖励ID'" json:"fail_bonus_id"`
|
||||
//是否需要广播,比如雷伊
|
||||
IsBroadcast int `gorm:"type:int;default:0;comment:'是否需要广播'" json:"is_broadcast"`
|
||||
// 剧情相关配置 通过剧情去主动触发boss显示和对话显示 ,待重构通过NPC节点判断哪种类型
|
||||
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID(0表示无剧情)'" json:"trigger_plot_id" description:"触发剧情ID"`
|
||||
//BindPlotIDs []uint32 `gorm:"type:int[];comment:'绑定的剧情ID列表'" json:"bind_plot_ids" description:"绑定剧情ID列表"`
|
||||
//完成后的脚本回调,比如战胜和击败绑定不同的任务ID,以及剧情绑定不同的ID
|
||||
//回调通boss打完给前端发送固定事件
|
||||
//PlotFinishScript string `gorm:"type:text;comment:'剧情完成后脚本回调'" json:"plot_finish_script" description:"剧情完成后脚本回调"`
|
||||
|
||||
BossIds []uint32 `gorm:"type:jsonb; ;comment:'塔层BOSS ID列表'" json:"boss_ids"`
|
||||
IsBroadcast uint32 `gorm:"type:int;default:0;comment:'是否需要广播'" json:"is_broadcast"`
|
||||
|
||||
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID(0表示无剧情)'" json:"trigger_plot_id" description:"触发剧情ID"`
|
||||
|
||||
BossIds []uint32 `gorm:"type:jsonb;comment:'塔层BOSS ID列表'" json:"boss_ids"`
|
||||
}
|
||||
|
||||
// -------------------------- MapNode 配套方法(遵循项目规范)--------------------------
|
||||
// TableName 指定数据库表名
|
||||
func (*MapNode) TableName() string {
|
||||
return TableNameMapNode
|
||||
}
|
||||
|
||||
// GroupName 指定分组名称(与原有规范保持一致)
|
||||
func (*MapNode) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewMapNode 创建MapNode实例
|
||||
func NewMapNode() *MapNode {
|
||||
return &MapNode{
|
||||
BaseConfig: NewBaseConfig(),
|
||||
Event: &Event{},
|
||||
}
|
||||
}
|
||||
|
||||
// GetNodeTypeName 获取节点类型的中文名称(方便展示)
|
||||
|
||||
// -------------------------- 表结构自动同步 --------------------------
|
||||
func init() {
|
||||
// 同步原有地图配置表
|
||||
cool.CreateTable(&MapConfig{})
|
||||
// 同步新增的地图节点配置表
|
||||
cool.CreateTable(&MapNode{})
|
||||
}
|
||||
|
||||
28
modules/config/service/map_model.go
Normal file
28
modules/config/service/map_model.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
)
|
||||
|
||||
type MapmodelService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewMapmodelService() *MapmodelService {
|
||||
return &MapmodelService{
|
||||
&cool.Service{
|
||||
Model: model.NewMapModel(),
|
||||
PageQueryOp: &cool.QueryOp{
|
||||
KeyWordField: []string{"remake"},
|
||||
FieldEQ: []string{"map_id"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MapmodelService) GetDataByModelId(modelid uint32) (ret *model.MapModel) {
|
||||
|
||||
dbm_notenable(s.Model).Where("model_id", modelid).Scan(&ret)
|
||||
return
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func (s *MapNodeService) GetData(mapid uint32) []model.MapNode {
|
||||
func (s *MapNodeService) GetDataB(mapid uint32) []model.MapNode {
|
||||
|
||||
var pet []model.MapNode //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Where("is_broadcast", 1).Scan(&pet)
|
||||
dbm_enable(s.Model).Where("map_id", mapid).WhereNot("is_broadcast", 0).Scan(&pet)
|
||||
|
||||
return pet
|
||||
|
||||
@@ -52,7 +52,7 @@ func (s *MapNodeService) GetTip(mapid uint32) []uint32 {
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet)
|
||||
var ret []uint32
|
||||
for _, v := range pet {
|
||||
ret = append(ret, v.TriggerID)
|
||||
ret = append(ret, v.BossIds...)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user