场景实体面向对象继承多态重构
This commit is contained in:
1 parent
178de25493
commit
fa4f53bf7a
15 files changed
+506
-483
No files matched your search
@@ -318,7 +318,7 @@ func UpdateFrame(fileData []byte, basePos *model.Vector, rgb bool) {
|
|||||||
Z: leftTopPos.Z,
|
Z: leftTopPos.Z,
|
||||||
}, new(model.Vector),
|
}, new(model.Vector),
|
||||||
uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT),
|
uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
new(GadgetNormalEntity), 0, 0, constant.VISION_LEVEL_SUPER)
|
false, 0, 0, 0, 0, constant.VISION_LEVEL_SUPER)
|
||||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||||
} else {
|
} else {
|
||||||
if !FRAME[w][h] {
|
if !FRAME[w][h] {
|
||||||
@@ -329,7 +329,7 @@ func UpdateFrame(fileData []byte, basePos *model.Vector, rgb bool) {
|
|||||||
Z: leftTopPos.Z,
|
Z: leftTopPos.Z,
|
||||||
}, new(model.Vector),
|
}, new(model.Vector),
|
||||||
uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT),
|
uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
new(GadgetNormalEntity), 0, 0, constant.VISION_LEVEL_SUPER)
|
false, 0, 0, 0, 0, constant.VISION_LEVEL_SUPER)
|
||||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ func (g *GMCmd) GMKillMonster(userId uint32, entityId uint32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 确保为怪物
|
// 确保为怪物
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_MONSTER {
|
_, ok := entity.(*MonsterEntity)
|
||||||
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 杀死怪物
|
// 杀死怪物
|
||||||
@@ -218,7 +219,8 @@ func (g *GMCmd) GMKillAllMonster(userId uint32) {
|
|||||||
// 杀死视野内所有怪物实体
|
// 杀死视野内所有怪物实体
|
||||||
for _, entity := range GAME.GetVisionEntity(scene, GAME.GetPlayerPos(player)) {
|
for _, entity := range GAME.GetVisionEntity(scene, GAME.GetPlayerPos(player)) {
|
||||||
// 确保为怪物
|
// 确保为怪物
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_MONSTER {
|
_, ok := entity.(*MonsterEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 杀死怪物
|
// 杀死怪物
|
||||||
@@ -413,7 +415,7 @@ func (g *GMCmd) GMCreateGadget(userId uint32, gadgetId uint32, count uint32) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
GAME.CreateGadget(player, nil, gadgetId, nil)
|
GAME.CreateGadget(player, nil, gadgetId, false, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,13 +65,13 @@ func (p *PhysicsEngine) ShowAvatarCollider() {
|
|||||||
entity := p.world.GetPlayerActiveAvatarEntity(player)
|
entity := p.world.GetPlayerActiveAvatarEntity(player)
|
||||||
avatarPos := entity.GetPos()
|
avatarPos := entity.GetPos()
|
||||||
avatarPos.Y += float64(p.avatarYOffset)
|
avatarPos.Y += float64(p.avatarYOffset)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y + AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y + AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y - AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y - AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X + AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X + AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X - AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X - AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z + AVATAR_RADIUS}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z + AVATAR_RADIUS}, GADGET_GREEN, false, 0, 0)
|
||||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z - AVATAR_RADIUS}, GADGET_GREEN, nil)
|
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z - AVATAR_RADIUS}, GADGET_GREEN, false, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ func (p *PhysicsEngine) Update(now int64) []*RigidBody {
|
|||||||
X: float64(rigidBody.position.X),
|
X: float64(rigidBody.position.X),
|
||||||
Y: float64(rigidBody.position.Y),
|
Y: float64(rigidBody.position.Y),
|
||||||
Z: float64(rigidBody.position.Z),
|
Z: float64(rigidBody.position.Z),
|
||||||
}, GADGET_RED, nil)
|
}, GADGET_RED, false, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.lastUpdateTime = now
|
p.lastUpdateTime = now
|
||||||
|
|||||||
+33
-23
@@ -227,7 +227,11 @@ func (p *PluginPubg) EventEvtDoSkillSucc(iEvent IPluginEvent) {
|
|||||||
scene := world.GetSceneById(player.GetSceneId())
|
scene := world.GetSceneById(player.GetSceneId())
|
||||||
avatarEntity := scene.GetEntity(worldAvatar.GetAvatarEntityId())
|
avatarEntity := scene.GetEntity(worldAvatar.GetAvatarEntityId())
|
||||||
for _, entity := range scene.GetAllEntity() {
|
for _, entity := range scene.GetAllEntity() {
|
||||||
if entity.GetId() == avatarEntity.GetId() || entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
if entity.GetId() == avatarEntity.GetId() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
_, ok := entity.(*AvatarEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
distance3D := math.Sqrt(
|
distance3D := math.Sqrt(
|
||||||
@@ -267,7 +271,8 @@ func (p *PluginPubg) EventEvtBeingHit(iEvent IPluginEvent) {
|
|||||||
if defEntity == nil {
|
if defEntity == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if defEntity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
defAvatarEntity, ok := defEntity.(*AvatarEntity)
|
||||||
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fightProp := defEntity.GetFightProp()
|
fightProp := defEntity.GetFightProp()
|
||||||
@@ -275,20 +280,25 @@ func (p *PluginPubg) EventEvtBeingHit(iEvent IPluginEvent) {
|
|||||||
if currHp-attackResult.Damage > 0.0 {
|
if currHp-attackResult.Damage > 0.0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defPlayer := USER_MANAGER.GetOnlineUser(defEntity.GetAvatarEntity().GetUid())
|
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetUid())
|
||||||
if defPlayer == nil {
|
if defPlayer == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
atkEntity := scene.GetEntity(attackResult.AttackerId)
|
atkEntity := scene.GetEntity(attackResult.AttackerId)
|
||||||
if atkEntity != nil && atkEntity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
if atkEntity == nil {
|
||||||
atkPlayer := USER_MANAGER.GetOnlineUser(atkEntity.GetAvatarEntity().GetUid())
|
return
|
||||||
if atkPlayer == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
info := fmt.Sprintf("『%v』击败了『%v』。", atkPlayer.NickName, defPlayer.NickName)
|
|
||||||
GAME.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
|
||||||
p.CreateUserTimer(defPlayer.PlayerId, 10, p.UserTimerPubgDieExit, p.world.GetId())
|
|
||||||
}
|
}
|
||||||
|
atkAvatarEntity, ok := atkEntity.(*AvatarEntity)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
atkPlayer := USER_MANAGER.GetOnlineUser(atkAvatarEntity.GetUid())
|
||||||
|
if atkPlayer == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
info := fmt.Sprintf("『%v』击败了『%v』。", atkPlayer.NickName, defPlayer.NickName)
|
||||||
|
GAME.PlayerChatReq(world.GetOwner(), &proto.PlayerChatReq{ChatInfo: &proto.ChatInfo{Content: &proto.ChatInfo_Text{Text: info}}})
|
||||||
|
p.CreateUserTimer(defPlayer.PlayerId, 10, p.UserTimerPubgDieExit, p.world.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
// EvtCreateGadget 创建物件实体事件
|
// EvtCreateGadget 创建物件实体事件
|
||||||
@@ -518,7 +528,7 @@ func (p *PluginPubg) StartPubg() {
|
|||||||
p.world.GetOwner(),
|
p.world.GetOwner(),
|
||||||
&model.Vector{X: float64(pubgWorldGadgetDataConfig.X), Y: float64(pubgWorldGadgetDataConfig.Y), Z: float64(pubgWorldGadgetDataConfig.Z)},
|
&model.Vector{X: float64(pubgWorldGadgetDataConfig.X), Y: float64(pubgWorldGadgetDataConfig.Y), Z: float64(pubgWorldGadgetDataConfig.Z)},
|
||||||
uint32(pubgWorldGadgetDataConfig.GadgetId),
|
uint32(pubgWorldGadgetDataConfig.GadgetId),
|
||||||
nil,
|
false, 0, 0,
|
||||||
)
|
)
|
||||||
p.entityIdWorldGadgetIdMap[entityId] = pubgWorldGadgetDataConfig.WorldGadgetId
|
p.entityIdWorldGadgetIdMap[entityId] = pubgWorldGadgetDataConfig.WorldGadgetId
|
||||||
}
|
}
|
||||||
@@ -697,19 +707,19 @@ func (p *PluginPubg) GetAlivePlayerList() []*model.Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEntityId uint32, isBow bool) {
|
func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEntityId uint32, isBow bool) {
|
||||||
defAvatarEntity := scene.GetEntity(defAvatarEntityId)
|
defEntity := scene.GetEntity(defAvatarEntityId)
|
||||||
if defAvatarEntity == nil {
|
if defEntity == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defPlayer := USER_MANAGER.GetOnlineUser(defAvatarEntity.GetAvatarEntity().GetUid())
|
defPlayer := USER_MANAGER.GetOnlineUser(defEntity.(*AvatarEntity).GetUid())
|
||||||
if defPlayer == nil {
|
if defPlayer == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
atkAvatarEntity := scene.GetEntity(atkAvatarEntityId)
|
atkEntity := scene.GetEntity(atkAvatarEntityId)
|
||||||
if atkAvatarEntity == nil {
|
if atkEntity == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
atkPlayer := USER_MANAGER.GetOnlineUser(atkAvatarEntity.GetAvatarEntity().GetUid())
|
atkPlayer := USER_MANAGER.GetOnlineUser(atkEntity.(*AvatarEntity).GetUid())
|
||||||
if atkPlayer == nil {
|
if atkPlayer == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -719,7 +729,7 @@ func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEn
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.playerHitTimeMap[atkPlayer.PlayerId] = now
|
p.playerHitTimeMap[atkPlayer.PlayerId] = now
|
||||||
atk := atkAvatarEntity.GetFightProp()[constant.FIGHT_PROP_CUR_ATTACK]
|
atk := atkEntity.GetFightProp()[constant.FIGHT_PROP_CUR_ATTACK]
|
||||||
dmg := float32(0.0)
|
dmg := float32(0.0)
|
||||||
if isBow {
|
if isBow {
|
||||||
dmg = atk / PUBG_BOW_ATTACK_ATK_RATIO
|
dmg = atk / PUBG_BOW_ATTACK_ATK_RATIO
|
||||||
@@ -728,8 +738,8 @@ func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEn
|
|||||||
}
|
}
|
||||||
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
GAME.handleEvtBeingHit(defPlayer, scene, &proto.EvtBeingHitInfo{
|
||||||
AttackResult: &proto.AttackResult{
|
AttackResult: &proto.AttackResult{
|
||||||
AttackerId: atkAvatarEntity.GetId(),
|
AttackerId: atkEntity.GetId(),
|
||||||
DefenseId: defAvatarEntity.GetId(),
|
DefenseId: defEntity.GetId(),
|
||||||
Damage: dmg,
|
Damage: dmg,
|
||||||
DamageShield: dmg,
|
DamageShield: dmg,
|
||||||
},
|
},
|
||||||
@@ -742,8 +752,8 @@ func (p *PluginPubg) PubgHit(scene *Scene, defAvatarEntityId uint32, atkAvatarEn
|
|||||||
AttackResult: attackResultTemplate,
|
AttackResult: attackResultTemplate,
|
||||||
FrameNum: 0,
|
FrameNum: 0,
|
||||||
}
|
}
|
||||||
evtBeingHitInfo.AttackResult.AttackerId = atkAvatarEntity.GetId()
|
evtBeingHitInfo.AttackResult.AttackerId = atkEntity.GetId()
|
||||||
evtBeingHitInfo.AttackResult.DefenseId = defAvatarEntity.GetId()
|
evtBeingHitInfo.AttackResult.DefenseId = defEntity.GetId()
|
||||||
evtBeingHitInfo.AttackResult.Damage = dmg
|
evtBeingHitInfo.AttackResult.Damage = dmg
|
||||||
if evtBeingHitInfo.AttackResult.HitCollision == nil {
|
if evtBeingHitInfo.AttackResult.HitCollision == nil {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -586,7 +586,7 @@ func (w *World) GetPlayerAvatarIndexByAvatarId(player *model.Player, avatarId ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPlayerActiveAvatarEntity 获取玩家当前活跃角色场景实体
|
// GetPlayerActiveAvatarEntity 获取玩家当前活跃角色场景实体
|
||||||
func (w *World) GetPlayerActiveAvatarEntity(player *model.Player) *Entity {
|
func (w *World) GetPlayerActiveAvatarEntity(player *model.Player) IEntity {
|
||||||
activeAvatarId := w.GetPlayerActiveAvatarId(player)
|
activeAvatarId := w.GetPlayerActiveAvatarId(player)
|
||||||
avatarEntityId := w.GetPlayerWorldAvatarEntityId(player, activeAvatarId)
|
avatarEntityId := w.GetPlayerWorldAvatarEntityId(player, activeAvatarId)
|
||||||
scene := w.GetSceneById(player.GetSceneId())
|
scene := w.GetSceneById(player.GetSceneId())
|
||||||
@@ -872,7 +872,7 @@ func (w *World) CreateScene(sceneId uint32) *Scene {
|
|||||||
id: sceneId,
|
id: sceneId,
|
||||||
world: w,
|
world: w,
|
||||||
playerMap: make(map[uint32]*model.Player),
|
playerMap: make(map[uint32]*model.Player),
|
||||||
entityMap: make(map[uint32]*Entity),
|
entityMap: make(map[uint32]IEntity),
|
||||||
groupMap: make(map[uint32]*Group),
|
groupMap: make(map[uint32]*Group),
|
||||||
createTime: time.Now().UnixMilli(),
|
createTime: time.Now().UnixMilli(),
|
||||||
meeoIndex: 0,
|
meeoIndex: 0,
|
||||||
|
|||||||
+261
-262
@@ -17,7 +17,7 @@ type Scene struct {
|
|||||||
id uint32
|
id uint32
|
||||||
world *World
|
world *World
|
||||||
playerMap map[uint32]*model.Player
|
playerMap map[uint32]*model.Player
|
||||||
entityMap map[uint32]*Entity // 场景中全部的实体
|
entityMap map[uint32]IEntity // 场景中全部的实体
|
||||||
groupMap map[uint32]*Group // 场景中按group->suite分类的实体
|
groupMap map[uint32]*Group // 场景中按group->suite分类的实体
|
||||||
createTime int64 // 场景创建时间
|
createTime int64 // 场景创建时间
|
||||||
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
|
meeoIndex uint32 // 客户端风元素染色同步协议的计数器
|
||||||
@@ -36,7 +36,7 @@ func (s *Scene) GetAllPlayer() map[uint32]*model.Player {
|
|||||||
return s.playerMap
|
return s.playerMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) GetAllEntity() map[uint32]*Entity {
|
func (s *Scene) GetAllEntity() map[uint32]IEntity {
|
||||||
return s.entityMap
|
return s.entityMap
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,44 +98,46 @@ func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32
|
|||||||
logger.Error("get avatar is nil, avatarId: %v", avatar)
|
logger.Error("get avatar is nil, avatarId: %v", avatar)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
entity := &Entity{
|
entity := &AvatarEntity{
|
||||||
id: entityId,
|
Entity: &Entity{
|
||||||
scene: s,
|
id: entityId,
|
||||||
lifeState: avatar.LifeState,
|
scene: s,
|
||||||
pos: player.GetPos(),
|
lifeState: avatar.LifeState,
|
||||||
rot: player.GetRot(),
|
pos: player.GetPos(),
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
rot: player.GetRot(),
|
||||||
lastMoveSceneTimeMs: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
lastMoveReliableSeq: 0,
|
lastMoveSceneTimeMs: 0,
|
||||||
fightProp: avatar.FightPropMap, // 使用角色结构的数据
|
lastMoveReliableSeq: 0,
|
||||||
entityType: constant.ENTITY_TYPE_AVATAR,
|
fightProp: avatar.FightPropMap, // 使用角色结构的数据
|
||||||
avatarEntity: &AvatarEntity{
|
entityType: constant.ENTITY_TYPE_AVATAR,
|
||||||
uid: player.PlayerId,
|
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||||
avatarId: avatarId,
|
|
||||||
},
|
},
|
||||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
uid: player.PlayerId,
|
||||||
|
avatarId: avatarId,
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) CreateEntityWeapon(pos, rot *model.Vector) uint32 {
|
func (s *Scene) CreateEntityWeapon(pos, rot *model.Vector) uint32 {
|
||||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_WEAPON)
|
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_WEAPON)
|
||||||
entity := &Entity{
|
entity := &WeaponEntity{
|
||||||
id: entityId,
|
&Entity{
|
||||||
scene: s,
|
id: entityId,
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
scene: s,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
lastMoveReliableSeq: 0,
|
lastMoveSceneTimeMs: 0,
|
||||||
fightProp: map[uint32]float32{
|
lastMoveReliableSeq: 0,
|
||||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
fightProp: map[uint32]float32{
|
||||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||||
constant.FIGHT_PROP_BASE_HP: float32(1),
|
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||||
|
constant.FIGHT_PROP_BASE_HP: float32(1),
|
||||||
|
},
|
||||||
|
entityType: constant.ENTITY_TYPE_WEAPON,
|
||||||
|
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||||
},
|
},
|
||||||
entityType: constant.ENTITY_TYPE_WEAPON,
|
|
||||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
@@ -147,116 +149,118 @@ func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, le
|
|||||||
fightPropMap[constant.FIGHT_PROP_MAX_HP] = fightPropMap[constant.FIGHT_PROP_BASE_HP]
|
fightPropMap[constant.FIGHT_PROP_MAX_HP] = fightPropMap[constant.FIGHT_PROP_BASE_HP]
|
||||||
fightPropMap[constant.FIGHT_PROP_CUR_HP] = fightPropMap[constant.FIGHT_PROP_MAX_HP]
|
fightPropMap[constant.FIGHT_PROP_CUR_HP] = fightPropMap[constant.FIGHT_PROP_MAX_HP]
|
||||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_MONSTER)
|
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_MONSTER)
|
||||||
entity := &Entity{
|
entity := &MonsterEntity{
|
||||||
id: entityId,
|
Entity: &Entity{
|
||||||
scene: s,
|
id: entityId,
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
scene: s,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
lastMoveReliableSeq: 0,
|
lastMoveSceneTimeMs: 0,
|
||||||
fightProp: fightPropMap,
|
lastMoveReliableSeq: 0,
|
||||||
entityType: constant.ENTITY_TYPE_MONSTER,
|
fightProp: fightPropMap,
|
||||||
level: level,
|
level: level,
|
||||||
monsterEntity: &MonsterEntity{
|
entityType: constant.ENTITY_TYPE_MONSTER,
|
||||||
monsterId: monsterId,
|
configId: configId,
|
||||||
|
groupId: groupId,
|
||||||
|
visionLevel: visionLevel,
|
||||||
},
|
},
|
||||||
configId: configId,
|
monsterId: monsterId,
|
||||||
groupId: groupId,
|
|
||||||
visionLevel: visionLevel,
|
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQuestId, blockId, configId, groupId uint32) uint32 {
|
func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQuestId, blockId, configId, groupId uint32) uint32 {
|
||||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_NPC)
|
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_NPC)
|
||||||
entity := &Entity{
|
entity := &NpcEntity{
|
||||||
id: entityId,
|
Entity: &Entity{
|
||||||
scene: s,
|
id: entityId,
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
scene: s,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
lastMoveReliableSeq: 0,
|
lastMoveSceneTimeMs: 0,
|
||||||
fightProp: map[uint32]float32{
|
lastMoveReliableSeq: 0,
|
||||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
fightProp: map[uint32]float32{
|
||||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||||
constant.FIGHT_PROP_BASE_HP: float32(1),
|
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||||
|
constant.FIGHT_PROP_BASE_HP: float32(1),
|
||||||
|
},
|
||||||
|
entityType: constant.ENTITY_TYPE_NPC,
|
||||||
|
configId: configId,
|
||||||
|
groupId: groupId,
|
||||||
|
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||||
},
|
},
|
||||||
entityType: constant.ENTITY_TYPE_NPC,
|
npcId: npcId,
|
||||||
npcEntity: &NpcEntity{
|
roomId: roomId,
|
||||||
npcId: npcId,
|
parentQuestId: parentQuestId,
|
||||||
roomId: roomId,
|
blockId: blockId,
|
||||||
parentQuestId: parentQuestId,
|
|
||||||
blockId: blockId,
|
|
||||||
},
|
|
||||||
configId: configId,
|
|
||||||
groupId: groupId,
|
|
||||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId, gadgetState uint32, gadgetNormalEntity *GadgetNormalEntity, configId, groupId uint32, visionLevel int) uint32 {
|
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId, gadgetState uint32, isDrop bool, itemId, count uint32, configId, groupId uint32, visionLevel int) uint32 {
|
||||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||||
entity := &Entity{
|
entity := &GadgetNormalEntity{
|
||||||
id: entityId,
|
GadgetEntity: &GadgetEntity{
|
||||||
scene: s,
|
Entity: &Entity{
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
id: entityId,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
scene: s,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveReliableSeq: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
fightProp: map[uint32]float32{
|
lastMoveSceneTimeMs: 0,
|
||||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
lastMoveReliableSeq: 0,
|
||||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
fightProp: map[uint32]float32{
|
||||||
constant.FIGHT_PROP_BASE_HP: float32(1),
|
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||||
|
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||||
|
constant.FIGHT_PROP_BASE_HP: float32(1),
|
||||||
|
},
|
||||||
|
entityType: constant.ENTITY_TYPE_GADGET,
|
||||||
|
configId: configId,
|
||||||
|
groupId: groupId,
|
||||||
|
visionLevel: visionLevel,
|
||||||
|
},
|
||||||
|
gadgetId: gadgetId,
|
||||||
|
gadgetState: gadgetState,
|
||||||
},
|
},
|
||||||
entityType: constant.ENTITY_TYPE_GADGET,
|
isDrop: isDrop,
|
||||||
gadgetEntity: &GadgetEntity{
|
itemId: itemId,
|
||||||
gadgetId: gadgetId,
|
count: count,
|
||||||
gadgetState: gadgetState,
|
|
||||||
gadgetType: GADGET_TYPE_NORMAL,
|
|
||||||
gadgetNormalEntity: gadgetNormalEntity,
|
|
||||||
},
|
|
||||||
configId: configId,
|
|
||||||
groupId: groupId,
|
|
||||||
visionLevel: visionLevel,
|
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, configId, campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) bool {
|
func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, configId, campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) bool {
|
||||||
entity := &Entity{
|
entity := &GadgetClientEntity{
|
||||||
id: entityId,
|
GadgetEntity: &GadgetEntity{
|
||||||
scene: s,
|
Entity: &Entity{
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
id: entityId,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
scene: s,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveReliableSeq: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
fightProp: map[uint32]float32{
|
lastMoveSceneTimeMs: 0,
|
||||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
lastMoveReliableSeq: 0,
|
||||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
fightProp: map[uint32]float32{
|
||||||
constant.FIGHT_PROP_BASE_HP: float32(1),
|
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||||
},
|
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||||
entityType: constant.ENTITY_TYPE_GADGET,
|
constant.FIGHT_PROP_BASE_HP: float32(1),
|
||||||
gadgetEntity: &GadgetEntity{
|
},
|
||||||
gadgetType: GADGET_TYPE_CLIENT,
|
entityType: constant.ENTITY_TYPE_GADGET,
|
||||||
gadgetClientEntity: &GadgetClientEntity{
|
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||||
configId: configId,
|
configId: configId,
|
||||||
campId: campId,
|
|
||||||
campType: campType,
|
|
||||||
ownerEntityId: ownerEntityId,
|
|
||||||
targetEntityId: targetEntityId,
|
|
||||||
propOwnerEntityId: propOwnerEntityId,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
campId: campId,
|
||||||
|
campType: campType,
|
||||||
|
ownerEntityId: ownerEntityId,
|
||||||
|
targetEntityId: targetEntityId,
|
||||||
|
propOwnerEntityId: propOwnerEntityId,
|
||||||
}
|
}
|
||||||
if s.CreateEntity(entity) == 0 {
|
if s.CreateEntity(entity) == 0 {
|
||||||
return false
|
return false
|
||||||
@@ -272,46 +276,45 @@ func (s *Scene) CreateEntityGadgetVehicle(ownerUid uint32, pos, rot *model.Vecto
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||||
entity := &Entity{
|
entity := &GadgetVehicleEntity{
|
||||||
id: entityId,
|
GadgetEntity: &GadgetEntity{
|
||||||
scene: s,
|
Entity: &Entity{
|
||||||
lifeState: constant.LIFE_STATE_ALIVE,
|
id: entityId,
|
||||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
scene: s,
|
||||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
lifeState: constant.LIFE_STATE_ALIVE,
|
||||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||||
lastMoveSceneTimeMs: 0,
|
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||||
lastMoveReliableSeq: 0,
|
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||||
fightProp: map[uint32]float32{
|
lastMoveSceneTimeMs: 0,
|
||||||
constant.FIGHT_PROP_BASE_DEFENSE: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.DefenseBase,
|
lastMoveReliableSeq: 0,
|
||||||
constant.FIGHT_PROP_CUR_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
fightProp: map[uint32]float32{
|
||||||
constant.FIGHT_PROP_MAX_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
constant.FIGHT_PROP_BASE_DEFENSE: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.DefenseBase,
|
||||||
constant.FIGHT_PROP_CUR_ATTACK: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.Attack,
|
constant.FIGHT_PROP_CUR_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
||||||
},
|
constant.FIGHT_PROP_MAX_HP: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.HP,
|
||||||
entityType: constant.ENTITY_TYPE_GADGET,
|
constant.FIGHT_PROP_CUR_ATTACK: vehicleDataConfig.ConfigGadgetVehicle.Combat.Property.Attack,
|
||||||
gadgetEntity: &GadgetEntity{
|
},
|
||||||
gadgetType: GADGET_TYPE_VEHICLE,
|
entityType: constant.ENTITY_TYPE_GADGET,
|
||||||
gadgetVehicleEntity: &GadgetVehicleEntity{
|
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||||
vehicleId: vehicleId,
|
|
||||||
worldId: s.world.id,
|
|
||||||
ownerUid: ownerUid,
|
|
||||||
maxStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
|
||||||
curStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
|
||||||
restoreDelay: 0,
|
|
||||||
memberMap: make(map[uint32]*model.Player),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
vehicleId: vehicleId,
|
||||||
|
worldId: s.world.id,
|
||||||
|
ownerUid: ownerUid,
|
||||||
|
maxStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
||||||
|
curStamina: vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaUpperLimit,
|
||||||
|
restoreDelay: 0,
|
||||||
|
memberMap: make(map[uint32]uint32),
|
||||||
}
|
}
|
||||||
return s.CreateEntity(entity)
|
return s.CreateEntity(entity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) CreateEntity(entity *Entity) uint32 {
|
func (s *Scene) CreateEntity(entity IEntity) uint32 {
|
||||||
if len(s.entityMap) >= ENTITY_MAX_SEND_NUM && !ENTITY_NUM_UNLIMIT {
|
if len(s.entityMap) >= ENTITY_MAX_SEND_NUM && !ENTITY_NUM_UNLIMIT {
|
||||||
logger.Error("above max scene entity num limit: %v, id: %v, pos: %v", ENTITY_MAX_SEND_NUM, entity.id, entity.pos)
|
logger.Error("above max scene entity num limit: %v, id: %v, pos: %v", ENTITY_MAX_SEND_NUM, entity.GetId(), entity.GetPos())
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
s.entityMap[entity.id] = entity
|
s.entityMap[entity.GetId()] = entity
|
||||||
return entity.id
|
return entity.GetId()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) DestroyEntity(entityId uint32) {
|
func (s *Scene) DestroyEntity(entityId uint32) {
|
||||||
@@ -319,14 +322,14 @@ func (s *Scene) DestroyEntity(entityId uint32) {
|
|||||||
if entity == nil {
|
if entity == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
delete(s.entityMap, entity.id)
|
delete(s.entityMap, entity.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) GetEntity(entityId uint32) *Entity {
|
func (s *Scene) GetEntity(entityId uint32) IEntity {
|
||||||
return s.entityMap[entityId]
|
return s.entityMap[entityId]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scene) AddGroupSuite(groupId uint32, suiteId uint8, entityMap map[uint32]*Entity) {
|
func (s *Scene) AddGroupSuite(groupId uint32, suiteId uint8, entityMap map[uint32]IEntity) {
|
||||||
group, exist := s.groupMap[groupId]
|
group, exist := s.groupMap[groupId]
|
||||||
if !exist {
|
if !exist {
|
||||||
group = &Group{
|
group = &Group{
|
||||||
@@ -339,7 +342,7 @@ func (s *Scene) AddGroupSuite(groupId uint32, suiteId uint8, entityMap map[uint3
|
|||||||
if !exist {
|
if !exist {
|
||||||
suite = &Suite{
|
suite = &Suite{
|
||||||
id: suiteId,
|
id: suiteId,
|
||||||
entityMap: make(map[uint32]*Entity),
|
entityMap: make(map[uint32]IEntity),
|
||||||
}
|
}
|
||||||
group.suiteMap[suiteId] = suite
|
group.suiteMap[suiteId] = suite
|
||||||
}
|
}
|
||||||
@@ -360,7 +363,7 @@ func (s *Scene) RemoveGroupSuite(groupId uint32, suiteId uint8) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, entity := range suite.entityMap {
|
for _, entity := range suite.entityMap {
|
||||||
s.DestroyEntity(entity.id)
|
s.DestroyEntity(entity.GetId())
|
||||||
}
|
}
|
||||||
delete(group.suiteMap, suiteId)
|
delete(group.suiteMap, suiteId)
|
||||||
if len(group.suiteMap) == 0 {
|
if len(group.suiteMap) == 0 {
|
||||||
@@ -375,7 +378,7 @@ type Group struct {
|
|||||||
|
|
||||||
type Suite struct {
|
type Suite struct {
|
||||||
id uint8
|
id uint8
|
||||||
entityMap map[uint32]*Entity
|
entityMap map[uint32]IEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetId() uint32 {
|
func (g *Group) GetId() uint32 {
|
||||||
@@ -390,20 +393,20 @@ func (g *Group) GetAllSuite() map[uint8]*Suite {
|
|||||||
return g.suiteMap
|
return g.suiteMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetAllEntity() map[uint32]*Entity {
|
func (g *Group) GetAllEntity() map[uint32]IEntity {
|
||||||
entityMap := make(map[uint32]*Entity)
|
entityMap := make(map[uint32]IEntity)
|
||||||
for _, suite := range g.suiteMap {
|
for _, suite := range g.suiteMap {
|
||||||
for _, entity := range suite.entityMap {
|
for _, entity := range suite.entityMap {
|
||||||
entityMap[entity.id] = entity
|
entityMap[entity.GetId()] = entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entityMap
|
return entityMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Group) GetEntityByConfigId(configId uint32) *Entity {
|
func (g *Group) GetEntityByConfigId(configId uint32) IEntity {
|
||||||
for _, suite := range g.suiteMap {
|
for _, suite := range g.suiteMap {
|
||||||
for _, entity := range suite.entityMap {
|
for _, entity := range suite.entityMap {
|
||||||
if entity.configId == configId {
|
if entity.GetConfigId() == configId {
|
||||||
return entity
|
return entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -414,8 +417,8 @@ func (g *Group) GetEntityByConfigId(configId uint32) *Entity {
|
|||||||
func (g *Group) DestroyEntity(entityId uint32) {
|
func (g *Group) DestroyEntity(entityId uint32) {
|
||||||
for _, suite := range g.suiteMap {
|
for _, suite := range g.suiteMap {
|
||||||
for _, entity := range suite.entityMap {
|
for _, entity := range suite.entityMap {
|
||||||
if entity.id == entityId {
|
if entity.GetId() == entityId {
|
||||||
delete(suite.entityMap, entity.id)
|
delete(suite.entityMap, entity.GetId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,14 +429,42 @@ func (s *Suite) GetId() uint8 {
|
|||||||
return s.id
|
return s.id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) GetEntityById(entityId uint32) *Entity {
|
func (s *Suite) GetEntityById(entityId uint32) IEntity {
|
||||||
return s.entityMap[entityId]
|
return s.entityMap[entityId]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Suite) GetAllEntity() map[uint32]*Entity {
|
func (s *Suite) GetAllEntity() map[uint32]IEntity {
|
||||||
return s.entityMap
|
return s.entityMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IEntity 场景实体抽象接口
|
||||||
|
type IEntity interface {
|
||||||
|
IsEntity()
|
||||||
|
GetId() uint32
|
||||||
|
GetScene() *Scene
|
||||||
|
GetLifeState() uint16
|
||||||
|
GetLastDieType() int32
|
||||||
|
GetPos() *model.Vector
|
||||||
|
GetRot() *model.Vector
|
||||||
|
GetMoveState() uint16
|
||||||
|
GetLastMoveSceneTimeMs() uint32
|
||||||
|
GetLastMoveReliableSeq() uint32
|
||||||
|
GetFightProp() map[uint32]float32
|
||||||
|
GetLevel() uint8
|
||||||
|
GetEntityType() uint8
|
||||||
|
GetConfigId() uint32
|
||||||
|
GetGroupId() uint32
|
||||||
|
GetVisionLevel() int
|
||||||
|
SetLifeState(lifeState uint16)
|
||||||
|
SetLastDieType(lastDieType int32)
|
||||||
|
SetPos(pos *model.Vector)
|
||||||
|
SetRot(rot *model.Vector)
|
||||||
|
SetMoveState(moveState uint16)
|
||||||
|
SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32)
|
||||||
|
SetLastMoveReliableSeq(lastMoveReliableSeq uint32)
|
||||||
|
SetFightProp(fightProp map[uint32]float32)
|
||||||
|
}
|
||||||
|
|
||||||
// Entity 场景实体数据结构
|
// Entity 场景实体数据结构
|
||||||
type Entity struct {
|
type Entity struct {
|
||||||
id uint32 // 实体id
|
id uint32 // 实体id
|
||||||
@@ -448,14 +479,12 @@ type Entity struct {
|
|||||||
fightProp map[uint32]float32 // 战斗属性
|
fightProp map[uint32]float32 // 战斗属性
|
||||||
level uint8 // 等级
|
level uint8 // 等级
|
||||||
entityType uint8 // 实体类型
|
entityType uint8 // 实体类型
|
||||||
// TODO 这堆东西变得有点答辩了 我觉得之后需要重构 做面向对象继承多态接口的设计
|
configId uint32 // LUA配置相关
|
||||||
avatarEntity *AvatarEntity
|
groupId uint32
|
||||||
monsterEntity *MonsterEntity
|
visionLevel int
|
||||||
npcEntity *NpcEntity
|
}
|
||||||
gadgetEntity *GadgetEntity
|
|
||||||
configId uint32 // LUA配置相关
|
func (e *Entity) IsEntity() {
|
||||||
groupId uint32
|
|
||||||
visionLevel int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) GetId() uint32 {
|
func (e *Entity) GetId() uint32 {
|
||||||
@@ -470,66 +499,34 @@ func (e *Entity) GetLifeState() uint16 {
|
|||||||
return e.lifeState
|
return e.lifeState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetLifeState(lifeState uint16) {
|
|
||||||
e.lifeState = lifeState
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetLastDieType() int32 {
|
func (e *Entity) GetLastDieType() int32 {
|
||||||
return e.lastDieType
|
return e.lastDieType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetLastDieType(lastDieType int32) {
|
|
||||||
e.lastDieType = lastDieType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetPos() *model.Vector {
|
func (e *Entity) GetPos() *model.Vector {
|
||||||
return &model.Vector{X: e.pos.X, Y: e.pos.Y, Z: e.pos.Z}
|
return &model.Vector{X: e.pos.X, Y: e.pos.Y, Z: e.pos.Z}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetPos(pos *model.Vector) {
|
|
||||||
e.pos.X, e.pos.Y, e.pos.Z = pos.X, pos.Y, pos.Z
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetRot() *model.Vector {
|
func (e *Entity) GetRot() *model.Vector {
|
||||||
return &model.Vector{X: e.rot.X, Y: e.rot.Y, Z: e.rot.Z}
|
return &model.Vector{X: e.rot.X, Y: e.rot.Y, Z: e.rot.Z}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetRot(rot *model.Vector) {
|
|
||||||
e.rot.X, e.rot.Y, e.rot.Z = rot.X, rot.Y, rot.Z
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetMoveState() uint16 {
|
func (e *Entity) GetMoveState() uint16 {
|
||||||
return e.moveState
|
return e.moveState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetMoveState(moveState uint16) {
|
|
||||||
e.moveState = moveState
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetLastMoveSceneTimeMs() uint32 {
|
func (e *Entity) GetLastMoveSceneTimeMs() uint32 {
|
||||||
return e.lastMoveSceneTimeMs
|
return e.lastMoveSceneTimeMs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32) {
|
|
||||||
e.lastMoveSceneTimeMs = lastMoveSceneTimeMs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetLastMoveReliableSeq() uint32 {
|
func (e *Entity) GetLastMoveReliableSeq() uint32 {
|
||||||
return e.lastMoveReliableSeq
|
return e.lastMoveReliableSeq
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetLastMoveReliableSeq(lastMoveReliableSeq uint32) {
|
|
||||||
e.lastMoveReliableSeq = lastMoveReliableSeq
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetFightProp() map[uint32]float32 {
|
func (e *Entity) GetFightProp() map[uint32]float32 {
|
||||||
return e.fightProp
|
return e.fightProp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) SetFightProp(fightProp map[uint32]float32) {
|
|
||||||
e.fightProp = fightProp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetLevel() uint8 {
|
func (e *Entity) GetLevel() uint8 {
|
||||||
return e.level
|
return e.level
|
||||||
}
|
}
|
||||||
@@ -538,22 +535,6 @@ func (e *Entity) GetEntityType() uint8 {
|
|||||||
return e.entityType
|
return e.entityType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Entity) GetAvatarEntity() *AvatarEntity {
|
|
||||||
return e.avatarEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetMonsterEntity() *MonsterEntity {
|
|
||||||
return e.monsterEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetNpcEntity() *NpcEntity {
|
|
||||||
return e.npcEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetGadgetEntity() *GadgetEntity {
|
|
||||||
return e.gadgetEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *Entity) GetConfigId() uint32 {
|
func (e *Entity) GetConfigId() uint32 {
|
||||||
return e.configId
|
return e.configId
|
||||||
}
|
}
|
||||||
@@ -566,7 +547,40 @@ func (e *Entity) GetVisionLevel() int {
|
|||||||
return e.visionLevel
|
return e.visionLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetLifeState(lifeState uint16) {
|
||||||
|
e.lifeState = lifeState
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetLastDieType(lastDieType int32) {
|
||||||
|
e.lastDieType = lastDieType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetPos(pos *model.Vector) {
|
||||||
|
e.pos.X, e.pos.Y, e.pos.Z = pos.X, pos.Y, pos.Z
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetRot(rot *model.Vector) {
|
||||||
|
e.rot.X, e.rot.Y, e.rot.Z = rot.X, rot.Y, rot.Z
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetMoveState(moveState uint16) {
|
||||||
|
e.moveState = moveState
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetLastMoveSceneTimeMs(lastMoveSceneTimeMs uint32) {
|
||||||
|
e.lastMoveSceneTimeMs = lastMoveSceneTimeMs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetLastMoveReliableSeq(lastMoveReliableSeq uint32) {
|
||||||
|
e.lastMoveReliableSeq = lastMoveReliableSeq
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Entity) SetFightProp(fightProp map[uint32]float32) {
|
||||||
|
e.fightProp = fightProp
|
||||||
|
}
|
||||||
|
|
||||||
type AvatarEntity struct {
|
type AvatarEntity struct {
|
||||||
|
*Entity
|
||||||
uid uint32
|
uid uint32
|
||||||
avatarId uint32
|
avatarId uint32
|
||||||
}
|
}
|
||||||
@@ -579,7 +593,12 @@ func (a *AvatarEntity) GetAvatarId() uint32 {
|
|||||||
return a.avatarId
|
return a.avatarId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WeaponEntity struct {
|
||||||
|
*Entity
|
||||||
|
}
|
||||||
|
|
||||||
type MonsterEntity struct {
|
type MonsterEntity struct {
|
||||||
|
*Entity
|
||||||
monsterId uint32
|
monsterId uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,6 +607,7 @@ func (m *MonsterEntity) GetMonsterId() uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NpcEntity struct {
|
type NpcEntity struct {
|
||||||
|
*Entity
|
||||||
npcId uint32
|
npcId uint32
|
||||||
roomId uint32
|
roomId uint32
|
||||||
parentQuestId uint32
|
parentQuestId uint32
|
||||||
@@ -610,23 +630,16 @@ func (n *NpcEntity) GetBlockId() uint32 {
|
|||||||
return n.blockId
|
return n.blockId
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
type IGadgetEntity interface {
|
||||||
GADGET_TYPE_NORMAL = iota
|
GetGadgetId() uint32
|
||||||
GADGET_TYPE_CLIENT
|
GetGadgetState() uint32
|
||||||
GADGET_TYPE_VEHICLE // 载具
|
SetGadgetState(state uint32)
|
||||||
)
|
|
||||||
|
|
||||||
type GadgetEntity struct {
|
|
||||||
gadgetType int
|
|
||||||
gadgetId uint32
|
|
||||||
gadgetState uint32
|
|
||||||
gadgetNormalEntity *GadgetNormalEntity
|
|
||||||
gadgetClientEntity *GadgetClientEntity
|
|
||||||
gadgetVehicleEntity *GadgetVehicleEntity
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetEntity) GetGadgetType() int {
|
type GadgetEntity struct {
|
||||||
return g.gadgetType
|
*Entity
|
||||||
|
gadgetId uint32
|
||||||
|
gadgetState uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetEntity) GetGadgetId() uint32 {
|
func (g *GadgetEntity) GetGadgetId() uint32 {
|
||||||
@@ -641,19 +654,8 @@ func (g *GadgetEntity) SetGadgetState(state uint32) {
|
|||||||
g.gadgetState = state
|
g.gadgetState = state
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetEntity) GetGadgetNormalEntity() *GadgetNormalEntity {
|
|
||||||
return g.gadgetNormalEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GadgetEntity) GetGadgetClientEntity() *GadgetClientEntity {
|
|
||||||
return g.gadgetClientEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GadgetEntity) GetGadgetVehicleEntity() *GadgetVehicleEntity {
|
|
||||||
return g.gadgetVehicleEntity
|
|
||||||
}
|
|
||||||
|
|
||||||
type GadgetNormalEntity struct {
|
type GadgetNormalEntity struct {
|
||||||
|
*GadgetEntity
|
||||||
isDrop bool
|
isDrop bool
|
||||||
itemId uint32
|
itemId uint32
|
||||||
count uint32
|
count uint32
|
||||||
@@ -672,7 +674,7 @@ func (g *GadgetNormalEntity) GetCount() uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GadgetClientEntity struct {
|
type GadgetClientEntity struct {
|
||||||
configId uint32
|
*GadgetEntity
|
||||||
campId uint32
|
campId uint32
|
||||||
campType uint32
|
campType uint32
|
||||||
ownerEntityId uint32
|
ownerEntityId uint32
|
||||||
@@ -680,10 +682,6 @@ type GadgetClientEntity struct {
|
|||||||
propOwnerEntityId uint32
|
propOwnerEntityId uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetClientEntity) GetConfigId() uint32 {
|
|
||||||
return g.configId
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GadgetClientEntity) GetCampId() uint32 {
|
func (g *GadgetClientEntity) GetCampId() uint32 {
|
||||||
return g.campId
|
return g.campId
|
||||||
}
|
}
|
||||||
@@ -705,13 +703,14 @@ func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GadgetVehicleEntity struct {
|
type GadgetVehicleEntity struct {
|
||||||
|
*GadgetEntity
|
||||||
vehicleId uint32
|
vehicleId uint32
|
||||||
worldId uint64
|
worldId uint64
|
||||||
ownerUid uint32
|
ownerUid uint32
|
||||||
maxStamina float32
|
maxStamina float32
|
||||||
curStamina float32
|
curStamina float32
|
||||||
restoreDelay uint8 // 载具耐力回复延时
|
restoreDelay uint8 // 载具耐力回复延时
|
||||||
memberMap map[uint32]*model.Player // uint32 = pos
|
memberMap map[uint32]uint32 // key:pos value:uid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
|
func (g *GadgetVehicleEntity) GetVehicleId() uint32 {
|
||||||
@@ -734,16 +733,16 @@ func (g *GadgetVehicleEntity) GetCurStamina() float32 {
|
|||||||
return g.curStamina
|
return g.curStamina
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
|
func (g *GadgetVehicleEntity) GetRestoreDelay() uint8 {
|
||||||
g.curStamina = curStamina
|
return g.restoreDelay
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetVehicleEntity) GetMemberMap() map[uint32]*model.Player {
|
func (g *GadgetVehicleEntity) GetMemberMap() map[uint32]uint32 {
|
||||||
return g.memberMap
|
return g.memberMap
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetVehicleEntity) GetRestoreDelay() uint8 {
|
func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
|
||||||
return g.restoreDelay
|
g.curStamina = curStamina
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GadgetVehicleEntity) SetRestoreDelay(restoreDelay uint8) {
|
func (g *GadgetVehicleEntity) SetRestoreDelay(restoreDelay uint8) {
|
||||||
|
|||||||
+15
-9
@@ -254,7 +254,8 @@ func GetGroupMonsterCount(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
monsterCount := 0
|
monsterCount := 0
|
||||||
for _, entity := range group.GetAllEntity() {
|
for _, entity := range group.GetAllEntity() {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
|
_, ok := entity.(*MonsterEntity)
|
||||||
|
if ok {
|
||||||
monsterCount++
|
monsterCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,7 +288,8 @@ func GetGroupMonsterCountByGroupId(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
monsterCount := 0
|
monsterCount := 0
|
||||||
for _, entity := range group.GetAllEntity() {
|
for _, entity := range group.GetAllEntity() {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
|
_, ok := entity.(*MonsterEntity)
|
||||||
|
if ok {
|
||||||
monsterCount++
|
monsterCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,7 +328,8 @@ func CheckRemainGadgetCountByGroupId(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
gadgetCount := 0
|
gadgetCount := 0
|
||||||
for _, entity := range group.GetAllEntity() {
|
for _, entity := range group.GetAllEntity() {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_GADGET {
|
_, ok := entity.(IGadgetEntity)
|
||||||
|
if ok {
|
||||||
gadgetCount++
|
gadgetCount++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,12 +399,12 @@ func GetGadgetStateByConfigId(luaState *lua.LState) int {
|
|||||||
luaState.Push(lua.LNumber(-1))
|
luaState.Push(lua.LNumber(-1))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||||
|
if !ok {
|
||||||
luaState.Push(lua.LNumber(-1))
|
luaState.Push(lua.LNumber(-1))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
luaState.Push(lua.LNumber(iGadgetEntity.GetGadgetState()))
|
||||||
luaState.Push(lua.LNumber(gadgetEntity.GetGadgetState()))
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,21 +961,24 @@ func KillGroupEntity(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
case constant.GROUP_KILL_MONSTER:
|
case constant.GROUP_KILL_MONSTER:
|
||||||
for _, entity := range entityMap {
|
for _, entity := range entityMap {
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_MONSTER {
|
_, ok := entity.(*MonsterEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
}
|
}
|
||||||
case constant.GROUP_KILL_NPC:
|
case constant.GROUP_KILL_NPC:
|
||||||
for _, entity := range entityMap {
|
for _, entity := range entityMap {
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_NPC {
|
_, ok := entity.(*NpcEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
}
|
}
|
||||||
case constant.GROUP_KILL_GADGET:
|
case constant.GROUP_KILL_GADGET:
|
||||||
for _, entity := range entityMap {
|
for _, entity := range entityMap {
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
_, ok := entity.(IGadgetEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
GAME.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ func (g *Game) SubPlayerAvatarHp(userId uint32, avatarId uint32, value float32,
|
|||||||
default:
|
default:
|
||||||
dieType = proto.PlayerDieType_PLAYER_DIE_GM
|
dieType = proto.PlayerDieType_PLAYER_DIE_GM
|
||||||
}
|
}
|
||||||
g.KillPlayerAvatar(player, entity.GetAvatarEntity().GetAvatarId(), dieType)
|
g.KillPlayerAvatar(player, entity.(*AvatarEntity).GetAvatarId(), dieType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ func (g *Game) ScenePlayerLocationNotify(world *World) {
|
|||||||
for _, entityId := range scenePlayer.VehicleInfo.CreateEntityIdMap {
|
for _, entityId := range scenePlayer.VehicleInfo.CreateEntityIdMap {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
// 确保实体类型是否为载具
|
// 确保实体类型是否为载具
|
||||||
if entity != nil && entity.GetEntityType() == constant.ENTITY_TYPE_GADGET && entity.GetGadgetEntity().GetGadgetVehicleEntity() != nil {
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
|
if ok {
|
||||||
vehicleLocationInfo := &proto.VehicleLocationInfo{
|
vehicleLocationInfo := &proto.VehicleLocationInfo{
|
||||||
Rot: &proto.Vector{
|
Rot: &proto.Vector{
|
||||||
X: float32(entity.GetRot().X),
|
X: float32(entity.GetRot().X),
|
||||||
@@ -189,18 +190,18 @@ func (g *Game) ScenePlayerLocationNotify(world *World) {
|
|||||||
},
|
},
|
||||||
EntityId: entity.GetId(),
|
EntityId: entity.GetId(),
|
||||||
CurHp: entity.GetFightProp()[constant.FIGHT_PROP_CUR_HP],
|
CurHp: entity.GetFightProp()[constant.FIGHT_PROP_CUR_HP],
|
||||||
OwnerUid: entity.GetGadgetEntity().GetGadgetVehicleEntity().GetOwnerUid(),
|
OwnerUid: gadgetVehicleEntity.GetOwnerUid(),
|
||||||
Pos: &proto.Vector{
|
Pos: &proto.Vector{
|
||||||
X: float32(entity.GetPos().X),
|
X: float32(entity.GetPos().X),
|
||||||
Y: float32(entity.GetPos().Y),
|
Y: float32(entity.GetPos().Y),
|
||||||
Z: float32(entity.GetPos().Z),
|
Z: float32(entity.GetPos().Z),
|
||||||
},
|
},
|
||||||
UidList: make([]uint32, 0, len(entity.GetGadgetEntity().GetGadgetVehicleEntity().GetMemberMap())),
|
UidList: make([]uint32, 0, len(gadgetVehicleEntity.GetMemberMap())),
|
||||||
GadgetId: entity.GetGadgetEntity().GetGadgetVehicleEntity().GetVehicleId(),
|
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
||||||
MaxHp: entity.GetFightProp()[constant.FIGHT_PROP_MAX_HP],
|
MaxHp: entity.GetFightProp()[constant.FIGHT_PROP_MAX_HP],
|
||||||
}
|
}
|
||||||
for _, p := range entity.GetGadgetEntity().GetGadgetVehicleEntity().GetMemberMap() {
|
for _, uid := range gadgetVehicleEntity.GetMemberMap() {
|
||||||
vehicleLocationInfo.UidList = append(vehicleLocationInfo.UidList, p.PlayerId)
|
vehicleLocationInfo.UidList = append(vehicleLocationInfo.UidList, uid)
|
||||||
}
|
}
|
||||||
ntf.VehicleLocList = append(ntf.VehicleLocList, vehicleLocationInfo)
|
ntf.VehicleLocList = append(ntf.VehicleLocList, vehicleLocationInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
|||||||
// logger.Error("not found def entity, DefenseId: %v", attackResult.DefenseId)
|
// logger.Error("not found def entity, DefenseId: %v", attackResult.DefenseId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch defEntity.GetEntityType() {
|
switch defEntity.(type) {
|
||||||
case constant.ENTITY_TYPE_AVATAR:
|
case *AvatarEntity:
|
||||||
g.SubPlayerAvatarHp(player.PlayerId, defEntity.GetAvatarEntity().GetAvatarId(), attackResult.Damage, false, proto.ChangHpReason_CHANGE_HP_SUB_MONSTER)
|
g.SubPlayerAvatarHp(player.PlayerId, defEntity.(*AvatarEntity).GetAvatarId(), attackResult.Damage, false, proto.ChangHpReason_CHANGE_HP_SUB_MONSTER)
|
||||||
case constant.ENTITY_TYPE_MONSTER:
|
case *MonsterEntity:
|
||||||
if scene.GetMonsterWudi() {
|
if scene.GetMonsterWudi() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -217,9 +217,9 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
|||||||
if defEntity.GetGroupId() == 0 {
|
if defEntity.GetGroupId() == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
monsterDataConfig := gdconf.GetMonsterDataById(int32(defEntity.GetMonsterEntity().GetMonsterId()))
|
monsterDataConfig := gdconf.GetMonsterDataById(int32(defEntity.(*MonsterEntity).GetMonsterId()))
|
||||||
if monsterDataConfig == nil {
|
if monsterDataConfig == nil {
|
||||||
logger.Error("get monster data config is nil, monsterId: %v", defEntity.GetMonsterEntity().GetMonsterId())
|
logger.Error("get monster data config is nil, monsterId: %v", defEntity.(*MonsterEntity).GetMonsterId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
lastHpPercent := lastHp / maxHp * 100.0
|
lastHpPercent := lastHp / maxHp * 100.0
|
||||||
@@ -229,9 +229,8 @@ func (g *Game) handleEvtBeingHit(player *model.Player, scene *Scene, hitInfo *pr
|
|||||||
g.monsterDrop(player, MonsterDropTypeHp, hpDrop.Id, defEntity)
|
g.monsterDrop(player, MonsterDropTypeHp, hpDrop.Id, defEntity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case IGadgetEntity:
|
||||||
gadgetEntity := defEntity.GetGadgetEntity()
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(defEntity.(IGadgetEntity).GetGadgetId()))
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
// logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
// logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
||||||
return
|
return
|
||||||
@@ -246,9 +245,9 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
|
|||||||
if entity == nil {
|
if entity == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
avatarEntity, ok := entity.(*AvatarEntity)
|
||||||
|
if ok {
|
||||||
// 玩家实体在移动
|
// 玩家实体在移动
|
||||||
avatarEntity := entity.GetAvatarEntity()
|
|
||||||
if avatarEntity.GetUid() != player.PlayerId {
|
if avatarEntity.GetUid() != player.PlayerId {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -301,8 +300,8 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
|
|||||||
entity.SetRot(rot)
|
entity.SetRot(rot)
|
||||||
if !force {
|
if !force {
|
||||||
motionInfo := moveInfo.MotionInfo
|
motionInfo := moveInfo.MotionInfo
|
||||||
switch entity.GetEntityType() {
|
switch entity.(type) {
|
||||||
case constant.ENTITY_TYPE_AVATAR:
|
case *AvatarEntity:
|
||||||
switch motionInfo.State {
|
switch motionInfo.State {
|
||||||
case proto.MotionState_MOTION_STANDBY, proto.MotionState_MOTION_WALK, proto.MotionState_MOTION_RUN, proto.MotionState_MOTION_DASH,
|
case proto.MotionState_MOTION_STANDBY, proto.MotionState_MOTION_WALK, proto.MotionState_MOTION_RUN, proto.MotionState_MOTION_DASH,
|
||||||
58, 59, 60, 64, 65, 66:
|
58, 59, 60, 64, 65, 66:
|
||||||
@@ -337,13 +336,13 @@ func (g *Game) handleEntityMove(player *model.Player, world *World, scene *Scene
|
|||||||
}
|
}
|
||||||
fightProp := entity.GetFightProp()
|
fightProp := entity.GetFightProp()
|
||||||
maxHp := fightProp[constant.FIGHT_PROP_MAX_HP]
|
maxHp := fightProp[constant.FIGHT_PROP_MAX_HP]
|
||||||
g.SubPlayerAvatarHp(player.PlayerId, entity.GetAvatarEntity().GetAvatarId(), maxHp*rate, false, proto.ChangHpReason_CHANGE_HP_SUB_FALL)
|
g.SubPlayerAvatarHp(player.PlayerId, avatarEntity.GetAvatarId(), maxHp*rate, false, proto.ChangHpReason_CHANGE_HP_SUB_FALL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.Speed = &model.Vector{X: float64(motionInfo.Speed.X), Y: float64(motionInfo.Speed.Y), Z: float64(motionInfo.Speed.Z)}
|
player.Speed = &model.Vector{X: float64(motionInfo.Speed.X), Y: float64(motionInfo.Speed.Y), Z: float64(motionInfo.Speed.Z)}
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case IGadgetEntity:
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
_, ok := entity.(*GadgetVehicleEntity)
|
||||||
if gadgetEntity.GetGadgetVehicleEntity() != nil {
|
if ok {
|
||||||
// 处理耐力消耗
|
// 处理耐力消耗
|
||||||
g.ImmediateStamina(player, motionInfo.State)
|
g.ImmediateStamina(player, motionInfo.State)
|
||||||
// 处理载具销毁请求
|
// 处理载具销毁请求
|
||||||
@@ -418,12 +417,13 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
|||||||
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
g.RemoveSceneEntityNotifyToPlayer(player, proto.VisionType_VISION_MISS, delEntityIdList)
|
||||||
for _, delEntityId := range delEntityIdList {
|
for _, delEntityId := range delEntityIdList {
|
||||||
entity := scene.GetEntity(delEntityId)
|
entity := scene.GetEntity(delEntityId)
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
avatarEntity, ok := entity.(*AvatarEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
otherPlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
otherPlayer := USER_MANAGER.GetOnlineUser(avatarEntity.GetUid())
|
||||||
if otherPlayer == nil {
|
if otherPlayer == nil {
|
||||||
logger.Error("get player is nil, target uid: %v, uid: %v", entity.GetAvatarEntity().GetUid(), player.PlayerId)
|
logger.Error("get player is nil, target uid: %v, uid: %v", avatarEntity.GetUid(), player.PlayerId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{avatarEntityId})
|
g.RemoveSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MISS, []uint32{avatarEntityId})
|
||||||
@@ -433,15 +433,16 @@ func (g *Game) SceneBlockAoiPlayerMove(player *model.Player, world *World, scene
|
|||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_MEET, addEntityIdList, false, false)
|
||||||
for _, addEntityId := range addEntityIdList {
|
for _, addEntityId := range addEntityIdList {
|
||||||
entity := scene.GetEntity(addEntityId)
|
entity := scene.GetEntity(addEntityId)
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_AVATAR {
|
avatarEntity, ok := entity.(*AvatarEntity)
|
||||||
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
otherPlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
otherPlayer := USER_MANAGER.GetOnlineUser(avatarEntity.GetUid())
|
||||||
if otherPlayer == nil {
|
if otherPlayer == nil {
|
||||||
logger.Error("get player is nil, target uid: %v, uid: %v", entity.GetAvatarEntity().GetUid(), player.PlayerId)
|
logger.Error("get player is nil, target uid: %v, uid: %v", avatarEntity.GetUid(), player.PlayerId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, scene.GetEntity(avatarEntityId).GetAvatarEntity().GetAvatarId())
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, player, scene.GetEntity(avatarEntityId).(*AvatarEntity).GetAvatarId())
|
||||||
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
g.AddSceneEntityNotifyToPlayer(otherPlayer, proto.VisionType_VISION_MEET, []*proto.SceneEntityInfo{sceneEntityInfoAvatar})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -553,7 +554,8 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
|||||||
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
newVisionEntityMap := g.GetVisionEntity(scene, newPos)
|
||||||
delEntityIdList := make([]uint32, 0)
|
delEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range oldVisionEntityMap {
|
for entityId, entity := range oldVisionEntityMap {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
_, ok := entity.(*AvatarEntity)
|
||||||
|
if ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, exist := newVisionEntityMap[entityId]
|
_, exist := newVisionEntityMap[entityId]
|
||||||
@@ -565,7 +567,8 @@ func (g *Game) AiWorldAoiPlayerMove(player *model.Player, world *World, scene *S
|
|||||||
}
|
}
|
||||||
addEntityIdList := make([]uint32, 0)
|
addEntityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range newVisionEntityMap {
|
for entityId, entity := range newVisionEntityMap {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
_, ok := entity.(*AvatarEntity)
|
||||||
|
if ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
_, exist := oldVisionEntityMap[entityId]
|
_, exist := oldVisionEntityMap[entityId]
|
||||||
@@ -980,20 +983,20 @@ func (g *Game) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Message) {
|
|||||||
|
|
||||||
// TODO 一些很low的解决方案 我本来是不想写的 有多low?要多low有多low!
|
// TODO 一些很low的解决方案 我本来是不想写的 有多low?要多low有多low!
|
||||||
|
|
||||||
func (g *Game) handleGadgetEntityBeHitLow(player *model.Player, entity *Entity, hitElementType uint32) {
|
func (g *Game) handleGadgetEntityBeHitLow(player *model.Player, entity IEntity, hitElementType uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.GetSceneId())
|
scene := world.GetSceneById(player.GetSceneId())
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||||
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetId := iGadgetEntity.GetGadgetId()
|
||||||
gadgetId := gadgetEntity.GetGadgetId()
|
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.Contains(gadgetDataConfig.Name, "火把") ||
|
if strings.Contains(gadgetDataConfig.Name, "火把") ||
|
||||||
@@ -1052,17 +1055,17 @@ func (g *Game) handleGadgetEntityAbilityLow(player *model.Player, entityId uint3
|
|||||||
if modifierChange.Action != proto.ModifierAction_REMOVED {
|
if modifierChange.Action != proto.ModifierAction_REMOVED {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||||
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetId := iGadgetEntity.GetGadgetId()
|
||||||
gadgetId := gadgetEntity.GetGadgetId()
|
|
||||||
if gadgetId == 0 {
|
if gadgetId == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetId))
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if strings.Contains(gadgetDataConfig.Name, "碎石堆") ||
|
if strings.Contains(gadgetDataConfig.Name, "碎石堆") ||
|
||||||
|
|||||||
+61
-66
@@ -379,7 +379,8 @@ func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
entityIdList := make([]uint32, 0)
|
entityIdList := make([]uint32, 0)
|
||||||
for entityId, entity := range visionEntityMap {
|
for entityId, entity := range visionEntityMap {
|
||||||
if WORLD_MANAGER.IsAiWorld(world) {
|
if WORLD_MANAGER.IsAiWorld(world) {
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
_, ok := entity.(*AvatarEntity)
|
||||||
|
if ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,26 +754,27 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
|
|||||||
logger.Error("get entity is nil, entityId: %v", entityId)
|
logger.Error("get entity is nil, entityId: %v", entityId)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch entity.GetEntityType() {
|
switch entity.(type) {
|
||||||
case constant.ENTITY_TYPE_AVATAR:
|
case *AvatarEntity:
|
||||||
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
avatarEntity := entity.(*AvatarEntity)
|
||||||
|
scenePlayer := USER_MANAGER.GetOnlineUser(avatarEntity.GetUid())
|
||||||
if scenePlayer == nil {
|
if scenePlayer == nil {
|
||||||
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
|
logger.Error("get scene player is nil, world id: %v, scene id: %v", world.GetId(), scene.GetId())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
sceneEntityInfoAvatar := g.PacketSceneEntityInfoAvatar(scene, scenePlayer, world.GetPlayerActiveAvatarId(scenePlayer))
|
||||||
entityList = append(entityList, sceneEntityInfoAvatar)
|
entityList = append(entityList, sceneEntityInfoAvatar)
|
||||||
case constant.ENTITY_TYPE_MONSTER:
|
case *MonsterEntity:
|
||||||
sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.GetId())
|
sceneEntityInfoMonster := g.PacketSceneEntityInfoMonster(scene, entity.GetId())
|
||||||
entityList = append(entityList, sceneEntityInfoMonster)
|
entityList = append(entityList, sceneEntityInfoMonster)
|
||||||
case constant.ENTITY_TYPE_NPC:
|
case *NpcEntity:
|
||||||
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
|
sceneEntityInfoNpc := g.PacketSceneEntityInfoNpc(scene, entity.GetId())
|
||||||
entityList = append(entityList, sceneEntityInfoNpc)
|
entityList = append(entityList, sceneEntityInfoNpc)
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case IGadgetEntity:
|
||||||
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(player, scene, entity.GetId())
|
sceneEntityInfoGadget := g.PacketSceneEntityInfoGadget(player, scene, entity.GetId())
|
||||||
entityList = append(entityList, sceneEntityInfoGadget)
|
entityList = append(entityList, sceneEntityInfoGadget)
|
||||||
default:
|
default:
|
||||||
logger.Error("not support entity type: %v, stack: %v", entity.GetEntityType(), logger.Stack())
|
logger.Error("not support entity: %v, stack: %v", entity, logger.Stack())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,7 +791,7 @@ func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.Visio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EntityFightPropUpdateNotifyBroadcast 场景实体战斗属性变更通知广播
|
// EntityFightPropUpdateNotifyBroadcast 场景实体战斗属性变更通知广播
|
||||||
func (g *Game) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity *Entity) {
|
func (g *Game) EntityFightPropUpdateNotifyBroadcast(scene *Scene, entity IEntity) {
|
||||||
ntf := &proto.EntityFightPropUpdateNotify{
|
ntf := &proto.EntityFightPropUpdateNotify{
|
||||||
FightPropMap: entity.GetFightProp(),
|
FightPropMap: entity.GetFightProp(),
|
||||||
EntityId: entity.GetId(),
|
EntityId: entity.GetId(),
|
||||||
@@ -890,7 +892,8 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
|||||||
}
|
}
|
||||||
g.SendToSceneA(scene, cmd.LifeStateChangeNotify, 0, ntf, 0)
|
g.SendToSceneA(scene, cmd.LifeStateChangeNotify, 0, ntf, 0)
|
||||||
|
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
_, ok := entity.(*AvatarEntity)
|
||||||
|
if ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,13 +916,13 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
|||||||
|
|
||||||
group.DestroyEntity(entity.GetId())
|
group.DestroyEntity(entity.GetId())
|
||||||
|
|
||||||
switch entity.GetEntityType() {
|
switch entity.(type) {
|
||||||
case constant.ENTITY_TYPE_MONSTER:
|
case *MonsterEntity:
|
||||||
// 随机掉落
|
// 随机掉落
|
||||||
g.monsterDrop(player, MonsterDropTypeKill, 0, entity)
|
g.monsterDrop(player, MonsterDropTypeKill, 0, entity)
|
||||||
// 怪物死亡触发器检测
|
// 怪物死亡触发器检测
|
||||||
g.MonsterDieTriggerCheck(player, group)
|
g.MonsterDieTriggerCheck(player, group)
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case IGadgetEntity:
|
||||||
// 物件死亡触发器检测
|
// 物件死亡触发器检测
|
||||||
g.GadgetDieTriggerCheck(player, group, entity.GetConfigId())
|
g.GadgetDieTriggerCheck(player, group, entity.GetConfigId())
|
||||||
}
|
}
|
||||||
@@ -937,15 +940,15 @@ func (g *Game) ChangeGadgetState(player *model.Player, entityId uint32, state ui
|
|||||||
logger.Error("get entity is nil, entityId: %v", entityId)
|
logger.Error("get entity is nil, entityId: %v", entityId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||||
|
if !ok {
|
||||||
logger.Error("entity is not gadget, entityId: %v", entityId)
|
logger.Error("entity is not gadget, entityId: %v", entityId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
iGadgetEntity.SetGadgetState(state)
|
||||||
gadgetEntity.SetGadgetState(state)
|
|
||||||
ntf := &proto.GadgetStateNotify{
|
ntf := &proto.GadgetStateNotify{
|
||||||
GadgetEntityId: entity.GetId(),
|
GadgetEntityId: entity.GetId(),
|
||||||
GadgetState: gadgetEntity.GetGadgetState(),
|
GadgetState: iGadgetEntity.GetGadgetState(),
|
||||||
IsEnableInteract: true,
|
IsEnableInteract: true,
|
||||||
}
|
}
|
||||||
g.SendMsg(cmd.GadgetStateNotify, player.PlayerId, player.ClientSeq, ntf)
|
g.SendMsg(cmd.GadgetStateNotify, player.PlayerId, player.ClientSeq, ntf)
|
||||||
@@ -962,31 +965,33 @@ func (g *Game) ChangeGadgetState(player *model.Player, entityId uint32, state ui
|
|||||||
if sceneGroup == nil {
|
if sceneGroup == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sceneGroup.ChangeGadgetState(entity.GetConfigId(), uint8(gadgetEntity.GetGadgetState()))
|
sceneGroup.ChangeGadgetState(entity.GetConfigId(), uint8(iGadgetEntity.GetGadgetState()))
|
||||||
|
|
||||||
// 物件状态变更触发器检测
|
// 物件状态变更触发器检测
|
||||||
g.GadgetStateChangeTriggerCheck(player, group, entity.GetConfigId(), uint8(gadgetEntity.GetGadgetState()))
|
g.GadgetStateChangeTriggerCheck(player, group, entity.GetConfigId(), uint8(iGadgetEntity.GetGadgetState()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetVisionEntity 获取某位置视野内的全部实体
|
// GetVisionEntity 获取某位置视野内的全部实体
|
||||||
func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Entity {
|
func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]IEntity {
|
||||||
allEntityMap := scene.GetAllEntity()
|
allEntityMap := scene.GetAllEntity()
|
||||||
visionEntity := make(map[uint32]*Entity)
|
visionEntity := make(map[uint32]IEntity)
|
||||||
for _, entity := range allEntityMap {
|
for _, entity := range allEntityMap {
|
||||||
if !g.IsInVision(pos, entity.GetPos(), entity.GetVisionLevel()) {
|
if !g.IsInVision(pos, entity.GetPos(), entity.GetVisionLevel()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_AVATAR {
|
avatarEntity, ok := entity.(*AvatarEntity)
|
||||||
scenePlayer := USER_MANAGER.GetOnlineUser(entity.GetAvatarEntity().GetUid())
|
if ok {
|
||||||
|
scenePlayer := USER_MANAGER.GetOnlineUser(avatarEntity.GetUid())
|
||||||
if scenePlayer == nil {
|
if scenePlayer == nil {
|
||||||
logger.Error("get scene player is nil, target uid: %v", entity.GetAvatarEntity().GetUid())
|
logger.Error("get scene player is nil, target uid: %v", avatarEntity.GetUid())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !scene.GetWorld().IsPlayerActiveAvatarEntity(scenePlayer, entity.GetId()) {
|
if !scene.GetWorld().IsPlayerActiveAvatarEntity(scenePlayer, entity.GetId()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_WEAPON {
|
_, ok = entity.(*WeaponEntity)
|
||||||
|
if ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
visionEntity[entity.GetId()] = entity
|
visionEntity[entity.GetId()] = entity
|
||||||
@@ -1214,7 +1219,7 @@ func (g *Game) AddSceneGroupSuiteCore(player *model.Player, scene *Scene, groupI
|
|||||||
if sceneGroup == nil {
|
if sceneGroup == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
entityMap := make(map[uint32]*Entity)
|
entityMap := make(map[uint32]IEntity)
|
||||||
for _, monsterConfigId := range suiteConfig.MonsterConfigIdList {
|
for _, monsterConfigId := range suiteConfig.MonsterConfigIdList {
|
||||||
monsterConfig, exist := groupConfig.MonsterMap[monsterConfigId]
|
monsterConfig, exist := groupConfig.MonsterMap[monsterConfigId]
|
||||||
if !exist {
|
if !exist {
|
||||||
@@ -1302,11 +1307,9 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
|
|||||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||||
uint32(gatherDataConfig.GadgetId),
|
uint32(gatherDataConfig.GadgetId),
|
||||||
uint32(constant.GADGET_STATE_DEFAULT),
|
uint32(constant.GADGET_STATE_DEFAULT),
|
||||||
&GadgetNormalEntity{
|
false,
|
||||||
isDrop: false,
|
uint32(gatherDataConfig.ItemId),
|
||||||
itemId: uint32(gatherDataConfig.ItemId),
|
1,
|
||||||
count: 1,
|
|
||||||
},
|
|
||||||
uint32(gadget.ConfigId),
|
uint32(gadget.ConfigId),
|
||||||
groupId,
|
groupId,
|
||||||
int(gadget.VisionLevel),
|
int(gadget.VisionLevel),
|
||||||
@@ -1322,7 +1325,9 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
|
|||||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||||
uint32(gadget.GadgetId),
|
uint32(gadget.GadgetId),
|
||||||
uint32(state),
|
uint32(state),
|
||||||
new(GadgetNormalEntity),
|
false,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
uint32(gadget.ConfigId),
|
uint32(gadget.ConfigId),
|
||||||
groupId,
|
groupId,
|
||||||
int(gadget.VisionLevel),
|
int(gadget.VisionLevel),
|
||||||
@@ -1378,7 +1383,7 @@ func (g *Game) SceneGroupCreateEntity(player *model.Player, groupId uint32, conf
|
|||||||
}
|
}
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
// 实体添加到场景小组
|
// 实体添加到场景小组
|
||||||
scene.AddGroupSuite(groupId, uint8(initSuiteId), map[uint32]*Entity{entity.GetId(): entity})
|
scene.AddGroupSuite(groupId, uint8(initSuiteId), map[uint32]IEntity{entity.GetId(): entity})
|
||||||
// 通知客户端
|
// 通知客户端
|
||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||||
// 触发器检测
|
// 触发器检测
|
||||||
@@ -1423,24 +1428,16 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
|||||||
if entity == nil {
|
if entity == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
entity.level = level
|
|
||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||||
return entityId
|
return entityId
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateGadget 创建物件实体
|
// CreateGadget 创建物件实体
|
||||||
func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId uint32, normalEntity *GadgetNormalEntity) uint32 {
|
func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId uint32, isDrop bool, itemId, count uint32) uint32 {
|
||||||
if gadgetId == 0 {
|
if gadgetId == 0 {
|
||||||
logger.Error("create gadget id is zero, pos: %+v, normalEntity: %+v, uid: %v", pos, normalEntity, player.PlayerId)
|
logger.Error("create gadget id is zero, pos: %+v, isDrop: %v, itemId: %v, count: %v, uid: %v", pos, isDrop, itemId, count, player.PlayerId)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if normalEntity == nil {
|
|
||||||
normalEntity = &GadgetNormalEntity{
|
|
||||||
isDrop: false,
|
|
||||||
itemId: 0,
|
|
||||||
count: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
return 0
|
return 0
|
||||||
@@ -1455,7 +1452,7 @@ func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId ui
|
|||||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||||
entityId := scene.CreateEntityGadgetNormal(
|
entityId := scene.CreateEntityGadgetNormal(
|
||||||
pos, rot,
|
pos, rot,
|
||||||
gadgetId, constant.GADGET_STATE_DEFAULT, normalEntity,
|
gadgetId, constant.GADGET_STATE_DEFAULT, isDrop, itemId, count,
|
||||||
0, 0, constant.VISION_LEVEL_NORMAL,
|
0, 0, constant.VISION_LEVEL_NORMAL,
|
||||||
)
|
)
|
||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||||
@@ -1464,11 +1461,7 @@ func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId ui
|
|||||||
|
|
||||||
// CreateDropGadget 创建掉落物的物件实体
|
// CreateDropGadget 创建掉落物的物件实体
|
||||||
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) uint32 {
|
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) uint32 {
|
||||||
entityId := g.CreateGadget(player, pos, gadgetId, &GadgetNormalEntity{
|
entityId := g.CreateGadget(player, pos, gadgetId, true, itemId, count)
|
||||||
isDrop: true,
|
|
||||||
itemId: itemId,
|
|
||||||
count: count,
|
|
||||||
})
|
|
||||||
return entityId
|
return entityId
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1915,7 +1908,7 @@ func (g *Game) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *proto.Sc
|
|||||||
LifeState: uint32(entity.GetLifeState()),
|
LifeState: uint32(entity.GetLifeState()),
|
||||||
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
|
AnimatorParaList: make([]*proto.AnimatorParameterValueInfoPair, 0),
|
||||||
Entity: &proto.SceneEntityInfo_Npc{
|
Entity: &proto.SceneEntityInfo_Npc{
|
||||||
Npc: g.PacketSceneNpcInfo(entity.GetNpcEntity()),
|
Npc: g.PacketSceneNpcInfo(entity.(*NpcEntity)),
|
||||||
},
|
},
|
||||||
EntityClientData: new(proto.EntityClientData),
|
EntityClientData: new(proto.EntityClientData),
|
||||||
EntityAuthorityInfo: &proto.EntityAuthorityInfo{
|
EntityAuthorityInfo: &proto.EntityAuthorityInfo{
|
||||||
@@ -1971,19 +1964,18 @@ func (g *Game) PacketSceneEntityInfoGadget(player *model.Player, scene *Scene, e
|
|||||||
BornPos: pos,
|
BornPos: pos,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
switch entity.(type) {
|
||||||
switch gadgetEntity.GetGadgetType() {
|
case *GadgetNormalEntity:
|
||||||
case GADGET_TYPE_NORMAL:
|
|
||||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||||
Gadget: g.PacketSceneGadgetInfoNormal(player, entity),
|
Gadget: g.PacketSceneGadgetInfoNormal(player, entity),
|
||||||
}
|
}
|
||||||
case GADGET_TYPE_CLIENT:
|
case *GadgetClientEntity:
|
||||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||||
Gadget: g.PacketSceneGadgetInfoClient(gadgetEntity.GetGadgetClientEntity()),
|
Gadget: g.PacketSceneGadgetInfoClient(entity.(*GadgetClientEntity)),
|
||||||
}
|
}
|
||||||
case GADGET_TYPE_VEHICLE:
|
case *GadgetVehicleEntity:
|
||||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||||
Gadget: g.PacketSceneGadgetInfoVehicle(gadgetEntity.GetGadgetVehicleEntity()),
|
Gadget: g.PacketSceneGadgetInfoVehicle(entity.(*GadgetVehicleEntity)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
@@ -2038,14 +2030,14 @@ func (g *Game) PacketSceneAvatarInfo(scene *Scene, player *model.Player, avatarI
|
|||||||
return sceneAvatarInfo
|
return sceneAvatarInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo {
|
func (g *Game) PacketSceneMonsterInfo(entity IEntity) *proto.SceneMonsterInfo {
|
||||||
blockId := uint32(0)
|
blockId := uint32(0)
|
||||||
if entity.GetGroupId() != 0 {
|
if entity.GetGroupId() != 0 {
|
||||||
groupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
groupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||||
blockId = uint32(groupConfig.BlockId)
|
blockId = uint32(groupConfig.BlockId)
|
||||||
}
|
}
|
||||||
sceneMonsterInfo := &proto.SceneMonsterInfo{
|
sceneMonsterInfo := &proto.SceneMonsterInfo{
|
||||||
MonsterId: entity.GetMonsterEntity().GetMonsterId(),
|
MonsterId: entity.(*MonsterEntity).GetMonsterId(),
|
||||||
AuthorityPeerId: 1,
|
AuthorityPeerId: 1,
|
||||||
BornType: proto.MonsterBornType_MONSTER_BORN_DEFAULT,
|
BornType: proto.MonsterBornType_MONSTER_BORN_DEFAULT,
|
||||||
BlockId: blockId,
|
BlockId: blockId,
|
||||||
@@ -2065,22 +2057,25 @@ func (g *Game) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo {
|
|||||||
return sceneNpcInfo
|
return sceneNpcInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) PacketSceneGadgetInfoNormal(player *model.Player, entity *Entity) *proto.SceneGadgetInfo {
|
func (g *Game) PacketSceneGadgetInfoNormal(player *model.Player, entity IEntity) *proto.SceneGadgetInfo {
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
if !ok {
|
||||||
|
return new(proto.SceneGadgetInfo)
|
||||||
|
}
|
||||||
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(iGadgetEntity.GetGadgetId()))
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadgetEntity.GetGadgetId())
|
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||||
return new(proto.SceneGadgetInfo)
|
return new(proto.SceneGadgetInfo)
|
||||||
}
|
}
|
||||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||||
GadgetId: gadgetEntity.GetGadgetId(),
|
GadgetId: iGadgetEntity.GetGadgetId(),
|
||||||
GroupId: entity.GetGroupId(),
|
GroupId: entity.GetGroupId(),
|
||||||
ConfigId: entity.GetConfigId(),
|
ConfigId: entity.GetConfigId(),
|
||||||
GadgetState: gadgetEntity.GetGadgetState(),
|
GadgetState: iGadgetEntity.GetGadgetState(),
|
||||||
IsEnableInteract: true,
|
IsEnableInteract: true,
|
||||||
AuthorityPeerId: 1,
|
AuthorityPeerId: 1,
|
||||||
}
|
}
|
||||||
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||||
if gadgetNormalEntity.GetIsDrop() {
|
if gadgetNormalEntity.GetIsDrop() {
|
||||||
dbItem := player.GetDbItem()
|
dbItem := player.GetDbItem()
|
||||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
||||||
|
|||||||
+26
-20
@@ -181,20 +181,20 @@ func (g *Game) RestoreCountStaminaHandler(player *model.Player) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 确保实体类型是否为载具
|
// 确保实体类型是否为载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 获取载具配置表
|
// 获取载具配置表
|
||||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetEntity.GetGadgetVehicleEntity().GetVehicleId()))
|
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||||
if vehicleDataConfig == nil {
|
if vehicleDataConfig == nil {
|
||||||
logger.Error("vehicle config error, vehicleId: %v", gadgetEntity.GetGadgetVehicleEntity().GetVehicleId())
|
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
restoreDelay := gadgetEntity.GetGadgetVehicleEntity().GetRestoreDelay()
|
restoreDelay := gadgetVehicleEntity.GetRestoreDelay()
|
||||||
// 做个限制不然一直加就panic了
|
// 做个限制不然一直加就panic了
|
||||||
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) {
|
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) {
|
||||||
gadgetEntity.GetGadgetVehicleEntity().SetRestoreDelay(restoreDelay + 1)
|
gadgetVehicleEntity.SetRestoreDelay(restoreDelay + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 处理玩家
|
// 处理玩家
|
||||||
@@ -276,40 +276,43 @@ func (g *Game) GetChangeStamina(curStamina int32, maxStamina int32, staminaCost
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateVehicleStamina 更新载具耐力
|
// UpdateVehicleStamina 更新载具耐力
|
||||||
func (g *Game) UpdateVehicleStamina(player *model.Player, vehicleEntity *Entity, staminaCost int32) {
|
func (g *Game) UpdateVehicleStamina(player *model.Player, entity IEntity, staminaCost int32) {
|
||||||
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
||||||
if staminaCost == 0 {
|
if staminaCost == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
staminaInfo := player.StaminaInfo
|
staminaInfo := player.StaminaInfo
|
||||||
// 确保载具实体存在
|
// 确保载具实体存在
|
||||||
if vehicleEntity == nil {
|
if entity == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gadgetEntity := vehicleEntity.GetGadgetEntity()
|
|
||||||
// 获取载具配置表
|
// 获取载具配置表
|
||||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetEntity.GetGadgetVehicleEntity().GetVehicleId()))
|
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||||
if vehicleDataConfig == nil {
|
if vehicleDataConfig == nil {
|
||||||
logger.Error("vehicle config error, vehicleId: %v", gadgetEntity.GetGadgetVehicleEntity().GetVehicleId())
|
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 添加的耐力大于0为恢复
|
// 添加的耐力大于0为恢复
|
||||||
if staminaCost > 0 {
|
if staminaCost > 0 {
|
||||||
// 耐力延迟1.5s(15 ticks)恢复 动作状态为加速将立刻恢复耐力
|
// 耐力延迟1.5s(15 ticks)恢复 动作状态为加速将立刻恢复耐力
|
||||||
restoreDelay := gadgetEntity.GetGadgetVehicleEntity().GetRestoreDelay()
|
restoreDelay := gadgetVehicleEntity.GetRestoreDelay()
|
||||||
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) && staminaInfo.State != proto.MotionState_MOTION_SKIFF_POWERED_DASH {
|
if restoreDelay < uint8(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.Stamina.StaminaRecoverWaitTime*10) && staminaInfo.State != proto.MotionState_MOTION_SKIFF_POWERED_DASH {
|
||||||
return // 不恢复耐力
|
return // 不恢复耐力
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 消耗耐力重新计算恢复需要延迟的tick
|
// 消耗耐力重新计算恢复需要延迟的tick
|
||||||
gadgetEntity.GetGadgetVehicleEntity().SetRestoreDelay(0)
|
gadgetVehicleEntity.SetRestoreDelay(0)
|
||||||
}
|
}
|
||||||
// 因为载具的耐力需要换算
|
// 因为载具的耐力需要换算
|
||||||
// 这里先*100后面要用的时候再换算 为了确保精度
|
// 这里先*100后面要用的时候再换算 为了确保精度
|
||||||
// 最大耐力值
|
// 最大耐力值
|
||||||
maxStamina := int32(gadgetEntity.GetGadgetVehicleEntity().GetMaxStamina() * 100)
|
maxStamina := int32(gadgetVehicleEntity.GetMaxStamina() * 100)
|
||||||
// 现行耐力值
|
// 现行耐力值
|
||||||
curStamina := int32(gadgetEntity.GetGadgetVehicleEntity().GetCurStamina() * 100)
|
curStamina := int32(gadgetVehicleEntity.GetCurStamina() * 100)
|
||||||
// 将被变更的耐力
|
// 将被变更的耐力
|
||||||
stamina := g.GetChangeStamina(curStamina, maxStamina, staminaCost)
|
stamina := g.GetChangeStamina(curStamina, maxStamina, staminaCost)
|
||||||
// 当前无变动不要频繁发包
|
// 当前无变动不要频繁发包
|
||||||
@@ -317,7 +320,7 @@ func (g *Game) UpdateVehicleStamina(player *model.Player, vehicleEntity *Entity,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 更改载具耐力 (换算)
|
// 更改载具耐力 (换算)
|
||||||
g.SetVehicleStamina(player, vehicleEntity, float32(stamina)/100)
|
g.SetVehicleStamina(player, entity, float32(stamina)/100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePlayerStamina 更新玩家耐力
|
// UpdatePlayerStamina 更新玩家耐力
|
||||||
@@ -388,14 +391,17 @@ func (g *Game) HandleDrown(player *model.Player, stamina uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetVehicleStamina 设置载具耐力
|
// SetVehicleStamina 设置载具耐力
|
||||||
func (g *Game) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
|
func (g *Game) SetVehicleStamina(player *model.Player, entity IEntity, stamina float32) {
|
||||||
// 设置载具的耐力
|
// 设置载具的耐力
|
||||||
gadgetEntity := vehicleEntity.GetGadgetEntity()
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
gadgetEntity.GetGadgetVehicleEntity().SetCurStamina(stamina)
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gadgetVehicleEntity.SetCurStamina(stamina)
|
||||||
// logger.Debug("vehicle stamina set, stamina: %v", stamina)
|
// logger.Debug("vehicle stamina set, stamina: %v", stamina)
|
||||||
|
|
||||||
vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
|
vehicleStaminaNotify := new(proto.VehicleStaminaNotify)
|
||||||
vehicleStaminaNotify.EntityId = vehicleEntity.GetId()
|
vehicleStaminaNotify.EntityId = entity.GetId()
|
||||||
vehicleStaminaNotify.CurStamina = stamina
|
vehicleStaminaNotify.CurStamina = stamina
|
||||||
g.SendMsg(cmd.VehicleStaminaNotify, player.PlayerId, player.ClientSeq, vehicleStaminaNotify)
|
g.SendMsg(cmd.VehicleStaminaNotify, player.PlayerId, player.ClientSeq, vehicleStaminaNotify)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func (g *Game) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
}
|
}
|
||||||
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
||||||
|
|
||||||
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.GetAvatarEntity().GetAvatarId())
|
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.(*AvatarEntity).GetAvatarId())
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: proto.VisionType_VISION_REPLACE,
|
AppearType: proto.VisionType_VISION_REPLACE,
|
||||||
Param: oldAvatarEntity.GetId(),
|
Param: oldAvatarEntity.GetId(),
|
||||||
@@ -144,7 +144,7 @@ func (g *Game) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
}
|
}
|
||||||
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
||||||
|
|
||||||
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.GetAvatarEntity().GetAvatarId())
|
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.(*AvatarEntity).GetAvatarId())
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: proto.VisionType_VISION_REPLACE,
|
AppearType: proto.VisionType_VISION_REPLACE,
|
||||||
Param: oldAvatarEntity.GetId(),
|
Param: oldAvatarEntity.GetId(),
|
||||||
@@ -215,7 +215,7 @@ func (g *Game) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.Message
|
|||||||
}
|
}
|
||||||
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
g.SendToSceneA(scene, cmd.SceneEntityDisappearNotify, player.ClientSeq, sceneEntityDisappearNotify, 0)
|
||||||
|
|
||||||
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.GetAvatarEntity().GetAvatarId())
|
sceneEntityInfo := g.PacketSceneEntityInfoAvatar(scene, player, newAvatarEntity.(*AvatarEntity).GetAvatarId())
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: proto.VisionType_VISION_REPLACE,
|
AppearType: proto.VisionType_VISION_REPLACE,
|
||||||
Param: oldAvatarEntity.GetId(),
|
Param: oldAvatarEntity.GetId(),
|
||||||
|
|||||||
+34
-32
@@ -3,7 +3,6 @@ package game
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hk4e/common/constant"
|
|
||||||
"hk4e/gdconf"
|
"hk4e/gdconf"
|
||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
@@ -86,9 +85,9 @@ func (g *Game) VehicleInteractReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 判断实体类型是否为载具
|
// 判断实体类型是否为载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
_, ok := entity.(*GadgetVehicleEntity)
|
||||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
if ok {
|
||||||
logger.Error("vehicle entity error, entityType: %v", entity.GetEntityType())
|
logger.Error("vehicle entity error, entity: %v", entity)
|
||||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_GADGET_NOT_VEHICLE)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -110,7 +109,7 @@ func (g *Game) VehicleInteractReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
/************************************************** 游戏功能 **************************************************/
|
/************************************************** 游戏功能 **************************************************/
|
||||||
|
|
||||||
// VehicleDestroyMotion 载具销毁动作
|
// VehicleDestroyMotion 载具销毁动作
|
||||||
func (g *Game) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) {
|
func (g *Game) VehicleDestroyMotion(player *model.Player, entity IEntity, state proto.MotionState) {
|
||||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
logger.Error("get world is nil, worldId: %v, uid: %v", player.WorldId, player.PlayerId)
|
||||||
@@ -120,22 +119,19 @@ func (g *Game) VehicleDestroyMotion(player *model.Player, entity *Entity, state
|
|||||||
|
|
||||||
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
|
// 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁
|
||||||
if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
|
if state == proto.MotionState_MOTION_DESTROY_VEHICLE {
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetVehicleEntity := entity.(*GadgetVehicleEntity)
|
||||||
g.DestroyVehicleEntity(player, scene, gadgetEntity.GetGadgetVehicleEntity().GetVehicleId(), entity.GetId())
|
g.DestroyVehicleEntity(player, scene, gadgetVehicleEntity.GetVehicleId(), entity.GetId())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPlayerInVehicle 判断玩家是否在载具中
|
// IsPlayerInVehicle 判断玩家是否在载具中
|
||||||
func (g *Game) IsPlayerInVehicle(player *model.Player, entity *Entity) bool {
|
func (g *Game) IsPlayerInVehicle(player *model.Player, entity IEntity) bool {
|
||||||
if entity.GetEntityType() != constant.ENTITY_TYPE_GADGET {
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
gadgetVehicleEntity := entity.GetGadgetEntity().GetGadgetVehicleEntity()
|
for _, uid := range gadgetVehicleEntity.GetMemberMap() {
|
||||||
if gadgetVehicleEntity == nil {
|
if uid == player.PlayerId {
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, p := range gadgetVehicleEntity.GetMemberMap() {
|
|
||||||
if p == player {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,17 +145,17 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 确保实体类型是否为载具
|
// 确保实体类型是否为载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
if gadgetEntity == nil || gadgetEntity.GetGadgetVehicleEntity() == nil {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改
|
// 目前原神仅有一种载具 多载具目前理论上是兼容了 到时候有问题再改
|
||||||
// 确保载具Id为将要创建的 (每种载具允许存在1个)
|
// 确保载具Id为将要创建的 (每种载具允许存在1个)
|
||||||
if gadgetEntity.GetGadgetVehicleEntity().GetVehicleId() != vehicleId {
|
if gadgetVehicleEntity.GetVehicleId() != vehicleId {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 该载具是否为此玩家的
|
// 该载具是否为此玩家的
|
||||||
if gadgetEntity.GetGadgetVehicleEntity().GetOwnerUid() != player.PlayerId {
|
if gadgetVehicleEntity.GetOwnerUid() != player.PlayerId {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 如果玩家正在载具中
|
// 如果玩家正在载具中
|
||||||
@@ -177,17 +173,20 @@ func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EnterVehicle 进入载具
|
// EnterVehicle 进入载具
|
||||||
func (g *Game) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
func (g *Game) EnterVehicle(player *model.Player, entity IEntity, avatarGuid uint64) {
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
// 获取载具配置表
|
// 获取载具配置表
|
||||||
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetEntity.GetGadgetVehicleEntity().GetVehicleId()))
|
vehicleDataConfig := gdconf.GetVehicleDataById(int32(gadgetVehicleEntity.GetVehicleId()))
|
||||||
if vehicleDataConfig == nil {
|
if vehicleDataConfig == nil {
|
||||||
logger.Error("vehicle config error, vehicleId: %v", gadgetEntity.GetGadgetVehicleEntity().GetVehicleId())
|
logger.Error("vehicle config error, vehicleId: %v", gadgetVehicleEntity.GetVehicleId())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
maxSlot := int(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.MaxSeatCount)
|
maxSlot := int(vehicleDataConfig.ConfigGadgetVehicle.Vehicle.MaxSeatCount)
|
||||||
// 判断载具是否已满
|
// 判断载具是否已满
|
||||||
if len(gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()) >= maxSlot {
|
if len(gadgetVehicleEntity.GetMemberMap()) >= maxSlot {
|
||||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_VEHICLE_SLOT_OCCUPIED)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -195,11 +194,11 @@ func (g *Game) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uin
|
|||||||
// 找出载具空闲的位置
|
// 找出载具空闲的位置
|
||||||
var freePos uint32
|
var freePos uint32
|
||||||
for i := uint32(0); i < uint32(maxSlot); i++ {
|
for i := uint32(0); i < uint32(maxSlot); i++ {
|
||||||
p := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i]
|
uid := gadgetVehicleEntity.GetMemberMap()[i]
|
||||||
// 玩家如果已进入载具重复记录不进行报错
|
// 玩家如果已进入载具重复记录不进行报错
|
||||||
if p == player || p == nil {
|
if uid == player.PlayerId || uid == 0 {
|
||||||
// 载具成员记录玩家
|
// 载具成员记录玩家
|
||||||
gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()[i] = player
|
gadgetVehicleEntity.GetMemberMap()[i] = player.PlayerId
|
||||||
freePos = i
|
freePos = i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,9 +220,12 @@ func (g *Game) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExitVehicle 离开载具
|
// ExitVehicle 离开载具
|
||||||
func (g *Game) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
func (g *Game) ExitVehicle(player *model.Player, entity IEntity, avatarGuid uint64) {
|
||||||
// 玩家是否进入载具
|
// 玩家是否进入载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetVehicleEntity, ok := entity.(*GadgetVehicleEntity)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
if !g.IsPlayerInVehicle(player, entity) {
|
if !g.IsPlayerInVehicle(player, entity) {
|
||||||
logger.Error("vehicle not has player, uid: %v", player.PlayerId)
|
logger.Error("vehicle not has player, uid: %v", player.PlayerId)
|
||||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{}, proto.Retcode_RET_NOT_IN_VEHICLE)
|
||||||
@@ -231,9 +233,9 @@ func (g *Game) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint
|
|||||||
}
|
}
|
||||||
// 载具成员删除玩家
|
// 载具成员删除玩家
|
||||||
var memberPos uint32
|
var memberPos uint32
|
||||||
memberMap := gadgetEntity.GetGadgetVehicleEntity().GetMemberMap()
|
memberMap := gadgetVehicleEntity.GetMemberMap()
|
||||||
for pos, p := range memberMap {
|
for pos, uid := range memberMap {
|
||||||
if p == player {
|
if uid == player.PlayerId {
|
||||||
memberPos = pos
|
memberPos = pos
|
||||||
delete(memberMap, pos)
|
delete(memberMap, pos)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -413,12 +413,11 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interactType := proto.InteractType_INTERACT_NONE
|
interactType := proto.InteractType_INTERACT_NONE
|
||||||
switch entity.GetEntityType() {
|
switch entity.(type) {
|
||||||
case constant.ENTITY_TYPE_GADGET:
|
case IGadgetEntity:
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(entity.(IGadgetEntity).GetGadgetId()))
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
logger.Error("get gadget data config is nil, gadgetId: %v, uid: %v", gadgetEntity.GetGadgetId(), player.PlayerId)
|
logger.Error("get gadget data config is nil, gadgetId: %v, uid: %v", entity.(IGadgetEntity).GetGadgetId(), player.PlayerId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.Debug("[GadgetInteractReq] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, entity.GetId(), player.PlayerId)
|
logger.Debug("[GadgetInteractReq] GadgetData: %+v, EntityId: %v, uid: %v", gadgetDataConfig, entity.GetId(), player.PlayerId)
|
||||||
@@ -426,13 +425,13 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
case constant.GADGET_TYPE_GADGET, constant.GADGET_TYPE_EQUIP, constant.GADGET_TYPE_ENERGY_BALL:
|
case constant.GADGET_TYPE_GADGET, constant.GADGET_TYPE_EQUIP, constant.GADGET_TYPE_ENERGY_BALL:
|
||||||
// 掉落物捡起
|
// 掉落物捡起
|
||||||
interactType = proto.InteractType_INTERACT_PICK_ITEM
|
interactType = proto.InteractType_INTERACT_PICK_ITEM
|
||||||
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_SUBFIELD_DROP)
|
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_SUBFIELD_DROP)
|
||||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
case constant.GADGET_TYPE_GATHER_OBJECT:
|
case constant.GADGET_TYPE_GATHER_OBJECT:
|
||||||
// 采集物摘取
|
// 采集物摘取
|
||||||
interactType = proto.InteractType_INTERACT_GATHER
|
interactType = proto.InteractType_INTERACT_GATHER
|
||||||
gadgetNormalEntity := gadgetEntity.GetGadgetNormalEntity()
|
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_GATHER)
|
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_GATHER)
|
||||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
case constant.GADGET_TYPE_CHEST:
|
case constant.GADGET_TYPE_CHEST:
|
||||||
@@ -454,11 +453,11 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
default:
|
default:
|
||||||
logger.Error("not support gadget type: %v, uid: %v", gadgetDataConfig.Type, player.PlayerId)
|
logger.Error("not support gadget type: %v, uid: %v", gadgetDataConfig.Type, player.PlayerId)
|
||||||
}
|
}
|
||||||
case constant.ENTITY_TYPE_MONSTER:
|
case *MonsterEntity:
|
||||||
// TODO 环境动物掉落道具
|
// TODO 环境动物掉落道具
|
||||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||||
default:
|
default:
|
||||||
logger.Error("not support entity type: %v, uid: %v", entity.GetEntityType(), player.PlayerId)
|
logger.Error("not support entity: %v, uid: %v", entity, player.PlayerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp := &proto.GadgetInteractRsp{
|
rsp := &proto.GadgetInteractRsp{
|
||||||
@@ -570,7 +569,7 @@ const (
|
|||||||
MonsterDropTypeKill
|
MonsterDropTypeKill
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *Game) monsterDrop(player *model.Player, monsterDropType int, hpDropId int32, entity *Entity) {
|
func (g *Game) monsterDrop(player *model.Player, monsterDropType int, hpDropId int32, entity IEntity) {
|
||||||
dropId := int32(0)
|
dropId := int32(0)
|
||||||
dropCount := int32(0)
|
dropCount := int32(0)
|
||||||
switch monsterDropType {
|
switch monsterDropType {
|
||||||
@@ -628,7 +627,7 @@ func (g *Game) monsterDrop(player *model.Player, monsterDropType int, hpDropId i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) chestDrop(player *model.Player, entity *Entity) {
|
func (g *Game) chestDrop(player *model.Player, entity IEntity) {
|
||||||
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||||
if sceneGroupConfig == nil {
|
if sceneGroupConfig == nil {
|
||||||
logger.Error("get scene group config is nil, groupId: %v, uid: %v", entity.GetGroupId(), player.PlayerId)
|
logger.Error("get scene group config is nil, groupId: %v, uid: %v", entity.GetGroupId(), player.PlayerId)
|
||||||
|
|||||||
Reference in new issue
Block a user