public void Update(EntityKey ownerKey, int frameTime) { _allThrowingSegments.Clear(); foreach (ThrowingEntity throwing in _throwings.GetEntities()) { if (throwing.ownerId.Value != ownerKey) { CheckVisible(throwing); continue; } if (throwing.isFlagDestroy) { continue; } PlayerEntity player = _contexts.player.GetEntityWithEntityKey(throwing.ownerId.Value); //销毁被中断的手雷 if (null != player && player.throwingAction.ActionInfo.IsInterrupt && player.throwingAction.ActionInfo.ThrowingEntityKey == throwing.entityKey.Value) { player.throwingAction.ActionInfo.IsInterrupt = false; throwing.isFlagDestroy = true; continue; } if (throwing.hasLifeTime && (DateTime.Now - throwing.lifeTime.CreateTime).TotalMilliseconds > throwing.throwingData.Config.CountdownTime) { //爆炸 ExplosionEffect(throwing); //伤害 if (SharedConfig.IsOffline || SharedConfig.IsServer) { BombingHandler(throwing); } throwing.isFlagDestroy = true; if (!throwing.throwingData.IsFly) { player.stateInterface.State.FinishGrenadeThrow(); CastGrenade(player); } continue; } if (throwing.throwingData.IsThrow && !throwing.throwingData.IsFly && null != player && player.throwingUpdate.IsStartFly && !throwing.isFlagDestroy) { //开始飞出 StartFlying(player, throwing); } if (throwing.throwingData.IsFly) { CheckVisible(throwing); bool isInWater = throwing.throwingData.IsInWater; var segments = _moveSimulator.MoveThrowing(throwing, frameTime); if (null != segments) { _allThrowingSegments.AddRange(segments); } //入水特效 throwing.throwingData.IsInWater = SingletonManager.Get <MapConfigManager>().InWater(throwing.position.Value); if (!isInWater && throwing.throwingData.IsInWater) { PlayOneEffect(throwing, throwing.throwingData.Config.EnterWaterEffectId, throwing.position.Value, false); } } else if (null != player) { Vector3 pos = PlayerEntityUtility.GetHandWeaponPosition(player); throwing.position.Value = pos; } } _allThrowingSegments.Sort(_comparator); if (_newRaycast) { NewRaycast(); } else { OldRaycast(); } }
public void Update(EntityKey ownerKey, int frameTime) { _allThrowingSegments.Clear(); foreach (ThrowingEntity throwing in _throwings.GetEntities()) { if (throwing.isFlagDestroy) { continue; } if (throwing.ownerId.Value != ownerKey) { CheckVisible(throwing); continue; } PlayerEntity player = _contexts.player.GetEntityWithEntityKey(throwing.ownerId.Value); if (throwing.CanExplosion()) { //爆炸 ExplosionEffect(throwing); //伤害 if (SharedConfig.IsOffline || SharedConfig.IsServer) { BombingHandler(throwing); } if (!throwing.throwingData.IsFly) { if (SharedConfig.IsServer) { FreeRuleEventArgs args = _contexts.session.commonSession.FreeArgs as FreeRuleEventArgs; (args.Rule as IGameRule).HandleWeaponFire(_contexts, player, throwing.throwingData.WeaonConfig); (args.Rule as IGameRule).HandleWeaponState(_contexts, player, throwing.throwingData.WeaonConfig.Id); } player.WeaponController().RelatedStatisticsData.UseThrowingCount++; player.stateInterface.State.ForceFinishGrenadeThrow(); AfterAttack(_contexts, player); player.WeaponController().AutoStuffGrenade(); } throwing.isFlagDestroy = true; continue; } if (player != null && player.throwingUpdate.ReadyFly && throwing.CanStartFlySimulation()) { //开始飞出 StartFlying(player, throwing); } if (throwing.throwingData.IsFly) { CheckVisible(throwing); bool isInWater = throwing.throwingData.IsInWater; var segments = _moveSimulator.MoveThrowing(throwing, frameTime); if (null != segments) { _allThrowingSegments.AddRange(segments); } //入水特效 throwing.throwingData.IsInWater = SingletonManager.Get <MapConfigManager>().InWater(throwing.position.Value); if (!isInWater && throwing.throwingData.IsInWater) { PlayOneEffect(throwing, throwing.throwingData.ThrowConfig.EnterWaterEffectId, throwing.position.Value, false); } } else if (null != player) { Vector3 pos = PlayerEntityUtility.GetHandWeaponPosition(player); throwing.position.Value = pos; } } _allThrowingSegments.Sort(_comparator); if (_newRaycast) { NewRaycast(); } else { OldRaycast(); } }