Пример #1
0
    // Token: 0x06000E59 RID: 3673 RVA: 0x00066A80 File Offset: 0x00064C80
    private void Destroy()
    {
        IDestructible component = base.GetComponent <IDestructible>();

        if (component != null)
        {
            HitData hitData = new HitData();
            hitData.m_damage.m_damage = 9999f;
            component.Damage(hitData);
        }
    }
Пример #2
0
        private static bool ExplodeDestructible(ExplosionGrenade __instance, IDestructible dest, Footprinting.Footprint attacker, Vector3 pos, ExplosionGrenade setts, out bool __result)
        {
            __result = false;
            try
            {
                if (Physics.Linecast(dest.CenterOfMass, pos, InventorySystem.Items.MicroHID.MicroHIDItem.WallMask))
                {
                    return(false);
                }
                Vector3      a         = dest.CenterOfMass - pos;
                float        magnitude = a.magnitude;
                float        num       = setts._playerDamageOverDistance.Evaluate(magnitude);
                ReferenceHub referenceHub;
                bool         flag = ReferenceHub.TryGetHubNetID(dest.NetworkId, out referenceHub);
                if (flag && referenceHub.characterClassManager.CurRole.team == Team.SCP)
                {
                    num *= setts._scpDamageMultiplier;
                }
                Vector3 force = (1f - magnitude / setts._maxRadius) * (a / magnitude) * setts._rigidbodyLiftForce + Vector3.up * setts._rigidbodyLiftForce;
                if (num > 0f && dest.Damage(num, new PlayerStatsSystem.ExplosionDamageHandler(attacker, force, num, 50), dest.CenterOfMass) && flag)
                {
                    float num2  = setts._effectDurationOverDistance.Evaluate(magnitude);
                    bool  flag2 = attacker.Hub == referenceHub;
                    if (num2 > 0f && (flag2 || HitboxIdentity.CheckFriendlyFire(attacker.Hub, referenceHub, false)))
                    {
                        float minimalDuration = setts._minimalDuration;
                        ExplosionGrenade.TriggerEffect <CustomPlayerEffects.Burned>(referenceHub, num2 * setts._burnedDuration, minimalDuration);
                        ExplosionGrenade.TriggerEffect <CustomPlayerEffects.Deafened>(referenceHub, num2 * setts._deafenedDuration, minimalDuration);
                        ExplosionGrenade.TriggerEffect <CustomPlayerEffects.Concussed>(referenceHub, num2 * setts._concussedDuration, minimalDuration);
                    }
                    if (!flag2 && attacker.Hub != null)
                    {
                        Hitmarker.SendHitmarker(attacker.Hub, 1f);
                    }
                    referenceHub.inventory.connectionToClient.Send(new GunHitMessage(false, num, pos), 0);
                }

                __result = true;
                return(false);
            }
            catch (Exception ex)
            {
                Logger.Get.Error($"Synapse-FF: ExplodeDestructible failed!!\n{ex}");
                return(true);
            }
        }
