protected override bool ListenBulletHit(EvtBulletHit evt)
        {
            if (!base._bulletAttackDatas.ContainsKey(evt.targetID))
            {
                return(false);
            }
            BaseMPIdentity identity = Singleton <MPManager> .Instance.TryGetIdentity(evt.otherID);

            if (((identity != null) && !identity.isAuthority) && !identity.remoteMode.IsRemoteReceive())
            {
                return(false);
            }
            AttackData attackData = base._bulletAttackDatas[evt.targetID];

            attackData.isFromBullet = true;
            bool           flag   = base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage;
            bool           flag2  = (base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage) || (base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDamageHitTarget);
            bool           flag3  = true;
            bool           flag4  = base.baseConfig.BulletHitType == BulletHitBehavior.NoDestroyAndRefresh;
            BaseMonoEntity entity = Singleton <EventManager> .Instance.GetEntity(evt.otherID);

            BaseAbilityActor actor = Singleton <EventManager> .Instance.GetActor(evt.otherID) as BaseAbilityActor;

            if ((entity is MonoDummyDynamicObject) || ((identity != null) && !identity.remoteMode.IsRemoteReceive()))
            {
                flag2 = false;
                flag  = false;
                flag3 = false;
                flag4 = false;
            }
            else if (evt.hitEnvironment)
            {
                flag2 = true;
                flag4 = false;
            }
            else if ((!evt.cannotBeReflected && (actor != null)) && actor.abilityState.ContainsState(AbilityState.ReflectBullet))
            {
                Singleton <EventManager> .Instance.FireEvent(new EvtAfterBulletReflected(evt.otherID, evt.targetID, base.actor.runtimeID, base._bulletAttackDatas[evt.targetID]), MPEventDispatchMode.Normal);

                return(false);
            }
            AbilityTriggerBullet bulletActor = Singleton <EventManager> .Instance.GetActor <AbilityTriggerBullet>(evt.targetID);

            if (flag2)
            {
                bulletActor.Kill();
                base._bulletAttackDatas.Remove(evt.targetID);
            }
            else
            {
                attackData = attackData.Clone();
            }
            if (flag4)
            {
                bulletActor.triggerBullet.ResetInside(base.baseConfig.ResetTime);
            }
            base._evtsLs.Clear();
            if (evt.hitEnvironment)
            {
                if (!evt.hitGround)
                {
                    return(true);
                }
                EvtHittingOther item = new EvtHittingOther(base.actor.runtimeID, evt.otherID, attackData)
                {
                    hitCollision = evt.hitCollision
                };
                base._evtsLs.Add(item);
            }
            else
            {
                attackData.hitCollision = evt.hitCollision;
                base._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, evt.otherID, base.baseConfig.HitAnimEventID, attackData));
            }
            if (flag)
            {
                List <CollisionResult> list = CollisionDetectPattern.CylinderCollisionDetectBySphere(evt.hitCollision.hitPoint, evt.hitCollision.hitPoint, base.instancedAbility.Evaluate(base.baseConfig.HitExplodeRadius), 1f, Singleton <EventManager> .Instance.GetAbilityHitboxTargettingMask(base.actor.runtimeID, base.baseConfig.Targetting));
                float y = evt.hitCollision.hitPoint.y;
                for (int j = 0; j < list.Count; j++)
                {
                    CollisionResult result = list[j];
                    BaseMonoEntity  collisionResultEntity = AttackPattern.GetCollisionResultEntity(result.entity);
                    if ((collisionResultEntity != null) && (collisionResultEntity.GetRuntimeID() != evt.otherID))
                    {
                        result.hitPoint.y = y;
                        AttackData data2 = attackData.Clone();
                        AttackResult.HitCollsion collsion = new AttackResult.HitCollsion {
                            hitDir   = result.hitForward,
                            hitPoint = result.hitPoint
                        };
                        data2.hitCollision = collsion;
                        base._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, collisionResultEntity.GetRuntimeID(), base.baseConfig.HitAnimEventID, data2));
                    }
                }
            }
            if (flag3)
            {
                Vector3 hitPoint = evt.hitCollision.hitPoint;
                if (base.baseConfig.ExplodeEffectGround)
                {
                    hitPoint.y = 0f;
                }
                Vector3 hitDir = evt.hitCollision.hitDir;
                hitDir.y = 0f;
                base.FireTriggerBulletHitExplodeEffect(bulletActor, hitPoint, hitDir, false);
            }
            if (base.baseConfig.HitExplodeActions.Length > 0)
            {
                for (int k = 0; k < base._evtsLs.Count; k++)
                {
                    base.actor.abilityPlugin.HandleActionTargetDispatch(base.baseConfig.HitExplodeActions, base.instancedAbility, base.instancedModifier, Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(base._evtsLs[k].toID), evt);
                }
            }
            for (int i = 0; i < base._evtsLs.Count; i++)
            {
                EvtHittingOther other2 = base._evtsLs[i];
                AttackPattern.SendHitEvent(base.actor.runtimeID, other2.toID, other2.animEventID, other2.hitCollision, other2.attackData, false, MPEventDispatchMode.CheckRemoteMode);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private static List <CollisionResult> FilterRealAttackeesByBodyParts(string attackName, ConfigEntityAttackPattern patternConfig, IAttacker attacker, List <CollisionResult> results)
        {
            ConfigEntityAttackPattern pattern = patternConfig;
            Dictionary <BaseMonoEntity, List <CollisionResult> > dictionary = new Dictionary <BaseMonoEntity, List <CollisionResult> >();
            List <CollisionResult> list = new List <CollisionResult>();

            foreach (CollisionResult result in results)
            {
                BaseMonoEntity entity = result.entity;
                if (entity != null)
                {
                    if (entity is MonoBodyPartEntity)
                    {
                        BaseMonoEntity owner = ((MonoBodyPartEntity)entity).owner;
                        if (!dictionary.ContainsKey(owner))
                        {
                            dictionary[owner] = new List <CollisionResult>();
                        }
                        dictionary[owner].Add(result);
                    }
                    else
                    {
                        list.Add(result);
                    }
                }
            }
            List <CollisionResult> list3 = new List <CollisionResult>();

            foreach (CollisionResult result2 in list)
            {
                if (!dictionary.ContainsKey(result2.entity))
                {
                    list3.Add(result2);
                }
            }
            foreach (BaseMonoEntity entity3 in dictionary.Keys)
            {
                CollisionResult result3 = null;
                if (((pattern is FanCollisionDetect) || (pattern is CylinderCollisionDetect)) || ((pattern is CylinderCollisionDetectTargetLocked) || (pattern is RectCollisionDetect)))
                {
                    Vector3 b = new Vector3();
                    if (pattern is RectCollisionDetect)
                    {
                        RectCollisionDetect detect        = (RectCollisionDetect)pattern;
                        Vector3             vector2       = new Vector3(attacker.XZPosition.x, 0f, attacker.XZPosition.z);
                        Vector3             faceDirection = attacker.FaceDirection;
                        faceDirection.y = 0f;
                        b = vector2 + ((Vector3)(detect.OffsetZ * faceDirection.normalized));
                    }
                    else
                    {
                        b = attacker.XZPosition;
                    }
                    float maxValue = float.MaxValue;
                    foreach (CollisionResult result4 in dictionary[entity3])
                    {
                        float num2 = Vector3.Distance(result4.entity.XZPosition, b);
                        if (num2 < maxValue)
                        {
                            result3  = result4;
                            maxValue = num2;
                        }
                    }
                }
                else
                {
                    result3 = dictionary[entity3][0];
                }
                CollisionResult item = new CollisionResult(entity3, result3.hitPoint, result3.hitForward);
                list3.Add(item);
            }
            return(list3);
        }
Ejemplo n.º 3
0
        protected virtual bool ListenBulletHit(EvtBulletHit evt)
        {
            if (!this._bulletAttackDatas.ContainsKey(evt.targetID))
            {
                return(false);
            }
            AttackData attackData = this._bulletAttackDatas[evt.targetID];

            attackData.isFromBullet = true;
            bool           flag   = this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage;
            bool           flag2  = (this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage) || (this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDamageHitTarget);
            bool           flag3  = true;
            bool           flag4  = this.baseConfig.BulletHitType == BulletHitBehavior.NoDestroyAndRefresh;
            BaseMonoEntity entity = Singleton <EventManager> .Instance.GetEntity(evt.otherID);

            BaseAbilityActor actor = Singleton <EventManager> .Instance.GetActor(evt.otherID) as BaseAbilityActor;

            if (entity is MonoDummyDynamicObject)
            {
                flag2 = false;
                flag  = false;
                flag3 = false;
                flag4 = false;
            }
            else if (evt.hitEnvironment)
            {
                flag2 = true;
                flag4 = false;
            }
            else if ((!evt.cannotBeReflected && (actor != null)) && actor.abilityState.ContainsState(AbilityState.ReflectBullet))
            {
                Singleton <EventManager> .Instance.FireEvent(new EvtAfterBulletReflected(evt.otherID, evt.targetID, base.actor.runtimeID, this._bulletAttackDatas[evt.targetID]), MPEventDispatchMode.Normal);

                return(false);
            }
            AbilityTriggerBullet bulletActor = Singleton <EventManager> .Instance.GetActor <AbilityTriggerBullet>(evt.targetID);

            if (flag2)
            {
                if (bulletActor != null)
                {
                    bulletActor.Kill();
                }
                this._bulletAttackDatas.Remove(evt.targetID);
            }
            else
            {
                attackData = attackData.Clone();
            }
            if (flag4 && (bulletActor != null))
            {
                bulletActor.triggerBullet.ResetInside(this.baseConfig.ResetTime);
            }
            this._evtsLs.Clear();
            if (evt.hitEnvironment)
            {
                if (!evt.hitGround)
                {
                    return(true);
                }
                EvtHittingOther item = new EvtHittingOther(base.actor.runtimeID, evt.otherID, attackData)
                {
                    hitCollision = evt.hitCollision
                };
                this._evtsLs.Add(item);
            }
            else
            {
                attackData.hitCollision = evt.hitCollision;
                this._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, evt.otherID, this.baseConfig.HitAnimEventID, attackData));
            }
            if (flag)
            {
                List <CollisionResult> list = CollisionDetectPattern.CylinderCollisionDetectBySphere(evt.hitCollision.hitPoint, evt.hitCollision.hitPoint, base.instancedAbility.Evaluate(this.baseConfig.HitExplodeRadius), 1f, Singleton <EventManager> .Instance.GetAbilityHitboxTargettingMask(base.actor.runtimeID, this.baseConfig.Targetting));
                float y = evt.hitCollision.hitPoint.y;
                for (int j = 0; j < list.Count; j++)
                {
                    CollisionResult result = list[j];
                    BaseMonoEntity  collisionResultEntity = AttackPattern.GetCollisionResultEntity(result.entity);
                    if ((collisionResultEntity != null) && (collisionResultEntity.GetRuntimeID() != evt.otherID))
                    {
                        result.hitPoint.y = y;
                        AttackData data2 = attackData.Clone();
                        AttackResult.HitCollsion collsion = new AttackResult.HitCollsion {
                            hitDir   = result.hitForward,
                            hitPoint = result.hitPoint
                        };
                        data2.hitCollision = collsion;
                        this._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, collisionResultEntity.GetRuntimeID(), this.baseConfig.HitAnimEventID, data2));
                    }
                }
            }
            if (flag3)
            {
                Vector3 hitPoint = evt.hitCollision.hitPoint;
                if (this.baseConfig.ExplodeEffectGround)
                {
                    hitPoint.y = 0f;
                }
                Vector3 hitDir = evt.hitCollision.hitDir;
                hitDir.y = 0f;
                bool selfExplode = evt.selfExplode;
                if (bulletActor != null)
                {
                    this.FireTriggerBulletHitExplodeEffect(bulletActor, hitPoint, hitDir, selfExplode);
                }
            }
            if ((this.baseConfig.HitExplodeActions.Length > 0) && (!evt.selfExplode || !this.baseConfig.MuteSelfHitExplodeActions))
            {
                for (int k = 0; k < this._evtsLs.Count; k++)
                {
                    if (base.actor.abilityPlugin != null)
                    {
                        base.actor.abilityPlugin.HandleActionTargetDispatch(this.baseConfig.HitExplodeActions, base.instancedAbility, base.instancedModifier, Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(this._evtsLs[k].toID), evt);
                    }
                }
            }
            for (int i = 0; i < this._evtsLs.Count; i++)
            {
                EvtHittingOther other2 = this._evtsLs[i];
                if (this.baseConfig.IsHitChangeTargetDirection && (other2.attackData.hitEffect >= AttackResult.AnimatorHitEffect.ThrowUp))
                {
                    BaseAbilityActor actor2 = Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(other2.toID);

                    if (actor2 != null)
                    {
                        actor2.entity.transform.forward = -other2.attackData.hitCollision.hitDir;
                    }
                }
                Singleton <EventManager> .Instance.FireEvent(other2, MPEventDispatchMode.Normal);
            }
            return(true);
        }