This commit is contained in:
flswld
2023-03-27 22:41:43 +08:00
parent 568a329488
commit e912932b79
2 changed files with 19 additions and 7 deletions

View File

@@ -556,8 +556,14 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
g.SendToWorldA(scene.world, cmd.LifeStateChangeNotify, 0, ntf)
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.id})
// 删除实体
scene.DestroyEntity(entity.id)
group := scene.GetGroupById(entity.groupId)
if group == nil {
logger.Error("get scene group is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
return
}
group.DestroyEntity(entity.GetId())
scene.DestroyEntity(entity.GetId())
// 怪物死亡触发器
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
if entity.groupId == 133003095 {
logger.Debug("==========1==========")
@@ -567,11 +573,6 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
logger.Error("get group config is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
return
}
group := scene.GetGroupById(entity.groupId)
if group == nil {
logger.Error("get scene group is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
return
}
for suiteId := range group.GetAllSuite() {
if entity.groupId == 133003095 {
logger.Debug("==========2==========")

View File

@@ -519,6 +519,17 @@ func (g *Group) GetEntityByConfigId(configId uint32) *Entity {
return nil
}
func (g *Group) DestroyEntity(entityId uint32) {
for _, suite := range g.suiteMap {
for _, entity := range suite.entityMap {
if entity.id == entityId {
delete(suite.entityMap, entity.id)
return
}
}
}
}
func (s *Suite) GetEntityById(entityId uint32) *Entity {
return s.entityMap[entityId]
}