Files
bl/modules/config/model/map_node.go
昔念 c00a796203
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
refactor(common/utils): 重构concurrent_swiss_map使用官方sync.Map实现

- 替换原有的第三方并发map实现,改为基于标准库sync.Map的封装
- 保持完全的API兼容性,原有配置方法变为无实际作用的占位符
- 优化Range方法实现,移除goroutine/channel开销,避免潜在的死锁风险
- 移除依赖的外部库和
2026-02-25 13:20:38 +08:00

89 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"blazing/cool"
)
// 这个是替换盖亚的实现,因为是单独类的
const (
// 新增地图节点表常量
TableNameMapNode = "config_map_node" // 地图节点配置表记录地图各节点的类型、绑定BOSS、剧情等信息
)
// 节点类型常量定义
const (
MapNodeTypeBoss = 1 // BOSS节点
MapNodeTypeNPC = 2 // NPC节点
MapNodeTypeScene = 3 // 场景触发节点
MapNodeTypePortal = 4 // 传送门节点
)
// MapNode 地图节点配置模型
type MapNode struct {
*BaseConfig
*Event // 嵌入BOSS事件配置
// 基础关联字段
NodeType int `gorm:"not null;default:0;comment:'节点类型0是游戏自带分支,其余自增)'" json:"node_type" description:"节点类型"`
NodeID uint32 `gorm:"not null;default:0;comment:'节点ID'" json:"node_id" description:"节点ID"`
NodeName string `gorm:"type:varchar(100);default:'';comment:'节点名称'" json:"node_name" description:"节点名称"`
//节点激活脚本
PositionX float64 `gorm:"not null;default:0;comment:'节点X坐标'" json:"position_x" description:"X坐标"`
PositionY float64 `gorm:"not null;default:0;comment:'节点Y坐标'" json:"position_y" description:"Y坐标"`
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"`
// 剧情相关配置
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID0表示无剧情'" 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:"剧情完成后脚本回调"`
BindBossID uint32 `gorm:"default:0;comment:'绑定的BOSS ID0表示无BOSS'" json:"bind_boss_id" description:"绑定BOSS ID"`
}
// -------------------------- MapNode 配套方法(遵循项目规范)--------------------------
// TableName 指定数据库表名
func (*MapNode) TableName() string {
return TableNameMapNode
}
// GroupName 指定分组名称(与原有规范保持一致)
func (*MapNode) GroupName() string {
return "default"
}
// NewMapNode 创建MapNode实例
func NewMapNode() *MapNode {
return &MapNode{
BaseConfig: NewBaseConfig(),
}
}
// GetNodeTypeName 获取节点类型的中文名称(方便展示)
func (m *MapNode) GetNodeTypeName() string {
switch m.NodeType {
case MapNodeTypeBoss:
return "BOSS节点"
case MapNodeTypeNPC:
return "NPC节点"
case MapNodeTypeScene:
return "场景触发节点"
case MapNodeTypePortal:
return "传送门节点"
default:
return "未知节点"
}
}
// -------------------------- 表结构自动同步 --------------------------
func init() {
// 同步原有地图配置表
cool.CreateTable(&MapConfig{})
// 同步新增的地图节点配置表
cool.CreateTable(&MapNode{})
}