From a18222f363826ca263c4709b4022bf7cc0474b79 Mon Sep 17 00:00:00 2001 From: UnKownOwO <80520429@qq.com> Date: Mon, 19 Dec 2022 17:39:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E9=94=80=E6=AF=81=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gs/game/user_fight_sync.go | 16 ++++++++++------ gs/game/user_vehicle.go | 11 +++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/gs/game/user_fight_sync.go b/gs/game/user_fight_sync.go index 9ef01093..54a5a0a5 100644 --- a/gs/game/user_fight_sync.go +++ b/gs/game/user_fight_sync.go @@ -119,6 +119,9 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p player.Rot.X = float64(motionInfo.Rot.X) player.Rot.Y = float64(motionInfo.Rot.Y) player.Rot.Z = float64(motionInfo.Rot.Z) + + // 处理耐力消耗 + g.ImmediateStamina(player, motionInfo.State) } else { // 非玩家实体在移动 更新场景实体的位置信息 sceneEntity.pos = &model.Vector{ @@ -131,17 +134,18 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p Y: float64(motionInfo.Rot.Y), Z: float64(motionInfo.Rot.Z), } + // 载具耐力消耗 + if sceneEntity.gadgetEntity != nil && sceneEntity.gadgetEntity.gadgetVehicleEntity != nil { + // 处理耐力消耗 + g.ImmediateStamina(player, motionInfo.State) + // 处理载具销毁请求 + g.VehicleDestroyMotion(player, sceneEntity, motionInfo.State) + } } sceneEntity.moveState = uint16(motionInfo.State) sceneEntity.lastMoveSceneTimeMs = entityMoveInfo.SceneTime sceneEntity.lastMoveReliableSeq = entityMoveInfo.ReliableSeq - // 角色和载具的耐力消耗 - if sceneEntity.avatarEntity != nil || (sceneEntity.gadgetEntity != nil && sceneEntity.gadgetEntity.gadgetVehicleEntity != nil) { - // 处理耐力消耗 - g.ImmediateStamina(player, motionInfo.State) - } - player.CombatInvokeHandler.AddEntry(entry.ForwardType, entry) case proto.CombatTypeArgument_COMBAT_TYPE_ARGUMENT_ANIMATOR_STATE_CHANGED: evtAnimatorStateChangedInfo := new(proto.EvtAnimatorStateChangedInfo) diff --git a/gs/game/user_vehicle.go b/gs/game/user_vehicle.go index 90edd297..dbfbe6d4 100644 --- a/gs/game/user_vehicle.go +++ b/gs/game/user_vehicle.go @@ -11,6 +11,17 @@ import ( pb "google.golang.org/protobuf/proto" ) +// VehicleDestroyMotion 载具销毁动作 +func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) { + world := WORLD_MANAGER.GetWorldByID(player.WorldId) + scene := world.GetSceneById(player.SceneId) + + // 状态等于 MOTION_STATE_DESTROY_VEHICLE 代表请求销毁 + if state == proto.MotionState_MOTION_STATE_DESTROY_VEHICLE { + g.DestroyVehicleEntity(player, scene, entity.gadgetEntity.gadgetVehicleEntity.vehicleId, entity.id) + } +} + // CreateVehicleReq 创建载具 func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Message) { req := payloadMsg.(*proto.CreateVehicleReq)