Пример #3
0
            public static bool Prefix(Projectile __instance, ref Collider collider, Vector3 hitPoint)
            {
                if (__instance.name.Contains(customProjectileName))
                {
                    GameObject    gameObject   = (collider ? Projectile.FindHitObject(collider) : null);
                    IDestructible destructible = (gameObject ? gameObject.GetComponent <IDestructible>() : null);
                    if (destructible != null)
                    {
                        bool hitCharacter = false;
                        bool hitValid     = (bool)typeof(Projectile).GetMethod("IsValidTarget", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { destructible, hitCharacter });
                        if (!hitValid)
                        {
                            return(true);
                        }
                        HitData hitData = new HitData();
                        hitData.m_hitCollider = collider;
                        hitData.m_damage      = __instance.m_damage.Clone();
                        hitData.m_toolTier    = __instance.m_damage.m_chop == darkChopDamage ? 2 : 0;
                        if ((destructible is Character character) && !treelikeCreatures.Contains(character.m_name))
                        {
                            hitData.m_damage.m_pierce = 0;
                        }
                        hitData.m_pushForce     = 20;
                        hitData.m_backstabBonus = 3;
                        hitData.m_point         = hitPoint;
                        hitData.m_dir           = __instance.transform.forward;
                        hitData.m_dodgeable     = true;
                        hitData.m_blockable     = true;
                        hitData.m_skill         = MagicSkill.MagicSkillDef.m_skill;
                        var owner = (Character)typeof(Projectile).GetField("m_owner", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(__instance);
                        hitData.SetAttacker(owner);
                        destructible.Damage(hitData);

                        __instance.m_hitEffects.Create(hitPoint, Quaternion.identity);
                        if (__instance.m_hitNoise > 0f)
                        {
                            BaseAI.DoProjectileHitNoise(__instance.transform.position, __instance.m_hitNoise, owner);
                        }
                        ((ZNetView)typeof(Projectile).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(__instance)).InvokeRPC("OnHit");
                        ZNetScene.instance.Destroy(__instance.gameObject);
                        return(false);
                    }
                }
                return(true);
            }
Пример #4
0
    // Implement IInteractable
    // directed interaction
    public void Interact(GameObject interactor, Vector3 direction)
    {
        // Blocking moving objects are implemented through
        // doing some ZERO VIRTUAL DAMAGE to interactors.
        // but only the interaction occur with front of blocking
        // cube - i.e. object normal direction at collision
        // point should be (-1, 0, 0)

        // Get IDestructible interface of interactor
        IDestructible destructible = interactor.GetComponent <IDestructible>();

        // if is destructible, and direction is corresponding
        if (destructible != null && direction.x == -1)
        {
            // Inflict ZERO VIRTUAL DAMAGE to the interactor
            destructible.Damage(0, DamageType.VIRTUAL);
        }
    }
Пример #5
0
    // IInteractable implementation
    public void Interact(GameObject interactor)
    {
        // only if fire is burning
        if (!isBurning)
        {
            return;
        }

        // if interactor is destructible
        IDestructible destructible = interactor.GetComponent <IDestructible>();

        if (destructible != null)
        {
            // do fire damage / destruct interacting object
            destructible.Damage(10, DamageType.FIRE);
            // only once
            isBurning = false;
            // rise up block... Just to show in scene what happens
            gameObject.transform.position += new Vector3(0f, .25f, 0f);
        }
    }
Пример #6
0
    // Token: 0x06000306 RID: 774 RVA: 0x00019C28 File Offset: 0x00017E28
    private void DoAOE(Vector3 hitPoint, ref bool hitCharacter, ref bool didDamage)
    {
        Collider[]           array   = Physics.OverlapSphere(hitPoint, this.m_aoe, Projectile.m_rayMaskSolids, QueryTriggerInteraction.UseGlobal);
        HashSet <GameObject> hashSet = new HashSet <GameObject>();

        foreach (Collider collider in array)
        {
            GameObject    gameObject = Projectile.FindHitObject(collider);
            IDestructible component  = gameObject.GetComponent <IDestructible>();
            if (component != null && !hashSet.Contains(gameObject))
            {
                hashSet.Add(gameObject);
                if (this.IsValidTarget(component, ref hitCharacter))
                {
                    Vector3 vector  = collider.ClosestPointOnBounds(hitPoint);
                    Vector3 vector2 = (Vector3.Distance(vector, hitPoint) > 0.1f) ? (vector - hitPoint) : this.m_vel;
                    vector2.y = 0f;
                    vector2.Normalize();
                    HitData hitData = new HitData();
                    hitData.m_hitCollider   = collider;
                    hitData.m_damage        = this.m_damage;
                    hitData.m_pushForce     = this.m_attackForce;
                    hitData.m_backstabBonus = this.m_backstabBonus;
                    hitData.m_point         = vector;
                    hitData.m_dir           = vector2.normalized;
                    hitData.m_statusEffect  = this.m_statusEffect;
                    hitData.m_dodgeable     = this.m_dodgeable;
                    hitData.m_blockable     = this.m_blockable;
                    hitData.m_skill         = this.m_skill;
                    hitData.SetAttacker(this.m_owner);
                    component.Damage(hitData);
                    didDamage = true;
                }
            }
        }
    }
Пример #7
0
    // Token: 0x06000434 RID: 1076 RVA: 0x000220CC File Offset: 0x000202CC
    public void OnCollisionEnter(Collision info)
    {
        if (!this.m_nview.IsValid())
        {
            return;
        }
        if (this.m_nview && !this.m_nview.IsOwner())
        {
            return;
        }
        if (info.contacts.Length == 0)
        {
            return;
        }
        if (!this.m_hitEffectEnabled)
        {
            return;
        }
        if ((this.m_triggerMask.value & 1 << info.collider.gameObject.layer) == 0)
        {
            return;
        }
        float magnitude = info.relativeVelocity.magnitude;

        if (magnitude < this.m_minVelocity)
        {
            return;
        }
        ContactPoint contactPoint  = info.contacts[0];
        Vector3      point         = contactPoint.point;
        Vector3      pointVelocity = this.m_body.GetPointVelocity(point);

        this.m_hitEffectEnabled = false;
        base.Invoke("ResetHitTimer", this.m_interval);
        if (this.m_damages.HaveDamage())
        {
            GameObject    gameObject = Projectile.FindHitObject(contactPoint.otherCollider);
            float         num        = Utils.LerpStep(this.m_minVelocity, this.m_maxVelocity, magnitude);
            IDestructible component  = gameObject.GetComponent <IDestructible>();
            if (component != null)
            {
                Character character = component as Character;
                if (character)
                {
                    if (!this.m_damagePlayers && character.IsPlayer())
                    {
                        return;
                    }
                    float num2 = Vector3.Dot(-info.relativeVelocity.normalized, pointVelocity);
                    if (num2 < this.m_minVelocity)
                    {
                        return;
                    }
                    ZLog.Log("Rel vel " + num2);
                    num = Utils.LerpStep(this.m_minVelocity, this.m_maxVelocity, num2);
                    if (character.GetSEMan().HaveStatusAttribute(StatusEffect.StatusAttribute.DoubleImpactDamage))
                    {
                        num *= 2f;
                    }
                }
                if (!this.m_damageFish && gameObject.GetComponent <Fish>())
                {
                    return;
                }
                HitData hitData = new HitData();
                hitData.m_point       = point;
                hitData.m_dir         = pointVelocity.normalized;
                hitData.m_hitCollider = info.collider;
                hitData.m_toolTier    = this.m_toolTier;
                hitData.m_damage      = this.m_damages.Clone();
                hitData.m_damage.Modify(num);
                component.Damage(hitData);
            }
            if (this.m_damageToSelf)
            {
                IDestructible component2 = base.GetComponent <IDestructible>();
                if (component2 != null)
                {
                    HitData hitData2 = new HitData();
                    hitData2.m_point    = point;
                    hitData2.m_dir      = -pointVelocity.normalized;
                    hitData2.m_toolTier = this.m_toolTier;
                    hitData2.m_damage   = this.m_damages.Clone();
                    hitData2.m_damage.Modify(num);
                    component2.Damage(hitData2);
                }
            }
        }
        Vector3    rhs    = Vector3.Cross(-Vector3.Normalize(info.relativeVelocity), contactPoint.normal);
        Vector3    vector = Vector3.Cross(contactPoint.normal, rhs);
        Quaternion rot    = Quaternion.identity;

        if (vector != Vector3.zero && contactPoint.normal != Vector3.zero)
        {
            rot = Quaternion.LookRotation(vector, contactPoint.normal);
        }
        this.m_hitEffect.Create(point, rot, null, 1f);
        if (this.m_firstHit && this.m_hitDestroyChance > 0f && UnityEngine.Random.value <= this.m_hitDestroyChance)
        {
            this.m_destroyEffect.Create(point, rot, null, 1f);
            GameObject gameObject2 = base.gameObject;
            if (base.transform.parent)
            {
                Animator componentInParent = base.transform.GetComponentInParent <Animator>();
                if (componentInParent)
                {
                    gameObject2 = componentInParent.gameObject;
                }
            }
            UnityEngine.Object.Destroy(gameObject2);
        }
        this.m_firstHit = false;
    }
Пример #8
0
    // Token: 0x06000308 RID: 776 RVA: 0x00019DEC File Offset: 0x00017FEC
    private void OnHit(Collider collider, Vector3 hitPoint, bool water)
    {
        GameObject gameObject = collider ? Projectile.FindHitObject(collider) : null;
        bool       flag       = false;
        bool       flag2      = false;

        if (this.m_aoe > 0f)
        {
            this.DoAOE(hitPoint, ref flag2, ref flag);
        }
        else
        {
            IDestructible destructible = gameObject ? gameObject.GetComponent <IDestructible>() : null;
            if (destructible != null)
            {
                if (!this.IsValidTarget(destructible, ref flag2))
                {
                    return;
                }
                HitData hitData = new HitData();
                hitData.m_hitCollider   = collider;
                hitData.m_damage        = this.m_damage;
                hitData.m_pushForce     = this.m_attackForce;
                hitData.m_backstabBonus = this.m_backstabBonus;
                hitData.m_point         = hitPoint;
                hitData.m_dir           = base.transform.forward;
                hitData.m_statusEffect  = this.m_statusEffect;
                hitData.m_dodgeable     = this.m_dodgeable;
                hitData.m_blockable     = this.m_blockable;
                hitData.m_skill         = this.m_skill;
                hitData.SetAttacker(this.m_owner);
                destructible.Damage(hitData);
                flag = true;
            }
        }
        if (water)
        {
            this.m_hitWaterEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        }
        else
        {
            this.m_hitEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        }
        if (this.m_spawnOnHit != null || this.m_spawnItem != null)
        {
            this.SpawnOnHit(gameObject, collider);
        }
        if (this.m_hitNoise > 0f)
        {
            BaseAI.DoProjectileHitNoise(base.transform.position, this.m_hitNoise, this.m_owner);
        }
        if (this.m_owner != null && flag && this.m_owner.IsPlayer())
        {
            (this.m_owner as Player).RaiseSkill(this.m_skill, flag2 ? 1f : 0.5f);
        }
        this.m_didHit           = true;
        base.transform.position = hitPoint;
        this.m_nview.InvokeRPC("OnHit", Array.Empty <object>());
        if (!this.m_stayAfterHitStatic)
        {
            ZNetScene.instance.Destroy(base.gameObject);
            return;
        }
        if (collider && collider.attachedRigidbody != null)
        {
            this.m_ttl = Mathf.Min(1f, this.m_ttl);
        }
    }
Пример #9
0
        private static void doMeleeAttack(Humanoid ___m_character, ItemDrop.ItemData ___m_weapon, Attack __instance,
                                          EffectList ___m_hitEffect, Skills.SkillType ___m_specialHitSkill, DestructibleType ___m_specialHitType,
                                          bool ___m_lowerDamagePerHit, float ___m_forceMultiplier, float ___m_staggerMultiplier, float ___m_damageMultiplier,
                                          int ___m_attackChainLevels, int ___m_currentAttackCainLevel, DestructibleType ___m_resetChainIfHit,
                                          ref int ___m_nextAttackChainLevel, EffectList ___m_hitTerrainEffect, float ___m_attackHitNoise, Vector3 pos,
                                          Collider col, Vector3 dir, GameObject ___m_spawnOnTrigger)
        {
            Vector3 zero  = Vector3.zero;
            bool    flag2 = false; //rename
            HashSet <Skills.SkillType> skillTypeSet = new HashSet <Skills.SkillType>();
            bool hitOccured = false;

            ___m_weapon.m_shared.m_hitEffect.Create(pos, Quaternion.identity);
            ___m_hitEffect.Create(pos, Quaternion.identity);

            GameObject hitObject = Projectile.FindHitObject(col);

            if (!(hitObject == ___m_character.gameObject))
            {
                Vagon component1 = hitObject.GetComponent <Vagon>();
                if (!component1 || !component1.IsAttached(___m_character))
                {
                    Character component2 = hitObject.GetComponent <Character>();
                    if (!(component2 != null) ||
                        (___m_character.IsPlayer() || BaseAI.IsEnemy(___m_character, component2)) &&
                        (!___m_weapon.m_shared.m_dodgeable || !component2.IsDodgeInvincible()))
                    {
                        hitOccured = true;
                    }
                }
            }

            if (!hitOccured)
            {
                return;
            }

            IDestructible component = hitObject.GetComponent <IDestructible>();

            if (component != null)
            {
                DestructibleType destructibleType = component.GetDestructibleType();
                Skills.SkillType skill            = ___m_weapon.m_shared.m_skillType;

                if (___m_specialHitSkill != Skills.SkillType.None &&
                    (destructibleType & ___m_specialHitType) != DestructibleType.None)
                {
                    skill = ___m_specialHitSkill;
                }

                float randomSkillFactor = ___m_character.GetRandomSkillFactor(skill);

                if (___m_lowerDamagePerHit)
                {
                    randomSkillFactor /= 0.75f;
                }

                HitData hitData = new HitData();
                hitData.m_toolTier     = ___m_weapon.m_shared.m_toolTier;
                hitData.m_statusEffect = ___m_weapon.m_shared.m_attackStatusEffect
                    ? ___m_weapon.m_shared.m_attackStatusEffect.name
                    : "";
                hitData.m_pushForce         = ___m_weapon.m_shared.m_attackForce * randomSkillFactor * ___m_forceMultiplier;
                hitData.m_backstabBonus     = ___m_weapon.m_shared.m_backstabBonus;
                hitData.m_staggerMultiplier = ___m_staggerMultiplier;
                hitData.m_dodgeable         = ___m_weapon.m_shared.m_dodgeable;
                hitData.m_blockable         = ___m_weapon.m_shared.m_blockable;
                hitData.m_skill             = skill;
                hitData.m_damage            = ___m_weapon.GetDamage();
                hitData.m_point             = pos;
                hitData.m_dir         = dir;
                hitData.m_hitCollider = col;
                hitData.SetAttacker(___m_character);
                hitData.m_damage.Modify(___m_damageMultiplier);
                hitData.m_damage.Modify(randomSkillFactor);
                hitData.m_damage.Modify((float)getLevelDamageFactorMethod.Invoke(__instance, null));
                if (___m_attackChainLevels > 1 && ___m_currentAttackCainLevel == ___m_attackChainLevels - 1)
                {
                    hitData.m_damage.Modify(2f);
                    hitData.m_pushForce *= 1.2f;
                }
                hitData.m_damage.Modify(MeshCooldown.calcDamageMultiplier());

                ___m_character.GetSEMan().ModifyAttack(skill, ref hitData);
                if (component is Character)
                {
                    flag2 = true;
                }
                component.Damage(hitData);
                if ((destructibleType & ___m_resetChainIfHit) != DestructibleType.None)
                {
                    ___m_nextAttackChainLevel = 0;
                }
                skillTypeSet.Add(skill);
            }

            ___m_weapon.m_shared.m_hitTerrainEffect.Create(pos,
                                                           Quaternion.identity); // Quaternion.identity might need to be replaced
            ___m_hitTerrainEffect.Create(pos, Quaternion.identity);

            if (___m_weapon.m_shared.m_spawnOnHitTerrain)
            {
                spawnOnHitTerrainMethod.Invoke(__instance,
                                               new object[] { pos, ___m_weapon.m_shared.m_spawnOnHitTerrain });
            }

            if (___m_weapon.m_shared.m_useDurability && ___m_character.IsPlayer())
            {
                ___m_weapon.m_durability -= ___m_weapon.m_shared.m_useDurabilityDrain;
            }
            ___m_character.AddNoise(___m_attackHitNoise);

            if (___m_weapon.m_shared.m_spawnOnHit)
            {
                Object.Instantiate(___m_weapon.m_shared.m_spawnOnHit, pos,
                                   Quaternion.identity).GetComponent <IProjectile>()
                ?.Setup(___m_character, zero, ___m_attackHitNoise, null, ___m_weapon);
            }
            foreach (Skills.SkillType skill in skillTypeSet)
            {
                ___m_character.RaiseSkill(skill, flag2 ? 1.5f : 1f);
            }

            if (!___m_spawnOnTrigger)
            {
                return;
            }
            Object.Instantiate(___m_spawnOnTrigger, zero,
                               Quaternion.identity).GetComponent <IProjectile>()?.Setup(___m_character,
                                                                                        ___m_character.transform.forward, -1f, null, ___m_weapon);

            return;
        }
Пример #10
0
    // Token: 0x060002DE RID: 734 RVA: 0x000173D0 File Offset: 0x000155D0
    private bool OnHit(Collider collider, Vector3 hitPoint)
    {
        GameObject gameObject = Projectile.FindHitObject(collider);

        if (this.m_hitList.Contains(gameObject))
        {
            return(false);
        }
        this.m_hitList.Add(gameObject);
        float num = 1f;

        if (this.m_owner && this.m_owner.IsPlayer() && this.m_skill != Skills.SkillType.None)
        {
            num = this.m_owner.GetRandomSkillFactor(this.m_skill);
        }
        bool          result    = false;
        IDestructible component = gameObject.GetComponent <IDestructible>();

        if (component != null)
        {
            Character character = component as Character;
            if (character)
            {
                if (this.m_nview == null && !character.IsOwner())
                {
                    return(false);
                }
                if (this.m_owner != null)
                {
                    if (!this.m_hitOwner && character == this.m_owner)
                    {
                        return(false);
                    }
                    if (!this.m_hitSame && character.m_name == this.m_owner.m_name)
                    {
                        return(false);
                    }
                    bool flag = BaseAI.IsEnemy(this.m_owner, character);
                    if (!this.m_hitFriendly && !flag)
                    {
                        return(false);
                    }
                    if (!this.m_hitEnemy && flag)
                    {
                        return(false);
                    }
                }
                if (!this.m_hitCharacters)
                {
                    return(false);
                }
                if (this.m_dodgeable && character.IsDodgeInvincible())
                {
                    return(false);
                }
            }
            else if (!this.m_hitProps)
            {
                return(false);
            }
            Vector3 dir     = this.m_attackForceForward ? base.transform.forward : (hitPoint - base.transform.position).normalized;
            HitData hitData = new HitData();
            hitData.m_hitCollider   = collider;
            hitData.m_damage        = this.GetDamage();
            hitData.m_pushForce     = this.m_attackForce * num;
            hitData.m_backstabBonus = this.m_backstabBonus;
            hitData.m_point         = hitPoint;
            hitData.m_dir           = dir;
            hitData.m_statusEffect  = this.m_statusEffect;
            hitData.m_dodgeable     = this.m_dodgeable;
            hitData.m_blockable     = this.m_blockable;
            hitData.m_toolTier      = this.m_toolTier;
            hitData.SetAttacker(this.m_owner);
            hitData.m_damage.Modify(num);
            component.Damage(hitData);
            if (this.m_damageSelf > 0f)
            {
                IDestructible componentInParent = base.GetComponentInParent <IDestructible>();
                if (componentInParent != null)
                {
                    HitData hitData2 = new HitData();
                    hitData2.m_damage.m_damage = this.m_damageSelf;
                    hitData2.m_point           = hitPoint;
                    hitData2.m_blockable       = false;
                    hitData2.m_dodgeable       = false;
                    componentInParent.Damage(hitData2);
                }
            }
            result = true;
        }
        this.m_hitEffects.Create(hitPoint, Quaternion.identity, null, 1f);
        return(result);
    }
Пример #11
0
    // Token: 0x060002F6 RID: 758 RVA: 0x00018CFC File Offset: 0x00016EFC
    private void DoMeleeAttack()
    {
        Transform transform;
        Vector3   vector;

        this.GetMeleeAttackDir(out transform, out vector);
        Vector3    point      = this.m_character.transform.InverseTransformDirection(vector);
        Quaternion quaternion = Quaternion.LookRotation(vector, Vector3.up);

        this.m_weapon.m_shared.m_triggerEffect.Create(transform.position, quaternion, transform, 1f);
        this.m_triggerEffect.Create(transform.position, quaternion, transform, 1f);
        Vector3 vector2                    = transform.position + Vector3.up * this.m_attackHeight + this.m_character.transform.right * this.m_attackOffset;
        float   num                        = this.m_attackAngle / 2f;
        float   num2                       = 4f;
        float   attackRange                = this.m_attackRange;
        List <Attack.HitPoint>     list    = new List <Attack.HitPoint>();
        HashSet <Skills.SkillType> hashSet = new HashSet <Skills.SkillType>();
        int layerMask                      = this.m_hitTerrain ? Attack.m_attackMaskTerrain : Attack.m_attackMask;

        for (float num3 = -num; num3 <= num; num3 += num2)
        {
            Quaternion rotation = Quaternion.identity;
            if (this.m_attackType == Attack.AttackType.Horizontal)
            {
                rotation = Quaternion.Euler(0f, -num3, 0f);
            }
            else if (this.m_attackType == Attack.AttackType.Vertical)
            {
                rotation = Quaternion.Euler(num3, 0f, 0f);
            }
            Vector3 vector3 = this.m_character.transform.TransformDirection(rotation * point);
            Debug.DrawLine(vector2, vector2 + vector3 * attackRange);
            RaycastHit[] array;
            if (this.m_attackRayWidth > 0f)
            {
                array = Physics.SphereCastAll(vector2, this.m_attackRayWidth, vector3, Mathf.Max(0f, attackRange - this.m_attackRayWidth), layerMask, QueryTriggerInteraction.Ignore);
            }
            else
            {
                array = Physics.RaycastAll(vector2, vector3, attackRange, layerMask, QueryTriggerInteraction.Ignore);
            }
            Array.Sort <RaycastHit>(array, (RaycastHit x, RaycastHit y) => x.distance.CompareTo(y.distance));
            foreach (RaycastHit raycastHit in array)
            {
                if (!(raycastHit.collider.gameObject == this.m_character.gameObject))
                {
                    Vector3 vector4 = raycastHit.point;
                    if (raycastHit.distance < 1E-45f)
                    {
                        if (raycastHit.collider is MeshCollider)
                        {
                            vector4 = vector2 + vector3 * attackRange;
                        }
                        else
                        {
                            vector4 = raycastHit.collider.ClosestPoint(vector2);
                        }
                    }
                    if (this.m_attackAngle >= 180f || Vector3.Dot(vector4 - vector2, vector) > 0f)
                    {
                        GameObject gameObject = Projectile.FindHitObject(raycastHit.collider);
                        if (!(gameObject == this.m_character.gameObject))
                        {
                            Vagon component = gameObject.GetComponent <Vagon>();
                            if (!component || !component.IsAttached(this.m_character))
                            {
                                Character component2 = gameObject.GetComponent <Character>();
                                if (!(component2 != null) || ((this.m_character.IsPlayer() || BaseAI.IsEnemy(this.m_character, component2)) && (!this.m_weapon.m_shared.m_dodgeable || !component2.IsDodgeInvincible())))
                                {
                                    this.AddHitPoint(list, gameObject, raycastHit.collider, vector4, raycastHit.distance);
                                    if (!this.m_hitThroughWalls)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        int     num4    = 0;
        Vector3 vector5 = Vector3.zero;
        bool    flag    = false;
        bool    flag2   = false;

        foreach (Attack.HitPoint hitPoint in list)
        {
            GameObject go      = hitPoint.go;
            Vector3    vector6 = hitPoint.avgPoint / (float)hitPoint.count;
            Vector3    vector7 = vector6;
            switch (this.m_hitPointtype)
            {
            case Attack.HitPointType.Closest:
                vector7 = hitPoint.closestPoint;
                break;

            case Attack.HitPointType.Average:
                vector7 = vector6;
                break;

            case Attack.HitPointType.First:
                vector7 = hitPoint.firstPoint;
                break;
            }
            num4++;
            vector5 += vector6;
            this.m_weapon.m_shared.m_hitEffect.Create(vector7, Quaternion.identity, null, 1f);
            this.m_hitEffect.Create(vector7, Quaternion.identity, null, 1f);
            IDestructible component3 = go.GetComponent <IDestructible>();
            if (component3 != null)
            {
                DestructibleType destructibleType = component3.GetDestructibleType();
                Skills.SkillType skillType        = this.m_weapon.m_shared.m_skillType;
                if (this.m_specialHitSkill != Skills.SkillType.None && (destructibleType & this.m_specialHitType) != DestructibleType.None)
                {
                    skillType = this.m_specialHitSkill;
                }
                float num5 = this.m_character.GetRandomSkillFactor(skillType);
                if (this.m_lowerDamagePerHit && list.Count > 1)
                {
                    num5 /= (float)list.Count * 0.75f;
                }
                HitData hitData = new HitData();
                hitData.m_toolTier          = this.m_weapon.m_shared.m_toolTier;
                hitData.m_statusEffect      = (this.m_weapon.m_shared.m_attackStatusEffect ? this.m_weapon.m_shared.m_attackStatusEffect.name : "");
                hitData.m_pushForce         = this.m_weapon.m_shared.m_attackForce * num5 * this.m_forceMultiplier;
                hitData.m_backstabBonus     = this.m_weapon.m_shared.m_backstabBonus;
                hitData.m_staggerMultiplier = this.m_staggerMultiplier;
                hitData.m_dodgeable         = this.m_weapon.m_shared.m_dodgeable;
                hitData.m_blockable         = this.m_weapon.m_shared.m_blockable;
                hitData.m_skill             = skillType;
                hitData.m_damage            = this.m_weapon.GetDamage();
                hitData.m_point             = vector7;
                hitData.m_dir         = (vector7 - vector2).normalized;
                hitData.m_hitCollider = hitPoint.collider;
                hitData.SetAttacker(this.m_character);
                hitData.m_damage.Modify(this.m_damageMultiplier);
                hitData.m_damage.Modify(num5);
                hitData.m_damage.Modify(this.GetLevelDamageFactor());
                if (this.m_attackChainLevels > 1 && this.m_currentAttackCainLevel == this.m_attackChainLevels - 1)
                {
                    hitData.m_damage.Modify(2f);
                    hitData.m_pushForce *= 1.2f;
                }
                this.m_character.GetSEMan().ModifyAttack(skillType, ref hitData);
                if (component3 is Character)
                {
                    flag2 = true;
                }
                component3.Damage(hitData);
                if ((destructibleType & this.m_resetChainIfHit) != DestructibleType.None)
                {
                    this.m_nextAttackChainLevel = 0;
                }
                hashSet.Add(skillType);
                if (!this.m_multiHit)
                {
                    break;
                }
            }
            if (go.GetComponent <Heightmap>() != null && !flag)
            {
                flag = true;
                this.m_weapon.m_shared.m_hitTerrainEffect.Create(vector6, quaternion, null, 1f);
                this.m_hitTerrainEffect.Create(vector6, quaternion, null, 1f);
                if (this.m_weapon.m_shared.m_spawnOnHitTerrain)
                {
                    this.SpawnOnHitTerrain(vector6, this.m_weapon.m_shared.m_spawnOnHitTerrain);
                }
                if (!this.m_multiHit)
                {
                    break;
                }
            }
        }
        if (num4 > 0)
        {
            vector5 /= (float)num4;
            if (this.m_weapon.m_shared.m_useDurability && this.m_character.IsPlayer())
            {
                this.m_weapon.m_durability -= this.m_weapon.m_shared.m_useDurabilityDrain;
            }
            this.m_character.AddNoise(this.m_attackHitNoise);
            this.m_animEvent.FreezeFrame(0.15f);
            if (this.m_weapon.m_shared.m_spawnOnHit)
            {
                IProjectile component4 = UnityEngine.Object.Instantiate <GameObject>(this.m_weapon.m_shared.m_spawnOnHit, vector5, quaternion).GetComponent <IProjectile>();
                if (component4 != null)
                {
                    component4.Setup(this.m_character, Vector3.zero, this.m_attackHitNoise, null, this.m_weapon);
                }
            }
            foreach (Skills.SkillType skill in hashSet)
            {
                this.m_character.RaiseSkill(skill, flag2 ? 1.5f : 1f);
            }
        }
        if (this.m_spawnOnTrigger)
        {
            IProjectile component5 = UnityEngine.Object.Instantiate <GameObject>(this.m_spawnOnTrigger, vector2, Quaternion.identity).GetComponent <IProjectile>();
            if (component5 != null)
            {
                component5.Setup(this.m_character, this.m_character.transform.forward, -1f, null, this.m_weapon);
            }
        }
    }
Пример #12
0
    // Token: 0x060002F3 RID: 755 RVA: 0x00018698 File Offset: 0x00016898
    private void DoAreaAttack()
    {
        Transform transform    = this.m_character.transform;
        Transform attackOrigin = this.GetAttackOrigin();
        Vector3   vector       = attackOrigin.position + Vector3.up * this.m_attackHeight + transform.forward * this.m_attackRange + transform.right * this.m_attackOffset;

        this.m_weapon.m_shared.m_triggerEffect.Create(vector, transform.rotation, attackOrigin, 1f);
        this.m_triggerEffect.Create(vector, transform.rotation, attackOrigin, 1f);
        Vector3 vector2 = vector - transform.position;

        vector2.y = 0f;
        vector2.Normalize();
        int     num               = 0;
        Vector3 vector3           = Vector3.zero;
        bool    flag              = false;
        bool    flag2             = false;
        float   randomSkillFactor = this.m_character.GetRandomSkillFactor(this.m_weapon.m_shared.m_skillType);
        int     layerMask         = this.m_hitTerrain ? Attack.m_attackMaskTerrain : Attack.m_attackMask;

        Collider[]           array   = Physics.OverlapSphere(vector, this.m_attackRayWidth, layerMask, QueryTriggerInteraction.UseGlobal);
        HashSet <GameObject> hashSet = new HashSet <GameObject>();

        foreach (Collider collider in array)
        {
            if (!(collider.gameObject == this.m_character.gameObject))
            {
                GameObject gameObject = Projectile.FindHitObject(collider);
                if (!(gameObject == this.m_character.gameObject) && !hashSet.Contains(gameObject))
                {
                    hashSet.Add(gameObject);
                    Vector3 vector4;
                    if (collider is MeshCollider)
                    {
                        vector4 = collider.ClosestPointOnBounds(vector);
                    }
                    else
                    {
                        vector4 = collider.ClosestPoint(vector);
                    }
                    IDestructible component = gameObject.GetComponent <IDestructible>();
                    if (component != null)
                    {
                        Vector3 vector5 = vector4 - vector;
                        vector5.y = 0f;
                        float num2 = Vector3.Dot(vector2, vector5);
                        if (num2 < 0f)
                        {
                            vector5 += vector2 * -num2;
                        }
                        vector5.Normalize();
                        HitData hitData = new HitData();
                        hitData.m_toolTier          = this.m_weapon.m_shared.m_toolTier;
                        hitData.m_statusEffect      = (this.m_weapon.m_shared.m_attackStatusEffect ? this.m_weapon.m_shared.m_attackStatusEffect.name : "");
                        hitData.m_pushForce         = this.m_weapon.m_shared.m_attackForce * randomSkillFactor * this.m_forceMultiplier;
                        hitData.m_backstabBonus     = this.m_weapon.m_shared.m_backstabBonus;
                        hitData.m_staggerMultiplier = this.m_staggerMultiplier;
                        hitData.m_dodgeable         = this.m_weapon.m_shared.m_dodgeable;
                        hitData.m_blockable         = this.m_weapon.m_shared.m_blockable;
                        hitData.m_skill             = this.m_weapon.m_shared.m_skillType;
                        hitData.m_damage.Add(this.m_weapon.GetDamage(), 1);
                        hitData.m_point       = vector4;
                        hitData.m_dir         = vector5;
                        hitData.m_hitCollider = collider;
                        hitData.SetAttacker(this.m_character);
                        hitData.m_damage.Modify(this.m_damageMultiplier);
                        hitData.m_damage.Modify(randomSkillFactor);
                        hitData.m_damage.Modify(this.GetLevelDamageFactor());
                        if (this.m_attackChainLevels > 1 && this.m_currentAttackCainLevel == this.m_attackChainLevels - 1 && this.m_lastChainDamageMultiplier > 1f)
                        {
                            hitData.m_damage.Modify(this.m_lastChainDamageMultiplier);
                            hitData.m_pushForce *= 1.2f;
                        }
                        this.m_character.GetSEMan().ModifyAttack(this.m_weapon.m_shared.m_skillType, ref hitData);
                        Character character = component as Character;
                        if (character)
                        {
                            if ((!this.m_character.IsPlayer() && !BaseAI.IsEnemy(this.m_character, character)) || (hitData.m_dodgeable && character.IsDodgeInvincible()))
                            {
                                goto IL_407;
                            }
                            flag2 = true;
                        }
                        component.Damage(hitData);
                        flag = true;
                    }
                    num++;
                    vector3 += vector4;
                }
            }
            IL_407 :;
        }
        if (num > 0)
        {
            vector3 /= (float)num;
            this.m_weapon.m_shared.m_hitEffect.Create(vector3, Quaternion.identity, null, 1f);
            this.m_hitEffect.Create(vector3, Quaternion.identity, null, 1f);
            if (this.m_weapon.m_shared.m_useDurability && this.m_character.IsPlayer())
            {
                this.m_weapon.m_durability -= 1f;
            }
            this.m_character.AddNoise(this.m_attackHitNoise);
            if (flag)
            {
                this.m_character.RaiseSkill(this.m_weapon.m_shared.m_skillType, flag2 ? 1.5f : 1f);
            }
        }
        if (this.m_spawnOnTrigger)
        {
            IProjectile component2 = UnityEngine.Object.Instantiate <GameObject>(this.m_spawnOnTrigger, vector, Quaternion.identity).GetComponent <IProjectile>();
            if (component2 != null)
            {
                component2.Setup(this.m_character, this.m_character.transform.forward, -1f, null, null);
            }
        }
    }