feat(space): 添加地图模型配置支持并优化BOSS信息结构 添加MapModel字段到MapBossInfo结构体中,用于存储更完整的BOSS模型数据, 修改初始化逻辑从新的MapModel服务获取数据,并更新HP恢复逻辑使用新模型数据。 同时优化MapNode配置表结构,移除冗余字段并调整数据查询逻辑, 将IsBroadcast字段类型改为uint32以
This commit is contained in:
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{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user