Esempio n. 1
0
        public void PrepareHitByUnblockedWeapon(SendHitToServerIfNeedEvent evt, UnblockedWeaponNode weapon)
        {
            DirectionData bestDirection = evt.TargetingData.BestDirection;

            if (bestDirection.HasAnyHit())
            {
                SplashHitData splashHit = SplashHitData.CreateSplashHitData(HitTargetAdapter.Adapt(bestDirection.Targets), bestDirection.StaticHit, weapon.Entity);
                base.ScheduleEvent(new CollectSplashTargetsEvent(splashHit), weapon);
            }
        }
Esempio n. 2
0
        public void SendHit(SendHitToServerIfNeedEvent evt, UnblockedWeaponNode weapon)
        {
            WeaponHitComponent weaponHit = weapon.weaponHit;
            StaticHit          staticHit = null;
            List <HitTarget>   targets   = new List <HitTarget>(4);

            if (evt.TargetingData.HasTargetHit())
            {
                if (!weaponHit.RemoveDuplicateTargets)
                {
                    targets = HitTargetAdapter.Adapt(evt.TargetingData.BestDirection.Targets);
                }
                else
                {
                    HashSet <Entity> set = new HashSet <Entity>();
                    int num = 0;
                    while (num < evt.TargetingData.Directions.Count)
                    {
                        DirectionData data = evt.TargetingData.Directions[num];
                        int           num2 = 0;
                        while (true)
                        {
                            if (num2 >= data.Targets.Count)
                            {
                                num++;
                                break;
                            }
                            TargetData targetData = data.Targets[num2];
                            if (set.Add(targetData.TargetEntity))
                            {
                                targets.Add(HitTargetAdapter.Adapt(targetData));
                            }
                            num2++;
                        }
                    }
                }
            }
            if (weaponHit.SendStaticHit && evt.TargetingData.HasStaticHit())
            {
                staticHit = evt.TargetingData.BestDirection.StaticHit;
            }
            if ((staticHit == null) && (targets.Count == 0))
            {
                base.ScheduleEvent <SelfHitSkipEvent>(weapon);
            }
            else
            {
                base.ScheduleEvent(new SendHitToServerEvent(evt.TargetingData, targets, staticHit), weapon);
            }
        }