| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package mapLogic
- import (
- "f1-game/internal/types"
- "f1-game/nodes/map/internal/db"
- mapTypes "f1-game/nodes/map/internal/types"
- capp "github.com/cherry-game/cherry/facade"
- )
- func Init(app capp.IApplication, mapTables *db.LogicTables, playerTables map[int64]*db.MapPlayerTable, leagueTables map[int64]*db.MapLeagueTable) {
- // 初始化联盟pb数据
- initLeagues(leagueTables)
- mapBornPos := initMapBornPos(mapTables)
- bornLimit := initStateBornLimit(playerTables)
- // 初始化 logic 数据
- actorLogic := NewActor(mapTables, mapBornPos, bornLimit)
- app.ActorSystem().CreateActor(actorLogic.AliasID(), actorLogic)
- }
- func initLeagues(leagueTables map[int64]*db.MapLeagueTable) {
- for _, league := range leagueTables {
- pbMapLeagues[league.LeagueID] = league.ToMapLeague()
- }
- }
- func initMapBornPos(mapTables *db.LogicTables) mapTypes.MapBornPos {
- mapBornPos := mapTypes.NewBornPos()
- // 过滤出生点
- // 系统建筑不会占领出生点
- // 玩家建筑占领的出生点
- for _, buildTable := range mapTables.BuildTables {
- mapBornPos.Remove(buildTable.GetTiles()...)
- }
- // TODO 集结中的怪物占领的出生点
- return mapBornPos
- }
- func initStateBornLimit(playerTables map[int64]*db.MapPlayerTable) types.Map[int32, int32] {
- bornLimit := types.NewMap[int32, int32]()
- for _, playerTable := range playerTables {
- if !playerTable.IsSelectBornState() {
- continue
- }
- bornLimit[playerTable.BornStateID]++
- }
- return bornLimit
- }
|