//拉栓/不按R进行一次自动拉栓 private void DoPull(PlayerWeaponController controller, WeaponSideCmd cmd, bool playPullAudio = true) { if (!throwingActionData.CanPull()) { return; } //生成Entity int renderTime = cmd.UserCmd.RenderTime; var throwAmmunitionCalculator = SingletonManager.Get <ThrowAmmunitionCalculator>(); var dir = throwAmmunitionCalculator.GetFireDir(0, controller, 0); var viewPosition = throwAmmunitionCalculator.GetFireViewPosition(controller); var throwingEntity = ThrowingEntityFactory.CreateThrowingEntity(controller, renderTime, dir, viewPosition, throwCfg.Throwing.GetThrowingInitSpeed(throwingActionData.IsNearThrow), resCfg, throwCfg.Throwing); throwingActionData.SetPull(throwingEntity.entityKey.Value); //弹片特效 if (cmd.UserCmd.IsReload) { controller.AddAuxEffect(EClientEffectType.PullBolt); } if (playPullAudio) { controller.AudioController.PlaySimpleAudio(EAudioUniqueId.GrenadeTrigger, true); } }
public static void CleanThrowingState(this ThrowingActionData actionData, bool interrupt = false) { if (actionData.IsPull) { //若已拉栓,销毁ThrowingEntity ThrowingEntityFactory.DestroyThrowing(actionData.ThrowingEntityKey); } actionData.IsReady = false; actionData.InternalCleanUp(interrupt); }
protected override void OnGamePlay(PlayerEntity entity) { var throwAction = entity.throwingAction.ActionData; if (throwAction.ThrowingPrepare && entity.playerClientUpdate.DestoryPreparedThrowingEntity) { var throwing = ThrowingEntityFactory.GetEntityWithEntityKey(throwAction.ThrowingEntityKey); if (null != throwing) { throwing.isFlagDestroy = true; } entity.stateInterface.State.ForceFinishGrenadeThrow(); throwAction.InternalCleanUp(); } }
public EntityKey CreateThrowing(PlayerWeaponController controller, Vector3 direction, int renderTime, float initVel) { var throwingEntity = ThrowingEntityFactory.CreateThrowingEntity( _throwingContext, _entityIdGenerator, controller, renderTime, direction, initVel, _newWeaponConfig, _config); _logger.InfoFormat("CreateThrowing from {0} with velocity {1}, entity key {2}", throwingEntity.position.Value, throwingEntity.throwingData.Velocity, throwingEntity.entityKey); return(throwingEntity.entityKey.Value); }
//投掷 private void DoThrowing(PlayerWeaponController controller, WeaponSideCmd cmd, Contexts contexts) { if (!throwingActionData.CanThrow()) { return; } if (!throwingActionData.IsPull) { DoPull(controller, cmd, false); } var handPos = controller.HandPos; DebugUtil.MyLog("Throw"); throwingActionData.SetThrow(handPos); ThrowingEntityFactory.StartThrowingEntityFly(throwingActionData.ThrowingEntityKey, true, throwCfg.Throwing.GetThrowingInitSpeed(throwingActionData.IsNearThrow)); //投掷动作 characterState.FinishGrenadeThrow(); //状态重置 if (controller.RelatedThrowUpdate != null) { controller.RelatedThrowUpdate.ReadyFly = false; } //投掷型物品使用数量 controller.RelatedStatisticsData.UseThrowingCount++; controller.RelatedAppearence.UnmountWeaponFromHand(); controller.RelatedAppearence.UnmountWeaponInPackage(WeaponInPackage.ThrownWeapon); if (SharedConfig.IsServer) { FreeRuleEventArgs args = contexts.session.commonSession.FreeArgs as FreeRuleEventArgs; (args.Rule as IGameRule).HandleWeaponFire(contexts, contexts.player.GetEntityWithEntityKey(controller.Owner), resCfg); (args.Rule as IGameRule).HandleWeaponState(contexts, contexts.player.GetEntityWithEntityKey(controller.Owner), resCfg.Id); } controller.AudioController.PlaySimpleAudio(EAudioUniqueId.GrenadeThrow, true); }