添加操作台物件
This commit is contained in:
1 parent
7f2fa99a82
commit
8c660281e7
15 files changed
+655
-286
No files matched your search
+11
-17
@@ -311,26 +311,20 @@ func UpdateFrame(fileData []byte, basePos *model.Vector, rgb bool) {
|
||||
for h := 0; h < SCREEN_HEIGHT; h++ {
|
||||
// 创建像素点
|
||||
if rgb {
|
||||
entityId := scene.CreateEntityGadgetNormal(
|
||||
&model.Vector{
|
||||
gadgetNormalEntity := scene.CreateEntityGadgetNormal(&model.Vector{
|
||||
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
||||
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
||||
Z: leftTopPos.Z,
|
||||
}, new(model.Vector), 0, 0, constant.VISION_LEVEL_SUPER, uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT))
|
||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, gadgetNormalEntity.GetId())
|
||||
} else {
|
||||
if !FRAME[w][h] {
|
||||
gadgetNormalEntity := scene.CreateEntityGadgetNormal(&model.Vector{
|
||||
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
||||
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
||||
Z: leftTopPos.Z,
|
||||
}, new(model.Vector),
|
||||
uint32(FRAME_COLOR[w][h]), uint32(constant.GADGET_STATE_DEFAULT),
|
||||
false, 0, 0, 0, 0, constant.VISION_LEVEL_SUPER)
|
||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||
} else {
|
||||
if !FRAME[w][h] {
|
||||
entityId := scene.CreateEntityGadgetNormal(
|
||||
&model.Vector{
|
||||
X: leftTopPos.X - float64(w)*SCREEN_DPI,
|
||||
Y: leftTopPos.Y - float64(h)*SCREEN_DPI,
|
||||
Z: leftTopPos.Z,
|
||||
}, new(model.Vector),
|
||||
uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT),
|
||||
false, 0, 0, 0, 0, constant.VISION_LEVEL_SUPER)
|
||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, entityId)
|
||||
}, new(model.Vector), 0, 0, constant.VISION_LEVEL_SUPER, uint32(GADGET_ID), uint32(constant.GADGET_STATE_DEFAULT))
|
||||
SCREEN_ENTITY_ID_LIST = append(SCREEN_ENTITY_ID_LIST, gadgetNormalEntity.GetId())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ func (g *GMCmd) GMCreateGadget(userId uint32, gadgetId uint32, count uint32) {
|
||||
return
|
||||
}
|
||||
for i := 0; i < int(count); i++ {
|
||||
GAME.CreateGadget(player, nil, gadgetId, false, 0, 0)
|
||||
GAME.CreateGadget(player, nil, gadgetId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,13 +65,13 @@ func (p *PhysicsEngine) ShowAvatarCollider() {
|
||||
entity := p.world.GetPlayerActiveAvatarEntity(player)
|
||||
avatarPos := entity.GetPos()
|
||||
avatarPos.Y += float64(p.avatarYOffset)
|
||||
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, 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, false, 0, 0)
|
||||
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, false, 0, 0)
|
||||
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, false, 0, 0)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y + AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y - AVATAR_HEIGHT/2.0, Z: avatarPos.Z}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X + AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X - AVATAR_RADIUS, Y: avatarPos.Y, Z: avatarPos.Z}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z + AVATAR_RADIUS}, GADGET_GREEN)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{X: avatarPos.X, Y: avatarPos.Y, Z: avatarPos.Z - AVATAR_RADIUS}, GADGET_GREEN)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,11 +120,11 @@ func (p *PhysicsEngine) Update(now int64) []*RigidBody {
|
||||
}
|
||||
if p.pathTracing {
|
||||
logger.Debug("[PhysicsEngineUpdate] e: %v, s: %v, p: %v, v: %v", rigidBody.entityId, rigidBody.sceneId, rigidBody.position, rigidBody.velocity)
|
||||
GAME.CreateGadget(p.world.GetOwner(), &model.Vector{
|
||||
X: float64(rigidBody.position.X),
|
||||
Y: float64(rigidBody.position.Y),
|
||||
Z: float64(rigidBody.position.Z),
|
||||
}, GADGET_RED, false, 0, 0)
|
||||
GAME.CreateGadget(
|
||||
p.world.GetOwner(),
|
||||
&model.Vector{X: float64(rigidBody.position.X), Y: float64(rigidBody.position.Y), Z: float64(rigidBody.position.Z)},
|
||||
GADGET_RED,
|
||||
)
|
||||
}
|
||||
}
|
||||
p.lastUpdateTime = now
|
||||
|
||||
@@ -528,7 +528,6 @@ func (p *PluginPubg) StartPubg() {
|
||||
p.world.GetOwner(),
|
||||
&model.Vector{X: float64(pubgWorldGadgetDataConfig.X), Y: float64(pubgWorldGadgetDataConfig.Y), Z: float64(pubgWorldGadgetDataConfig.Z)},
|
||||
uint32(pubgWorldGadgetDataConfig.GadgetId),
|
||||
false, 0, 0,
|
||||
)
|
||||
p.entityIdWorldGadgetIdMap[entityId] = pubgWorldGadgetDataConfig.WorldGadgetId
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ func (r *RouteManager) initRoute() {
|
||||
cmd.GetMailItemReq: GAME.GetMailItemReq,
|
||||
cmd.ReadMailNotify: GAME.ReadMailNotify,
|
||||
cmd.ChangeMailStarNotify: GAME.ChangeMailStarNotify,
|
||||
cmd.SelectWorktopOptionReq: GAME.SelectWorktopOptionReq,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+237
-126
@@ -105,17 +105,15 @@ func (s *Scene) CreateEntityAvatar(player *model.Player, avatarId uint32) uint32
|
||||
}
|
||||
entity := &AvatarEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: avatar.LifeState,
|
||||
pos: player.GetPos(),
|
||||
rot: player.GetRot(),
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: avatar.FightPropMap, // 使用角色结构的数据
|
||||
entityType: constant.ENTITY_TYPE_AVATAR,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: avatar.LifeState,
|
||||
pos: player.GetPos(),
|
||||
rot: player.GetRot(),
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: avatar.FightPropMap, // 使用角色结构的数据
|
||||
entityType: constant.ENTITY_TYPE_AVATAR,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
},
|
||||
uid: player.PlayerId,
|
||||
avatarId: avatarId,
|
||||
@@ -127,14 +125,12 @@ func (s *Scene) CreateEntityWeapon(pos, rot *model.Vector) uint32 {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_WEAPON)
|
||||
entity := &WeaponEntity{
|
||||
&Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||
@@ -147,47 +143,37 @@ func (s *Scene) CreateEntityWeapon(pos, rot *model.Vector) uint32 {
|
||||
return s.CreateEntity(entity)
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, monsterId uint32, level uint8, configId, groupId uint32, visionLevel int) uint32 {
|
||||
fightPropMap := gdconf.GetMonsterFightPropMap(monsterId, level)
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_ATTACK] = fightPropMap[constant.FIGHT_PROP_BASE_ATTACK]
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_DEFENSE] = fightPropMap[constant.FIGHT_PROP_BASE_DEFENSE]
|
||||
fightPropMap[constant.FIGHT_PROP_MAX_HP] = fightPropMap[constant.FIGHT_PROP_BASE_HP]
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_HP] = fightPropMap[constant.FIGHT_PROP_MAX_HP]
|
||||
func (s *Scene) CreateEntityMonster(pos, rot *model.Vector, level uint8, configId, groupId uint32, visionLevel int) *MonsterEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_MONSTER)
|
||||
entity := &MonsterEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: fightPropMap,
|
||||
level: level,
|
||||
entityType: constant.ENTITY_TYPE_MONSTER,
|
||||
configId: configId,
|
||||
groupId: groupId,
|
||||
visionLevel: visionLevel,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
level: level,
|
||||
entityType: constant.ENTITY_TYPE_MONSTER,
|
||||
configId: configId,
|
||||
groupId: groupId,
|
||||
visionLevel: visionLevel,
|
||||
},
|
||||
monsterId: monsterId,
|
||||
}
|
||||
return s.CreateEntity(entity)
|
||||
s.CreateEntity(entity)
|
||||
return 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, configId, groupId uint32) *NpcEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_NPC)
|
||||
entity := &NpcEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||
@@ -198,27 +184,22 @@ func (s *Scene) CreateEntityNpc(pos, rot *model.Vector, npcId, roomId, parentQue
|
||||
groupId: groupId,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
},
|
||||
npcId: npcId,
|
||||
roomId: roomId,
|
||||
parentQuestId: parentQuestId,
|
||||
blockId: blockId,
|
||||
}
|
||||
return s.CreateEntity(entity)
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId, gadgetState uint32, isDrop bool, itemId, count uint32, configId, groupId uint32, visionLevel int) uint32 {
|
||||
func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, configId, groupId uint32, visionLevel int, gadgetId, gadgetState uint32) *GadgetNormalEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
entity := &GadgetNormalEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||
@@ -232,25 +213,107 @@ func (s *Scene) CreateEntityGadgetNormal(pos, rot *model.Vector, gadgetId, gadge
|
||||
gadgetId: gadgetId,
|
||||
gadgetState: gadgetState,
|
||||
},
|
||||
isDrop: isDrop,
|
||||
itemId: itemId,
|
||||
count: count,
|
||||
}
|
||||
return s.CreateEntity(entity)
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, configId, campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) bool {
|
||||
func (s *Scene) CreateEntityGadgetTrifleItem(pos, rot *model.Vector, visionLevel int, gadgetId, gadgetState uint32) *GadgetTrifleItemEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
entity := &GadgetTrifleItemEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
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,
|
||||
visionLevel: visionLevel,
|
||||
},
|
||||
gadgetId: gadgetId,
|
||||
gadgetState: gadgetState,
|
||||
},
|
||||
}
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetGather(pos, rot *model.Vector, configId, groupId uint32, visionLevel int, gadgetId, gadgetState uint32) *GadgetGatherEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
entity := &GadgetGatherEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
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,
|
||||
},
|
||||
}
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetWorktop(pos, rot *model.Vector, configId, groupId uint32, visionLevel int, gadgetId, gadgetState uint32) *GadgetWorktopEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
entity := &GadgetWorktopEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
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,
|
||||
},
|
||||
optionMap: make(map[uint32]struct{}),
|
||||
}
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetClient(entityId uint32, pos, rot *model.Vector, gadgetId uint32) *GadgetClientEntity {
|
||||
entity := &GadgetClientEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_CUR_HP: math.MaxFloat32,
|
||||
constant.FIGHT_PROP_MAX_HP: math.MaxFloat32,
|
||||
@@ -259,62 +322,34 @@ func (s *Scene) CreateEntityGadgetClient(pos, rot *model.Vector, entityId, confi
|
||||
entityType: constant.ENTITY_TYPE_GADGET,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
},
|
||||
gadgetId: configId,
|
||||
gadgetId: gadgetId,
|
||||
},
|
||||
campId: campId,
|
||||
campType: campType,
|
||||
ownerEntityId: ownerEntityId,
|
||||
targetEntityId: targetEntityId,
|
||||
propOwnerEntityId: propOwnerEntityId,
|
||||
}
|
||||
if s.CreateEntity(entity) == 0 {
|
||||
return false
|
||||
return nil
|
||||
}
|
||||
return true
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntityGadgetVehicle(ownerUid uint32, pos, rot *model.Vector, vehicleId uint32) uint32 {
|
||||
// 获取载具配置表
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(vehicleId))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", vehicleId)
|
||||
return 0
|
||||
}
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
return 0
|
||||
}
|
||||
func (s *Scene) CreateEntityGadgetVehicle(pos, rot *model.Vector, gadgetId uint32) *GadgetVehicleEntity {
|
||||
entityId := s.world.GetNextWorldEntityId(constant.ENTITY_TYPE_GADGET)
|
||||
entity := &GadgetVehicleEntity{
|
||||
GadgetEntity: &GadgetEntity{
|
||||
Entity: &Entity{
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
lastMoveSceneTimeMs: 0,
|
||||
lastMoveReliableSeq: 0,
|
||||
fightProp: map[uint32]float32{
|
||||
constant.FIGHT_PROP_BASE_DEFENSE: gadgetJsonConfig.Combat.Property.DefenseBase,
|
||||
constant.FIGHT_PROP_CUR_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_MAX_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_CUR_ATTACK: gadgetJsonConfig.Combat.Property.Attack,
|
||||
},
|
||||
id: entityId,
|
||||
scene: s,
|
||||
lifeState: constant.LIFE_STATE_ALIVE,
|
||||
pos: &model.Vector{X: pos.X, Y: pos.Y, Z: pos.Z},
|
||||
rot: &model.Vector{X: rot.X, Y: rot.Y, Z: rot.Z},
|
||||
moveState: uint16(proto.MotionState_MOTION_NONE),
|
||||
entityType: constant.ENTITY_TYPE_GADGET,
|
||||
visionLevel: constant.VISION_LEVEL_NORMAL,
|
||||
},
|
||||
gadgetId: vehicleId,
|
||||
gadgetId: gadgetId,
|
||||
},
|
||||
ownerUid: ownerUid,
|
||||
maxStamina: gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit,
|
||||
curStamina: gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit,
|
||||
restoreDelay: 0,
|
||||
memberMap: make(map[uint32]uint32),
|
||||
}
|
||||
return s.CreateEntity(entity)
|
||||
s.CreateEntity(entity)
|
||||
return entity
|
||||
}
|
||||
|
||||
func (s *Scene) CreateEntity(entity IEntity) uint32 {
|
||||
@@ -776,7 +811,7 @@ func (e *Entity) AbilityAction(ability *Ability, action *gdconf.ActionData, enti
|
||||
if !action.ByServer {
|
||||
return
|
||||
}
|
||||
GAME.CreateGadget(owner, entity.GetPos(), uint32(action.GadgetID), false, 0, 0)
|
||||
GAME.CreateGadget(owner, entity.GetPos(), uint32(action.GadgetID))
|
||||
case "GenerateElemBall":
|
||||
itemDataConfig := gdconf.GetItemDataById(action.ConfigID)
|
||||
if itemDataConfig == nil {
|
||||
@@ -885,6 +920,16 @@ func (m *MonsterEntity) InitAbility() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MonsterEntity) CreateMonsterEntity(monsterId uint32) {
|
||||
fightPropMap := gdconf.GetMonsterFightPropMap(monsterId, m.GetLevel())
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_ATTACK] = fightPropMap[constant.FIGHT_PROP_BASE_ATTACK]
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_DEFENSE] = fightPropMap[constant.FIGHT_PROP_BASE_DEFENSE]
|
||||
fightPropMap[constant.FIGHT_PROP_MAX_HP] = fightPropMap[constant.FIGHT_PROP_BASE_HP]
|
||||
fightPropMap[constant.FIGHT_PROP_CUR_HP] = fightPropMap[constant.FIGHT_PROP_MAX_HP]
|
||||
m.fightProp = fightPropMap
|
||||
m.monsterId = monsterId
|
||||
}
|
||||
|
||||
type NpcEntity struct {
|
||||
*Entity
|
||||
npcId uint32
|
||||
@@ -914,6 +959,13 @@ func (n *NpcEntity) InitAbility() {
|
||||
n.modifierMap = make(map[uint32]*Modifier)
|
||||
}
|
||||
|
||||
func (n *NpcEntity) CreateNpcEntity(npcId, roomId, parentQuestId, blockId uint32) {
|
||||
n.npcId = npcId
|
||||
n.roomId = roomId
|
||||
n.parentQuestId = parentQuestId
|
||||
n.blockId = blockId
|
||||
}
|
||||
|
||||
type IGadgetEntity interface {
|
||||
GetGadgetId() uint32
|
||||
GetGadgetState() uint32
|
||||
@@ -968,23 +1020,49 @@ func (g *GadgetEntity) InitAbility() {
|
||||
|
||||
type GadgetNormalEntity struct {
|
||||
*GadgetEntity
|
||||
isDrop bool
|
||||
}
|
||||
|
||||
type GadgetTrifleItemEntity struct {
|
||||
*GadgetEntity
|
||||
itemId uint32
|
||||
count uint32
|
||||
}
|
||||
|
||||
func (g *GadgetNormalEntity) GetIsDrop() bool {
|
||||
return g.isDrop
|
||||
}
|
||||
|
||||
func (g *GadgetNormalEntity) GetItemId() uint32 {
|
||||
func (g *GadgetTrifleItemEntity) GetItemId() uint32 {
|
||||
return g.itemId
|
||||
}
|
||||
|
||||
func (g *GadgetNormalEntity) GetCount() uint32 {
|
||||
func (g *GadgetTrifleItemEntity) GetCount() uint32 {
|
||||
return g.count
|
||||
}
|
||||
|
||||
func (g *GadgetTrifleItemEntity) CreateGadgetTrifleItemEntity(itemId, count uint32) {
|
||||
g.itemId = itemId
|
||||
g.count = count
|
||||
}
|
||||
|
||||
type GadgetGatherEntity struct {
|
||||
*GadgetEntity
|
||||
itemId uint32
|
||||
}
|
||||
|
||||
func (g *GadgetGatherEntity) GetItemId() uint32 {
|
||||
return g.itemId
|
||||
}
|
||||
|
||||
func (g *GadgetGatherEntity) CreateGadgetGatherEntity(itemId uint32) {
|
||||
g.itemId = itemId
|
||||
}
|
||||
|
||||
type GadgetWorktopEntity struct {
|
||||
*GadgetEntity
|
||||
optionMap map[uint32]struct{}
|
||||
}
|
||||
|
||||
func (g *GadgetWorktopEntity) GetOptionMap() map[uint32]struct{} {
|
||||
return g.optionMap
|
||||
}
|
||||
|
||||
type GadgetClientEntity struct {
|
||||
*GadgetEntity
|
||||
campId uint32
|
||||
@@ -1014,6 +1092,14 @@ func (g *GadgetClientEntity) GetPropOwnerEntityId() uint32 {
|
||||
return g.propOwnerEntityId
|
||||
}
|
||||
|
||||
func (g *GadgetClientEntity) CreateGadgetClientEntity(campId, campType, ownerEntityId, targetEntityId, propOwnerEntityId uint32) {
|
||||
g.campId = campId
|
||||
g.campType = campType
|
||||
g.ownerEntityId = ownerEntityId
|
||||
g.targetEntityId = targetEntityId
|
||||
g.propOwnerEntityId = propOwnerEntityId
|
||||
}
|
||||
|
||||
type GadgetVehicleEntity struct {
|
||||
*GadgetEntity
|
||||
ownerUid uint32
|
||||
@@ -1050,3 +1136,28 @@ func (g *GadgetVehicleEntity) SetCurStamina(curStamina float32) {
|
||||
func (g *GadgetVehicleEntity) SetRestoreDelay(restoreDelay uint8) {
|
||||
g.restoreDelay = restoreDelay
|
||||
}
|
||||
|
||||
func (g *GadgetVehicleEntity) CreateGadgetVehicleEntity(ownerUid uint32) {
|
||||
// 获取载具配置表
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(g.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", g.GetGadgetId())
|
||||
return
|
||||
}
|
||||
gadgetJsonConfig := gdconf.GetGadgetJsonConfigByName(gadgetDataConfig.JsonName)
|
||||
if gadgetJsonConfig == nil {
|
||||
logger.Error("get gadget json config is nil, name: %v", gadgetDataConfig.JsonName)
|
||||
return
|
||||
}
|
||||
fightPropMap := map[uint32]float32{
|
||||
constant.FIGHT_PROP_BASE_DEFENSE: gadgetJsonConfig.Combat.Property.DefenseBase,
|
||||
constant.FIGHT_PROP_CUR_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_MAX_HP: gadgetJsonConfig.Combat.Property.HP,
|
||||
constant.FIGHT_PROP_CUR_ATTACK: gadgetJsonConfig.Combat.Property.Attack,
|
||||
}
|
||||
g.fightProp = fightPropMap
|
||||
g.ownerUid = ownerUid
|
||||
g.maxStamina = gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit
|
||||
g.curStamina = gadgetJsonConfig.Vehicle.Stamina.StaminaUpperLimit
|
||||
g.memberMap = make(map[uint32]uint32)
|
||||
}
|
||||
@@ -193,6 +193,10 @@ func RegLuaScriptLibFunc() {
|
||||
gdconf.RegScriptLibFunc("RemoveExtraGroupSuite", RemoveExtraGroupSuite)
|
||||
gdconf.RegScriptLibFunc("ShowReminder", ShowReminder)
|
||||
gdconf.RegScriptLibFunc("KillGroupEntity", KillGroupEntity)
|
||||
gdconf.RegScriptLibFunc("SetWorktopOptions", SetWorktopOptions)
|
||||
gdconf.RegScriptLibFunc("SetWorktopOptionsByGroupId", SetWorktopOptionsByGroupId)
|
||||
gdconf.RegScriptLibFunc("DelWorktopOption", DelWorktopOption)
|
||||
gdconf.RegScriptLibFunc("DelWorktopOptionByGroupId", DelWorktopOptionByGroupId)
|
||||
// 调用物件LUA方法
|
||||
gdconf.RegScriptLibFunc("SetGadgetState", SetGadgetState)
|
||||
gdconf.RegScriptLibFunc("GetGadgetState", GetGadgetState)
|
||||
@@ -480,6 +484,10 @@ func SetGadgetStateByConfigId(luaState *lua.LState) int {
|
||||
configId := luaState.ToInt(2)
|
||||
state := luaState.ToInt(3)
|
||||
entity := group.GetEntityByConfigId(uint32(configId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
GAME.ChangeGadgetState(player, entity.GetId(), uint32(state))
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
@@ -1041,6 +1049,198 @@ func KillGroupEntity(luaState *lua.LState) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func SetWorktopOptions(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
targetEntityId, ok := luaState.GetField(ctx, "target_entity_id").(lua.LNumber)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
luaTable, ok := luaState.Get(2).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
var optionList []uint32 = nil
|
||||
gdconf.ParseLuaTableToObject[*[]uint32](luaTable, &optionList)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
entity := scene.GetEntity(uint32(targetEntityId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
gadgetWorktopEntity, ok := entity.(*GadgetWorktopEntity)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
optionMap := gadgetWorktopEntity.GetOptionMap()
|
||||
for _, option := range optionList {
|
||||
optionMap[option] = struct{}{}
|
||||
}
|
||||
GAME.SendToSceneA(scene, cmd.WorktopOptionNotify, player.ClientSeq, &proto.WorktopOptionNotify{
|
||||
GadgetEntityId: gadgetWorktopEntity.GetId(),
|
||||
OptionList: object.ConvMapKeyToList[uint32, struct{}](gadgetWorktopEntity.GetOptionMap()),
|
||||
}, 0)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func SetWorktopOptionsByGroupId(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
groupId := luaState.ToInt(2)
|
||||
configId := luaState.ToInt(3)
|
||||
luaTable, ok := luaState.Get(4).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
var optionList []uint32 = nil
|
||||
gdconf.ParseLuaTableToObject[*[]uint32](luaTable, &optionList)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
group := scene.GetGroupById(uint32(groupId))
|
||||
if group == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
entity := group.GetEntityByConfigId(uint32(configId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
gadgetWorktopEntity, ok := entity.(*GadgetWorktopEntity)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
optionMap := gadgetWorktopEntity.GetOptionMap()
|
||||
for _, option := range optionList {
|
||||
optionMap[option] = struct{}{}
|
||||
}
|
||||
GAME.SendToSceneA(scene, cmd.WorktopOptionNotify, player.ClientSeq, &proto.WorktopOptionNotify{
|
||||
GadgetEntityId: gadgetWorktopEntity.GetId(),
|
||||
OptionList: object.ConvMapKeyToList[uint32, struct{}](gadgetWorktopEntity.GetOptionMap()),
|
||||
}, 0)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func DelWorktopOption(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
targetEntityId, ok := luaState.GetField(ctx, "target_entity_id").(lua.LNumber)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
option := luaState.ToInt(2)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
entity := scene.GetEntity(uint32(targetEntityId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
gadgetWorktopEntity, ok := entity.(*GadgetWorktopEntity)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
optionMap := gadgetWorktopEntity.GetOptionMap()
|
||||
delete(optionMap, uint32(option))
|
||||
GAME.SendToSceneA(scene, cmd.WorktopOptionNotify, player.ClientSeq, &proto.WorktopOptionNotify{
|
||||
GadgetEntityId: gadgetWorktopEntity.GetId(),
|
||||
OptionList: object.ConvMapKeyToList[uint32, struct{}](gadgetWorktopEntity.GetOptionMap()),
|
||||
}, 0)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func DelWorktopOptionByGroupId(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
player := GetContextPlayer(ctx, luaState)
|
||||
if player == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
groupId := luaState.ToInt(2)
|
||||
configId := luaState.ToInt(3)
|
||||
option := luaState.ToInt(4)
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
scene := world.GetSceneById(player.SceneId)
|
||||
group := scene.GetGroupById(uint32(groupId))
|
||||
if group == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
entity := group.GetEntityByConfigId(uint32(configId))
|
||||
if entity == nil {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
gadgetWorktopEntity, ok := entity.(*GadgetWorktopEntity)
|
||||
if !ok {
|
||||
luaState.Push(lua.LNumber(-1))
|
||||
return 1
|
||||
}
|
||||
optionMap := gadgetWorktopEntity.GetOptionMap()
|
||||
delete(optionMap, uint32(option))
|
||||
GAME.SendToSceneA(scene, cmd.WorktopOptionNotify, player.ClientSeq, &proto.WorktopOptionNotify{
|
||||
GadgetEntityId: gadgetWorktopEntity.GetId(),
|
||||
OptionList: object.ConvMapKeyToList[uint32, struct{}](gadgetWorktopEntity.GetOptionMap()),
|
||||
}, 0)
|
||||
luaState.Push(lua.LNumber(0))
|
||||
return 1
|
||||
}
|
||||
|
||||
func SetGadgetState(luaState *lua.LState) int {
|
||||
ctx, ok := luaState.Get(1).(*lua.LTable)
|
||||
if !ok {
|
||||
|
||||
+14
-14
@@ -182,7 +182,7 @@ func (g *Game) QuestStartTriggerCheck(player *model.Player, questId uint32) {
|
||||
}
|
||||
|
||||
// MonsterCreateTriggerCheck 怪物创建触发器检测
|
||||
func (g *Game) MonsterCreateTriggerCheck(player *model.Player, group *Group, configId uint32) {
|
||||
func (g *Game) MonsterCreateTriggerCheck(player *model.Player, group *Group, entity IEntity) {
|
||||
forEachGroupTrigger(player, group, func(triggerConfig *gdconf.Trigger, groupConfig *gdconf.Group) {
|
||||
if triggerConfig.Event != constant.LUA_EVENT_ANY_MONSTER_LIVE {
|
||||
return
|
||||
@@ -190,7 +190,7 @@ func (g *Game) MonsterCreateTriggerCheck(player *model.Player, group *Group, con
|
||||
if triggerConfig.Condition != "" {
|
||||
cond := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Condition,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaEvt{param1: int32(configId)})
|
||||
&LuaEvt{param1: int32(entity.GetId())})
|
||||
if !cond {
|
||||
return
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func (g *Game) MonsterCreateTriggerCheck(player *model.Player, group *Group, con
|
||||
if triggerConfig.Action != "" {
|
||||
logger.Debug("scene group trigger do action, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
ok := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Action,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id), targetEntityId: entity.GetId()},
|
||||
&LuaEvt{})
|
||||
if !ok {
|
||||
logger.Error("trigger action fail, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
@@ -208,7 +208,7 @@ func (g *Game) MonsterCreateTriggerCheck(player *model.Player, group *Group, con
|
||||
}
|
||||
|
||||
// MonsterDieTriggerCheck 怪物死亡触发器检测
|
||||
func (g *Game) MonsterDieTriggerCheck(player *model.Player, group *Group) {
|
||||
func (g *Game) MonsterDieTriggerCheck(player *model.Player, group *Group, entity IEntity) {
|
||||
forEachGroupTrigger(player, group, func(triggerConfig *gdconf.Trigger, groupConfig *gdconf.Group) {
|
||||
if triggerConfig.Event != constant.LUA_EVENT_ANY_MONSTER_DIE {
|
||||
return
|
||||
@@ -224,7 +224,7 @@ func (g *Game) MonsterDieTriggerCheck(player *model.Player, group *Group) {
|
||||
if triggerConfig.Action != "" {
|
||||
logger.Debug("scene group trigger do action, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
ok := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Action,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id), targetEntityId: entity.GetId()},
|
||||
&LuaEvt{})
|
||||
if !ok {
|
||||
logger.Error("trigger action fail, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
@@ -234,7 +234,7 @@ func (g *Game) MonsterDieTriggerCheck(player *model.Player, group *Group) {
|
||||
}
|
||||
|
||||
// GadgetCreateTriggerCheck 物件创建触发器检测
|
||||
func (g *Game) GadgetCreateTriggerCheck(player *model.Player, group *Group, configId uint32) {
|
||||
func (g *Game) GadgetCreateTriggerCheck(player *model.Player, group *Group, entity IEntity) {
|
||||
forEachGroupTrigger(player, group, func(triggerConfig *gdconf.Trigger, groupConfig *gdconf.Group) {
|
||||
if triggerConfig.Event != constant.LUA_EVENT_GADGET_CREATE {
|
||||
return
|
||||
@@ -242,7 +242,7 @@ func (g *Game) GadgetCreateTriggerCheck(player *model.Player, group *Group, conf
|
||||
if triggerConfig.Condition != "" {
|
||||
cond := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Condition,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaEvt{param1: int32(configId)})
|
||||
&LuaEvt{param1: int32(entity.GetConfigId())})
|
||||
if !cond {
|
||||
return
|
||||
}
|
||||
@@ -250,7 +250,7 @@ func (g *Game) GadgetCreateTriggerCheck(player *model.Player, group *Group, conf
|
||||
if triggerConfig.Action != "" {
|
||||
logger.Debug("scene group trigger do action, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
ok := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Action,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id), targetEntityId: entity.GetId()},
|
||||
&LuaEvt{})
|
||||
if !ok {
|
||||
logger.Error("trigger action fail, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
@@ -260,7 +260,7 @@ func (g *Game) GadgetCreateTriggerCheck(player *model.Player, group *Group, conf
|
||||
}
|
||||
|
||||
// GadgetStateChangeTriggerCheck 物件状态变更触发器检测
|
||||
func (g *Game) GadgetStateChangeTriggerCheck(player *model.Player, group *Group, configId uint32, state uint8) {
|
||||
func (g *Game) GadgetStateChangeTriggerCheck(player *model.Player, group *Group, entity IEntity, state uint8) {
|
||||
forEachGroupTrigger(player, group, func(triggerConfig *gdconf.Trigger, groupConfig *gdconf.Group) {
|
||||
if triggerConfig.Event != constant.LUA_EVENT_GADGET_STATE_CHANGE {
|
||||
return
|
||||
@@ -268,7 +268,7 @@ func (g *Game) GadgetStateChangeTriggerCheck(player *model.Player, group *Group,
|
||||
if triggerConfig.Condition != "" {
|
||||
cond := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Condition,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaEvt{param1: int32(state), param2: int32(configId)})
|
||||
&LuaEvt{param1: int32(state), param2: int32(entity.GetConfigId())})
|
||||
if !cond {
|
||||
return
|
||||
}
|
||||
@@ -276,7 +276,7 @@ func (g *Game) GadgetStateChangeTriggerCheck(player *model.Player, group *Group,
|
||||
if triggerConfig.Action != "" {
|
||||
logger.Debug("scene group trigger do action, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
ok := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Action,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id), targetEntityId: entity.GetId()},
|
||||
&LuaEvt{})
|
||||
if !ok {
|
||||
logger.Error("trigger action fail, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
@@ -286,7 +286,7 @@ func (g *Game) GadgetStateChangeTriggerCheck(player *model.Player, group *Group,
|
||||
}
|
||||
|
||||
// GadgetDieTriggerCheck 物件死亡触发器检测
|
||||
func (g *Game) GadgetDieTriggerCheck(player *model.Player, group *Group, configId uint32) {
|
||||
func (g *Game) GadgetDieTriggerCheck(player *model.Player, group *Group, entity IEntity) {
|
||||
forEachGroupTrigger(player, group, func(triggerConfig *gdconf.Trigger, groupConfig *gdconf.Group) {
|
||||
if triggerConfig.Event != constant.LUA_EVENT_ANY_GADGET_DIE {
|
||||
return
|
||||
@@ -294,7 +294,7 @@ func (g *Game) GadgetDieTriggerCheck(player *model.Player, group *Group, configI
|
||||
if triggerConfig.Condition != "" {
|
||||
cond := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Condition,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaEvt{param1: int32(configId)})
|
||||
&LuaEvt{param1: int32(entity.GetConfigId())})
|
||||
if !cond {
|
||||
return
|
||||
}
|
||||
@@ -302,7 +302,7 @@ func (g *Game) GadgetDieTriggerCheck(player *model.Player, group *Group, configI
|
||||
if triggerConfig.Action != "" {
|
||||
logger.Debug("scene group trigger do action, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
ok := CallSceneLuaFunc(groupConfig.GetLuaState(), triggerConfig.Action,
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id)},
|
||||
&LuaCtx{uid: player.PlayerId, groupId: uint32(groupConfig.Id), targetEntityId: entity.GetId()},
|
||||
&LuaEvt{})
|
||||
if !ok {
|
||||
logger.Error("trigger action fail, trigger: %+v, uid: %v", triggerConfig, player.PlayerId)
|
||||
|
||||
@@ -922,7 +922,7 @@ func (g *Game) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
|
||||
},
|
||||
},
|
||||
LifeState: uint32(avatar.LifeState),
|
||||
EquipGuidList: object.ConvMapToList(avatar.EquipGuidMap),
|
||||
EquipGuidList: object.ConvMapValueToList[uint64, uint64](avatar.EquipGuidMap),
|
||||
FightPropMap: avatar.FightPropMap,
|
||||
SkillDepotId: avatar.SkillDepotId,
|
||||
FetterInfo: &proto.AvatarFetterInfo{
|
||||
|
||||
@@ -855,18 +855,16 @@ func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message
|
||||
if ntf.InitPos == nil {
|
||||
return
|
||||
}
|
||||
ok := scene.CreateEntityGadgetClient(&model.Vector{
|
||||
X: float64(ntf.InitPos.X),
|
||||
Y: float64(ntf.InitPos.Y),
|
||||
Z: float64(ntf.InitPos.Z),
|
||||
}, &model.Vector{
|
||||
X: float64(ntf.InitEulerAngles.X),
|
||||
Y: float64(ntf.InitEulerAngles.Y),
|
||||
Z: float64(ntf.InitEulerAngles.Z),
|
||||
}, ntf.EntityId, ntf.ConfigId, ntf.CampId, ntf.CampType, ntf.OwnerEntityId, ntf.TargetEntityId, ntf.PropOwnerEntityId)
|
||||
if !ok {
|
||||
gadgetClientEntity := scene.CreateEntityGadgetClient(
|
||||
ntf.EntityId,
|
||||
&model.Vector{X: float64(ntf.InitPos.X), Y: float64(ntf.InitPos.Y), Z: float64(ntf.InitPos.Z)},
|
||||
&model.Vector{X: float64(ntf.InitEulerAngles.X), Y: float64(ntf.InitEulerAngles.Y), Z: float64(ntf.InitEulerAngles.Z)},
|
||||
ntf.ConfigId,
|
||||
)
|
||||
if gadgetClientEntity == nil {
|
||||
return
|
||||
}
|
||||
gadgetClientEntity.CreateGadgetClientEntity(ntf.CampId, ntf.CampType, ntf.OwnerEntityId, ntf.TargetEntityId, ntf.PropOwnerEntityId)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{ntf.EntityId}, true, true)
|
||||
|
||||
// 触发事件
|
||||
|
||||
+144
-86
@@ -921,11 +921,11 @@ func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, d
|
||||
// 随机掉落
|
||||
g.monsterDrop(player, MonsterDropTypeKill, 0, entity)
|
||||
// 怪物死亡触发器检测
|
||||
g.MonsterDieTriggerCheck(player, group)
|
||||
g.MonsterDieTriggerCheck(player, group, entity)
|
||||
case IGadgetEntity:
|
||||
iGadgetEntity := entity.(IGadgetEntity)
|
||||
// 物件死亡触发器检测
|
||||
g.GadgetDieTriggerCheck(player, group, entity.GetConfigId())
|
||||
g.GadgetDieTriggerCheck(player, group, entity)
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(iGadgetEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||
@@ -985,7 +985,7 @@ func (g *Game) ChangeGadgetState(player *model.Player, entityId uint32, state ui
|
||||
sceneGroup.ChangeGadgetState(entity.GetConfigId(), uint8(iGadgetEntity.GetGadgetState()))
|
||||
|
||||
// 物件状态变更触发器检测
|
||||
g.GadgetStateChangeTriggerCheck(player, group, entity.GetConfigId(), uint8(iGadgetEntity.GetGadgetState()))
|
||||
g.GadgetStateChangeTriggerCheck(player, group, entity, uint8(iGadgetEntity.GetGadgetState()))
|
||||
}
|
||||
|
||||
// GetVisionEntity 获取某位置视野内的全部实体
|
||||
@@ -1299,56 +1299,66 @@ func (g *Game) CreateConfigEntity(scene *Scene, groupId uint32, entityConfig any
|
||||
if monsterLevel > 100 {
|
||||
monsterLevel = 100
|
||||
}
|
||||
return scene.CreateEntityMonster(
|
||||
monsterEntity := scene.CreateEntityMonster(
|
||||
&model.Vector{X: float64(monster.Pos.X), Y: float64(monster.Pos.Y), Z: float64(monster.Pos.Z)},
|
||||
&model.Vector{X: float64(monster.Rot.X), Y: float64(monster.Rot.Y), Z: float64(monster.Rot.Z)},
|
||||
uint32(monster.MonsterId), monsterLevel, uint32(monster.ConfigId), groupId, int(monster.VisionLevel),
|
||||
monsterLevel, uint32(monster.ConfigId), groupId, int(monster.VisionLevel),
|
||||
)
|
||||
monsterEntity.CreateMonsterEntity(uint32(monster.MonsterId))
|
||||
return monsterEntity.GetId()
|
||||
case *gdconf.Npc:
|
||||
npc := entityConfig.(*gdconf.Npc)
|
||||
return scene.CreateEntityNpc(
|
||||
npcEntity := scene.CreateEntityNpc(
|
||||
&model.Vector{X: float64(npc.Pos.X), Y: float64(npc.Pos.Y), Z: float64(npc.Pos.Z)},
|
||||
&model.Vector{X: float64(npc.Rot.X), Y: float64(npc.Rot.Y), Z: float64(npc.Rot.Z)},
|
||||
uint32(npc.NpcId), 0, 0, 0, uint32(npc.ConfigId), groupId,
|
||||
uint32(npc.ConfigId), groupId,
|
||||
)
|
||||
npcEntity.CreateNpcEntity(uint32(npc.NpcId), 0, 0, 0)
|
||||
return npcEntity.GetId()
|
||||
case *gdconf.Gadget:
|
||||
gadget := entityConfig.(*gdconf.Gadget)
|
||||
// 70500000并不是实际的物件id 根据节点类型对应采集物配置表
|
||||
if gadget.PointType != 0 && gadget.GadgetId == 70500000 {
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(gadget.GadgetId)
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", gadget.GadgetId)
|
||||
return 0
|
||||
}
|
||||
switch gadgetDataConfig.Type {
|
||||
case constant.GADGET_TYPE_GATHER_POINT:
|
||||
gatherDataConfig := gdconf.GetGatherDataByPointType(gadget.PointType)
|
||||
if gatherDataConfig == nil {
|
||||
return 0
|
||||
}
|
||||
return scene.CreateEntityGadgetNormal(
|
||||
gadgetGatherEntity := scene.CreateEntityGadgetGather(
|
||||
&model.Vector{X: float64(gadget.Pos.X), Y: float64(gadget.Pos.Y), Z: float64(gadget.Pos.Z)},
|
||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||
uint32(gatherDataConfig.GadgetId),
|
||||
uint32(constant.GADGET_STATE_DEFAULT),
|
||||
false,
|
||||
uint32(gatherDataConfig.ItemId),
|
||||
1,
|
||||
uint32(gadget.ConfigId),
|
||||
groupId,
|
||||
int(gadget.VisionLevel),
|
||||
uint32(gadget.ConfigId), groupId, int(gadget.VisionLevel), uint32(gatherDataConfig.GadgetId), uint32(constant.GADGET_STATE_DEFAULT),
|
||||
)
|
||||
} else {
|
||||
gadgetGatherEntity.CreateGadgetGatherEntity(uint32(gatherDataConfig.ItemId))
|
||||
return gadgetGatherEntity.GetId()
|
||||
case constant.GADGET_TYPE_WORKTOP:
|
||||
state := uint8(gadget.State)
|
||||
exist := sceneGroup.CheckGadgetExist(uint32(gadget.ConfigId))
|
||||
if exist {
|
||||
state = sceneGroup.GetGadgetState(uint32(gadget.ConfigId))
|
||||
}
|
||||
return scene.CreateEntityGadgetNormal(
|
||||
gadgetWorktopEntity := scene.CreateEntityGadgetWorktop(
|
||||
&model.Vector{X: float64(gadget.Pos.X), Y: float64(gadget.Pos.Y), Z: float64(gadget.Pos.Z)},
|
||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||
uint32(gadget.GadgetId),
|
||||
uint32(state),
|
||||
false,
|
||||
0,
|
||||
0,
|
||||
uint32(gadget.ConfigId),
|
||||
groupId,
|
||||
int(gadget.VisionLevel),
|
||||
uint32(gadget.ConfigId), groupId, int(gadget.VisionLevel), uint32(gadget.GadgetId), uint32(state),
|
||||
)
|
||||
return gadgetWorktopEntity.GetId()
|
||||
default:
|
||||
state := uint8(gadget.State)
|
||||
exist := sceneGroup.CheckGadgetExist(uint32(gadget.ConfigId))
|
||||
if exist {
|
||||
state = sceneGroup.GetGadgetState(uint32(gadget.ConfigId))
|
||||
}
|
||||
gadgetNormalEntity := scene.CreateEntityGadgetNormal(
|
||||
&model.Vector{X: float64(gadget.Pos.X), Y: float64(gadget.Pos.Y), Z: float64(gadget.Pos.Z)},
|
||||
&model.Vector{X: float64(gadget.Rot.X), Y: float64(gadget.Rot.Y), Z: float64(gadget.Rot.Z)},
|
||||
uint32(gadget.ConfigId), groupId, int(gadget.VisionLevel), uint32(gadget.GadgetId), uint32(state),
|
||||
)
|
||||
return gadgetNormalEntity.GetId()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
@@ -1412,10 +1422,10 @@ func (g *Game) SceneGroupCreateEntity(player *model.Player, groupId uint32, conf
|
||||
switch entityType {
|
||||
case constant.ENTITY_TYPE_MONSTER:
|
||||
// 怪物创建触发器检测
|
||||
g.MonsterCreateTriggerCheck(player, group, configId)
|
||||
g.MonsterCreateTriggerCheck(player, group, entity)
|
||||
case constant.ENTITY_TYPE_GADGET:
|
||||
// 物件创建触发器检测
|
||||
g.GadgetCreateTriggerCheck(player, group, configId)
|
||||
g.GadgetCreateTriggerCheck(player, group, entity)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1436,23 +1446,16 @@ func (g *Game) CreateMonster(player *model.Player, pos *model.Vector, monsterId
|
||||
}
|
||||
rot := new(model.Vector)
|
||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||
entityId := scene.CreateEntityMonster(
|
||||
pos, rot,
|
||||
monsterId, level,
|
||||
0, 0, constant.VISION_LEVEL_NORMAL,
|
||||
)
|
||||
entity := scene.GetEntity(entityId)
|
||||
if entity == nil {
|
||||
return 0
|
||||
}
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||
return entityId
|
||||
monsterEntity := scene.CreateEntityMonster(pos, rot, level, 0, 0, constant.VISION_LEVEL_NORMAL)
|
||||
monsterEntity.CreateMonsterEntity(monsterId)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{monsterEntity.GetId()}, true, false)
|
||||
return monsterEntity.GetId()
|
||||
}
|
||||
|
||||
// CreateGadget 创建物件实体
|
||||
func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId uint32, isDrop bool, itemId, count uint32) uint32 {
|
||||
func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId uint32) uint32 {
|
||||
if gadgetId == 0 {
|
||||
logger.Error("create gadget id is zero, pos: %+v, isDrop: %v, itemId: %v, count: %v, uid: %v", pos, isDrop, itemId, count, player.PlayerId)
|
||||
logger.Error("create gadget id is zero, pos: %+v, uid: %v", pos, player.PlayerId)
|
||||
return 0
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
@@ -1467,19 +1470,33 @@ func (g *Game) CreateGadget(player *model.Player, pos *model.Vector, gadgetId ui
|
||||
}
|
||||
rot := new(model.Vector)
|
||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||
entityId := scene.CreateEntityGadgetNormal(
|
||||
pos, rot,
|
||||
gadgetId, constant.GADGET_STATE_DEFAULT, isDrop, itemId, count,
|
||||
0, 0, constant.VISION_LEVEL_NORMAL,
|
||||
)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||
return entityId
|
||||
gadgetNormalEntity := scene.CreateEntityGadgetNormal(pos, rot, 0, 0, constant.VISION_LEVEL_NORMAL, gadgetId, constant.GADGET_STATE_DEFAULT)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{gadgetNormalEntity.GetId()}, true, false)
|
||||
return gadgetNormalEntity.GetId()
|
||||
}
|
||||
|
||||
// CreateDropGadget 创建掉落物的物件实体
|
||||
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) uint32 {
|
||||
entityId := g.CreateGadget(player, pos, gadgetId, true, itemId, count)
|
||||
return entityId
|
||||
if gadgetId == 0 {
|
||||
logger.Error("create gadget id is zero, pos: %+v, itemId: %v, count: %v, uid: %v", pos, itemId, count, player.PlayerId)
|
||||
return 0
|
||||
}
|
||||
world := WORLD_MANAGER.GetWorldById(player.WorldId)
|
||||
if world == nil {
|
||||
return 0
|
||||
}
|
||||
scene := world.GetSceneById(player.GetSceneId())
|
||||
if pos == nil {
|
||||
pos = g.GetPlayerPos(player)
|
||||
pos.X += random.GetRandomFloat64(-5.0, 5.0)
|
||||
pos.Z += random.GetRandomFloat64(-5.0, 5.0)
|
||||
}
|
||||
rot := new(model.Vector)
|
||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||
gadgetTrifleItemEntity := scene.CreateEntityGadgetTrifleItem(pos, rot, constant.VISION_LEVEL_NORMAL, gadgetId, constant.GADGET_STATE_DEFAULT)
|
||||
gadgetTrifleItemEntity.CreateGadgetTrifleItemEntity(itemId, count)
|
||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{gadgetTrifleItemEntity.GetId()}, true, false)
|
||||
return gadgetTrifleItemEntity.GetId()
|
||||
}
|
||||
|
||||
// GetPosIsInWeatherArea 获取坐标是否在指定的天气区域
|
||||
@@ -1984,7 +2001,19 @@ func (g *Game) PacketSceneEntityInfoGadget(player *model.Player, scene *Scene, e
|
||||
switch entity.(type) {
|
||||
case *GadgetNormalEntity:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoNormal(player, entity),
|
||||
Gadget: g.PacketSceneGadgetInfoNormal(entity.(*GadgetNormalEntity)),
|
||||
}
|
||||
case *GadgetTrifleItemEntity:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoTrifleItem(player, entity.(*GadgetTrifleItemEntity)),
|
||||
}
|
||||
case *GadgetGatherEntity:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoGather(entity.(*GadgetGatherEntity)),
|
||||
}
|
||||
case *GadgetWorktopEntity:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
Gadget: g.PacketSceneGadgetInfoWorktop(entity.(*GadgetWorktopEntity)),
|
||||
}
|
||||
case *GadgetClientEntity:
|
||||
sceneEntityInfo.Entity = &proto.SceneEntityInfo_Gadget{
|
||||
@@ -2074,45 +2103,74 @@ func (g *Game) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo {
|
||||
return sceneNpcInfo
|
||||
}
|
||||
|
||||
func (g *Game) PacketSceneGadgetInfoNormal(player *model.Player, entity IEntity) *proto.SceneGadgetInfo {
|
||||
iGadgetEntity, ok := entity.(IGadgetEntity)
|
||||
if !ok {
|
||||
return new(proto.SceneGadgetInfo)
|
||||
}
|
||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(iGadgetEntity.GetGadgetId()))
|
||||
if gadgetDataConfig == nil {
|
||||
logger.Error("get gadget data config is nil, gadgetId: %v", iGadgetEntity.GetGadgetId())
|
||||
return new(proto.SceneGadgetInfo)
|
||||
}
|
||||
func (g *Game) PacketSceneGadgetInfoNormal(gadgetNormalEntity *GadgetNormalEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: iGadgetEntity.GetGadgetId(),
|
||||
GroupId: entity.GetGroupId(),
|
||||
ConfigId: entity.GetConfigId(),
|
||||
GadgetState: iGadgetEntity.GetGadgetState(),
|
||||
GadgetId: gadgetNormalEntity.GetGadgetId(),
|
||||
GroupId: gadgetNormalEntity.GetGroupId(),
|
||||
ConfigId: gadgetNormalEntity.GetConfigId(),
|
||||
GadgetState: gadgetNormalEntity.GetGadgetState(),
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
}
|
||||
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||
if gadgetNormalEntity.GetIsDrop() {
|
||||
dbItem := player.GetDbItem()
|
||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
||||
TrifleItem: &proto.Item{
|
||||
ItemId: gadgetNormalEntity.GetItemId(),
|
||||
Guid: dbItem.GetItemGuid(gadgetNormalEntity.GetItemId()),
|
||||
Detail: &proto.Item_Material{
|
||||
Material: &proto.Material{
|
||||
Count: gadgetNormalEntity.GetCount(),
|
||||
},
|
||||
return sceneGadgetInfo
|
||||
}
|
||||
|
||||
func (g *Game) PacketSceneGadgetInfoTrifleItem(player *model.Player, gadgetTrifleItemEntity *GadgetTrifleItemEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetTrifleItemEntity.GetGadgetId(),
|
||||
GroupId: gadgetTrifleItemEntity.GetGroupId(),
|
||||
ConfigId: gadgetTrifleItemEntity.GetConfigId(),
|
||||
GadgetState: gadgetTrifleItemEntity.GetGadgetState(),
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
}
|
||||
dbItem := player.GetDbItem()
|
||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_TrifleItem{
|
||||
TrifleItem: &proto.Item{
|
||||
ItemId: gadgetTrifleItemEntity.GetItemId(),
|
||||
Guid: dbItem.GetItemGuid(gadgetTrifleItemEntity.GetItemId()),
|
||||
Detail: &proto.Item_Material{
|
||||
Material: &proto.Material{
|
||||
Count: gadgetTrifleItemEntity.GetCount(),
|
||||
},
|
||||
},
|
||||
}
|
||||
} else if gadgetDataConfig.Type == constant.GADGET_TYPE_GATHER_OBJECT {
|
||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
||||
GatherGadget: &proto.GatherGadgetInfo{
|
||||
ItemId: gadgetNormalEntity.GetItemId(),
|
||||
IsForbidGuest: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
return sceneGadgetInfo
|
||||
}
|
||||
|
||||
func (g *Game) PacketSceneGadgetInfoGather(gadgetGatherEntity *GadgetGatherEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetGatherEntity.GetGadgetId(),
|
||||
GroupId: gadgetGatherEntity.GetGroupId(),
|
||||
ConfigId: gadgetGatherEntity.GetConfigId(),
|
||||
GadgetState: gadgetGatherEntity.GetGadgetState(),
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
}
|
||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_GatherGadget{
|
||||
GatherGadget: &proto.GatherGadgetInfo{
|
||||
ItemId: gadgetGatherEntity.GetItemId(),
|
||||
IsForbidGuest: false,
|
||||
},
|
||||
}
|
||||
return sceneGadgetInfo
|
||||
}
|
||||
|
||||
func (g *Game) PacketSceneGadgetInfoWorktop(gadgetWorktopEntity *GadgetWorktopEntity) *proto.SceneGadgetInfo {
|
||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||
GadgetId: gadgetWorktopEntity.GetGadgetId(),
|
||||
GroupId: gadgetWorktopEntity.GetGroupId(),
|
||||
ConfigId: gadgetWorktopEntity.GetConfigId(),
|
||||
GadgetState: gadgetWorktopEntity.GetGadgetState(),
|
||||
IsEnableInteract: true,
|
||||
AuthorityPeerId: 1,
|
||||
}
|
||||
sceneGadgetInfo.Content = &proto.SceneGadgetInfo_Worktop{
|
||||
Worktop: &proto.WorktopInfo{
|
||||
OptionList: object.ConvMapKeyToList[uint32, struct{}](gadgetWorktopEntity.GetOptionMap()),
|
||||
IsGuestCanOperate: false,
|
||||
},
|
||||
}
|
||||
return sceneGadgetInfo
|
||||
}
|
||||
|
||||
@@ -46,21 +46,21 @@ func (g *Game) CreateVehicleReq(player *model.Player, payloadMsg pb.Message) {
|
||||
// 创建载具实体
|
||||
pos := &model.Vector{X: float64(req.Pos.X), Y: float64(req.Pos.Y), Z: float64(req.Pos.Z)}
|
||||
rot := &model.Vector{X: float64(req.Rot.X), Y: float64(req.Rot.Y), Z: float64(req.Rot.Z)}
|
||||
entityId := scene.CreateEntityGadgetVehicle(player.PlayerId, pos, rot, req.VehicleId)
|
||||
if entityId == 0 {
|
||||
logger.Error("vehicle entityId is 0, uid: %v", player.PlayerId)
|
||||
gadgetVehicleEntity := scene.CreateEntityGadgetVehicle(pos, rot, req.VehicleId)
|
||||
if gadgetVehicleEntity == nil {
|
||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
|
||||
return
|
||||
}
|
||||
GAME.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||
gadgetVehicleEntity.CreateGadgetVehicleEntity(player.PlayerId)
|
||||
GAME.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{gadgetVehicleEntity.GetId()}, true, false)
|
||||
// 记录创建的载具信息
|
||||
player.VehicleInfo.CreateEntityIdMap[req.VehicleId] = entityId
|
||||
player.VehicleInfo.CreateEntityIdMap[req.VehicleId] = gadgetVehicleEntity.GetId()
|
||||
player.VehicleInfo.LastCreateTime = time.Now().UnixMilli()
|
||||
|
||||
// PacketCreateVehicleRsp
|
||||
createVehicleRsp := &proto.CreateVehicleRsp{
|
||||
VehicleId: req.VehicleId,
|
||||
EntityId: entityId,
|
||||
EntityId: gadgetVehicleEntity.GetId(),
|
||||
}
|
||||
g.SendMsg(cmd.CreateVehicleRsp, player.PlayerId, player.ClientSeq, createVehicleRsp)
|
||||
}
|
||||
|
||||
@@ -425,14 +425,14 @@ func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||
case constant.GADGET_TYPE_GADGET, constant.GADGET_TYPE_EQUIP, constant.GADGET_TYPE_ENERGY_BALL:
|
||||
// 掉落物捡起
|
||||
interactType = proto.InteractType_INTERACT_PICK_ITEM
|
||||
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_SUBFIELD_DROP)
|
||||
gadgetTrifleItemEntity := entity.(*GadgetTrifleItemEntity)
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetTrifleItemEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_SUBFIELD_DROP)
|
||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||
case constant.GADGET_TYPE_GATHER_OBJECT:
|
||||
// 采集物摘取
|
||||
interactType = proto.InteractType_INTERACT_GATHER
|
||||
gadgetNormalEntity := entity.(*GadgetNormalEntity)
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetNormalEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_GATHER)
|
||||
gadgetGatherEntity := entity.(*GadgetGatherEntity)
|
||||
g.AddPlayerItem(player.PlayerId, []*ChangeItem{{ItemId: gadgetGatherEntity.GetItemId(), ChangeCount: 1}}, proto.ActionReasonType_ACTION_REASON_GATHER)
|
||||
g.KillEntity(player, scene, entity.GetId(), proto.PlayerDieType_PLAYER_DIE_NONE)
|
||||
case constant.GADGET_TYPE_CHEST:
|
||||
// 宝箱开启
|
||||
@@ -503,6 +503,11 @@ func (g *Game) ExitTransPointRegionNotify(player *model.Player, payloadMsg pb.Me
|
||||
_ = ntf
|
||||
}
|
||||
|
||||
func (g *Game) SelectWorktopOptionReq(player *model.Player, payloadMsg pb.Message) {
|
||||
req := payloadMsg.(*proto.SelectWorktopOptionReq)
|
||||
_ = req
|
||||
}
|
||||
|
||||
/************************************************** 游戏功能 **************************************************/
|
||||
|
||||
// UnlockPlayerScenePoint 解锁场景锚点
|
||||
|
||||
@@ -79,18 +79,18 @@ func ConvRetCodeToBool(v int64) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func ConvListToMap[T any](l []T) map[uint64]T {
|
||||
ret := make(map[uint64]T)
|
||||
for index, value := range l {
|
||||
ret[uint64(index)] = value
|
||||
func ConvMapValueToList[K comparable, V any](m map[K]V) []V {
|
||||
ret := make([]V, 0)
|
||||
for _, value := range m {
|
||||
ret = append(ret, value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func ConvMapToList[T any](m map[uint64]T) []T {
|
||||
ret := make([]T, 0)
|
||||
for _, value := range m {
|
||||
ret = append(ret, value)
|
||||
func ConvMapKeyToList[K comparable, V any](m map[K]V) []K {
|
||||
ret := make([]K, 0)
|
||||
for key := range m {
|
||||
ret = append(ret, key)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -165,6 +165,9 @@ func (c *CmdProtoMap) registerMessage() {
|
||||
c.regMsg(EnterTransPointRegionNotify, func() any { return new(proto.EnterTransPointRegionNotify) }) // 进入传送点区域通知 七天神像区域
|
||||
c.regMsg(ExitTransPointRegionNotify, func() any { return new(proto.ExitTransPointRegionNotify) }) // 离开传送点区域通知
|
||||
c.regMsg(SceneAreaUnlockNotify, func() any { return new(proto.SceneAreaUnlockNotify) }) // 场景区域解锁通知
|
||||
c.regMsg(SelectWorktopOptionReq, func() any { return new(proto.SelectWorktopOptionReq) }) // 操作台选项选择请求
|
||||
c.regMsg(SelectWorktopOptionRsp, func() any { return new(proto.SelectWorktopOptionRsp) }) // 操作台选项选择响应
|
||||
c.regMsg(WorktopOptionNotify, func() any { return new(proto.WorktopOptionNotify) }) // 操作台选项通知
|
||||
|
||||
// 战斗与同步
|
||||
c.regMsg(AvatarFightPropNotify, func() any { return new(proto.AvatarFightPropNotify) }) // 角色战斗属性通知
|
||||
|
||||
Reference in new issue
Block a user