Ejemplo n.º 1
0
        void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
        {
            if (IsTraitDisabled)
            {
                return;
            }

            if (!info.ArmamentNames.Contains(a.Info.Name))
            {
                return;
            }

            var targetPlayer = GetTargetPlayer(target);

            if (targetPlayer != null && targetPlayer.WinState == WinState.Undefined)
            {
                self.World.AddFrameEndTask(w => w.Add(new RevealShroudEffect(self.CenterPosition, info.Radius,
                                                                             info.RevealGeneratedShroud ? Shroud.SourceType.Visibility : Shroud.SourceType.PassiveVisibility, targetPlayer,
                                                                             info.RevealForStancesRelativeToTarget, duration: info.Duration)));
            }
        }
Ejemplo n.º 2
0
 void INotifyAttack.PreparingAttack(Actor self, Target target, Armament a, Barrel barrel)
 {
 }
Ejemplo n.º 3
0
 void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
 {
     ChargeLevel = 0;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 开火
        /// </summary>
        /// <param name="self"></param>
        /// <param name="facing"></param>
        /// <param name="target"></param>
        /// <param name="barrel"></param>
        protected virtual void FireBarrel(Actor self, IFacing facing, Target target, Barrel barrel)
        {
            Func <WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel);//枪口位置

            var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4;

            var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition());
            var initialOffset = Weapon.FirstBurstTargetOffset;

            if (initialOffset != WVec.Zero)
            {
                //We want this to match Armament.LocalOffset,so we need to convert it to forward,right,up.
                //我们希望这个匹配Armament.LocalOffset,所以我们需要将它转换为向前,向上,向右。
                initialOffset  = new WVec(initialOffset.Y, -initialOffset.X, initialOffset.Z);
                passiveTarget += initialOffset.Rotate(WRot.FromFacing(legacyFacing));
            }

            var followingOffset = Weapon.FollowingBurstTargetOffset;

            if (followingOffset != WVec.Zero)
            {
                //We want this to match Armament.LocalOffset,so we need to convert it to forward,right,up.
                followingOffset = new WVec(followingOffset.Y, -followingOffset.X, followingOffset.Z);
                passiveTarget  += ((Weapon.Burst - Burst) * followingOffset).Rotate(WRot.FromFacing(legacyFacing));
            }

            var args = new ProjectileArgs
            {
                Weapon = Weapon,
                Facing = legacyFacing,

                DamagedModifiers = damageModifiers.ToArray(),

                InaccuracyModifiers = inaccuracyModifiers.ToArray(),

                RangeModifiers = rangeModifiers.ToArray(),

                Source = muzzlePosition(),

                CurrentSource = muzzlePosition,

                SourceActor = self,

                PassiveTarget = passiveTarget,

                GuidedTarget = target
            };

            foreach (var na in notifyAttacks)
            {
                na.PreparingAttack(self, target, this, barrel);
            }

            ScheduleDelayedAction(Info.FireDelay, () =>
            {
                if (args.Weapon.Projectile != null)
                {
                    var projectile = args.Weapon.Projectile.Create(args);
                    if (projectile != null)
                    {
                        self.World.Add(projectile);
                    }

                    if (args.Weapon.Report != null && args.Weapon.Report.Any())
                    {
                        WarGame.Sound.Play(SoundType.World, args.Weapon.Report.Random(self.World.SharedRandom), self.CenterPosition);
                    }

                    if (Burst == args.Weapon.Burst && args.Weapon.StartBurstReport != null && args.Weapon.StartBurstReport.Any())
                    {
                        WarGame.Sound.Play(SoundType.World, args.Weapon.StartBurstReport.Random(self.World.SharedRandom), self.CenterPosition);
                    }

                    foreach (var na in notifyAttacks)
                    {
                        na.Attacking(self, target, this, barrel);
                    }

                    Recoil = Info.Recoil;
                }
            });
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 枪口朝向
 /// </summary>
 /// <param name="self"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public WRot MuzzleOrientation(Actor self, Barrel b)
 {
     return(CalculateMuzzleOrientation(self, b));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 枪口偏移
 /// </summary>
 /// <param name="self"></param>
 /// <param name="b"></param>
 /// <returns></returns>
 public WVec MuzzleOffset(Actor self, Barrel b)
 {
     return(CalculateMuzzleOffset(self, b));
 }
Ejemplo n.º 7
0
 void INotifyAttack.Attacking(Actor self, Target target, Armament armament, Barrel barrel)
 {
 }