예제 #1
0
    private void ImpaleObject(CJObject obj)
    {
        if (this.m_ImpaledObject)
        {
            return;
        }
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        DebugUtils.Assert(currentItem, true);
        this.m_ImpaledObject = obj.gameObject;
        this.m_ImpaledObject.transform.position = currentItem.m_DamagerStart.position;
        this.m_ImpaledObject.transform.parent   = currentItem.m_DamagerStart;
        Rigidbody component = this.m_ImpaledObject.GetComponent <Rigidbody>();

        if (component)
        {
            UnityEngine.Object.Destroy(component);
        }
        obj.OnImpaleOnSpear();
        HintsManager.Get().ShowHint("Take_Item_From_Spear", 10f);
        Item component2 = this.m_ImpaledObject.GetComponent <Item>();

        if (component2)
        {
            component2.ItemsManagerUnregister();
            component2.enabled = false;
        }
    }
예제 #2
0
 public void OnObjectDisappear(CJObject obj, bool play_disappear_chatter)
 {
     if (!this.m_ItemHallucinationsEnabled && !obj.IsAI())
     {
         return;
     }
     if (!obj.IsAI())
     {
         this.m_ColleectedItemHallucinations++;
         if (this.m_ColleectedItemHallucinations > 5)
         {
             this.DisableItemHallucinations();
         }
     }
     if (play_disappear_chatter)
     {
         AudioClip clip;
         if (obj.IsAI())
         {
             clip = this.m_DisappearAI[UnityEngine.Random.Range(0, this.m_DisappearAI.Count)];
         }
         else
         {
             clip = this.m_DisappearItem[UnityEngine.Random.Range(0, this.m_DisappearItem.Count)];
         }
         this.m_DisappearAudioSource.clip = clip;
         this.m_DisappearAudioSource.Play();
     }
 }
예제 #3
0
    public override bool StopAnimOnHit(CJObject hit_obj, Collider coll = null)
    {
        ObjectMaterial component = coll.GetComponent <ObjectMaterial>();

        if (hit_obj == null && (component == null || !ObjectMaterial.IsMaterialHard(component.m_ObjectMaterial)))
        {
            return(false);
        }
        if (hit_obj != null && hit_obj.GetComponent <AI>() != null)
        {
            return(false);
        }
        if (coll != null)
        {
            Item component2 = coll.gameObject.GetComponent <Item>();
            if (component2 != null)
            {
                if (component2.m_Info != null && component2.m_Info.m_Health <= 0f)
                {
                    this.m_ComboScheduled        = false;
                    this.m_ReleaseComboScheduled = false;
                    this.m_ReleaseCombo          = false;
                    this.m_ComboBlocked          = true;
                    return(false);
                }
                if (component2.m_IsPlant)
                {
                    return(false);
                }
            }
            return(true);
        }
        return(true);
    }
예제 #4
0
 public override bool StopAnimOnHit(CJObject hit_obj, Collider coll = null)
 {
     if (hit_obj == null)
     {
         return(false);
     }
     if (hit_obj.GetComponent <AI>() != null)
     {
         return(false);
     }
     if (coll != null)
     {
         Item component = coll.gameObject.GetComponent <Item>();
         if (component != null)
         {
             if (component.m_Info.m_Health <= 0f)
             {
                 this.m_ComboScheduled        = false;
                 this.m_ReleaseComboScheduled = false;
                 this.m_ReleaseCombo          = false;
                 this.m_ComboBlocked          = true;
                 return(false);
             }
             if (component.m_IsPlant)
             {
                 return(false);
             }
         }
         return(true);
     }
     return(true);
 }
예제 #5
0
    private bool CheckHit()
    {
        Vector3    position   = this.m_DamageEnd.position;
        Vector3    normalized = this.m_Velocity.normalized;
        Vector3    e          = position + normalized * this.m_Velocity.magnitude * Time.fixedDeltaTime;
        RaycastHit raycastHit;

        if (!Physics.Raycast(position, normalized, out raycastHit, this.m_Velocity.magnitude * Time.fixedDeltaTime))
        {
            return(false);
        }
        this.m_HitObject = raycastHit.collider.gameObject;
        CJObject componentDeepChild = General.GetComponentDeepChild <CJObject>(raycastHit.collider.gameObject);

        if (!componentDeepChild)
        {
            return(true);
        }
        if (componentDeepChild.GetHitCollisionType() == HitCollisionType.Bones)
        {
            Vector3    zero          = Vector3.zero;
            List <OBB> colliderBoxes = componentDeepChild.GetColliderBoxes();
            for (int i = 0; i < colliderBoxes.Count; i++)
            {
                if (colliderBoxes[i].IntersectsLine(position, e, ref zero))
                {
                    this.GiveDamage(componentDeepChild);
                    return(true);
                }
            }
            return(false);
        }
        this.GiveDamage(componentDeepChild);
        return(true);
    }
예제 #6
0
 protected override void HitObject(CJObject obj, Vector3 hit_pos, Vector3 hit_dir)
 {
     base.HitObject(obj, hit_pos, hit_dir);
     if (obj.CanBeImpaledOnSpear())
     {
         this.ImpaleObject(obj);
     }
 }
예제 #7
0
 private void GiveDamage(CJObject cj_object)
 {
     cj_object.TakeDamage(new DamageInfo
     {
         m_Damage  = this.m_Parent.GetDamage(),
         m_Damager = Player.Get().gameObject
     });
 }
 protected override void HitObject(CJObject obj, Vector3 hit_pos, Vector3 hit_dir)
 {
     if (obj.IsFish() && !obj.CanBeImpaledOnSpear())
     {
         return;
     }
     base.HitObject(obj, hit_pos, hit_dir);
     if (obj.CanBeImpaledOnSpear())
     {
         this.ImpaleObject(obj);
     }
 }
예제 #9
0
 private void DetachActiveRigidbodies(GameObject go)
 {
     for (int i = 0; i < go.transform.childCount; i++)
     {
         Transform child = go.transform.GetChild(i);
         if (child.gameObject.ReplIsReplicable() && child.GetComponent <Rigidbody>())
         {
             CJObject component = child.gameObject.GetComponent <CJObject>();
             if (component && component.enabled)
             {
                 this.OnItemDestroyed(component);
                 child.parent = null;
             }
         }
     }
 }
예제 #10
0
    protected bool CheckBonesIntersection(Triangle t0, Triangle t1, CJObject obj)
    {
        List <OBB> colliderBoxes = obj.GetColliderBoxes();

        for (int i = 0; i < colliderBoxes.Count; i++)
        {
            OBB box = colliderBoxes[i];
            if (Triangle.TriOBBIntersect(t0, box))
            {
                return(true);
            }
            if (Triangle.TriOBBIntersect(t1, box))
            {
                return(true);
            }
        }
        return(false);
    }
예제 #11
0
    public void OnItemDestroyed(CJObject balance_object)
    {
        bool       main_obj_destroyed;
        GameObject gameObject;

        if (!balance_object.IsItem() && balance_object.transform.parent)
        {
            main_obj_destroyed = false;
            gameObject         = balance_object.transform.parent.gameObject;
        }
        else
        {
            main_obj_destroyed = true;
            gameObject         = balance_object.gameObject;
        }
        bool flag = false;

        foreach (string group in this.m_Groups.Keys)
        {
            if (this.ItemDestroyed(group, gameObject, main_obj_destroyed))
            {
                flag = true;
                break;
            }
        }
        if (!flag && gameObject.transform.parent != null)
        {
            gameObject = gameObject.transform.parent.gameObject;
            foreach (string group2 in this.m_Groups.Keys)
            {
                if (this.ItemDestroyed(group2, gameObject, false))
                {
                    break;
                }
            }
        }
    }
예제 #12
0
    private void Hit(CJObject cj_object, Collider coll, Vector3 hit_pos, Vector3 hit_dir)
    {
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (cj_object)
        {
            HumanAI humanAI   = null;
            AI      component = cj_object.GetComponent <AI>();
            if (component && component.IsHuman())
            {
                humanAI = (HumanAI)component;
            }
            if (humanAI)
            {
                if (humanAI.m_Hallucination && humanAI.m_HallucinationDisappearing)
                {
                    return;
                }
                this.HitHumanAI(humanAI, hit_pos, hit_dir);
                this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                this.m_AlreadyHit = true;
            }
            else
            {
                Fish component2 = cj_object.GetComponent <Fish>();
                if (component2 && component2.m_ID != AI.AIID.AngelFish && component2.m_ID != AI.AIID.DiscusFish && UnityEngine.Random.Range(0f, 1f) < 0.5f)
                {
                    this.m_AlreadyHit = true;
                }
                else if (base.m_ControllerType == PlayerControllerType.WeaponMelee && component2 && component2.m_ID != AI.AIID.AngelFish && component2.m_ID != AI.AIID.DiscusFish)
                {
                    component2.OnHitByItem(null, hit_pos);
                    this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                    this.m_AlreadyHit = true;
                }
            }
            if (component)
            {
                PlayerConditionModule.Get().GetDirtinessAdd(GetDirtyReason.Combat, null);
            }
            if (!this.m_AlreadyHit)
            {
                this.HitObject(cj_object, hit_pos, hit_dir);
            }
        }
        else
        {
            RagdollBone component3 = coll.gameObject.GetComponent <RagdollBone>();
            if (component3 && component3.m_ParentObject)
            {
                DeadBody component4 = component3.m_ParentObject.GetComponent <DeadBody>();
                if (component4)
                {
                    component4.OnTakeDamage(new DamageInfo
                    {
                        m_DamageItem = currentItem,
                        m_Damager    = base.gameObject,
                        m_Position   = hit_pos,
                        m_HitDir     = hit_dir,
                        m_Normal     = -hit_dir
                    });
                    this.m_AlreadyHit = true;
                }
            }
        }
        DamageInfo     damageInfo = new DamageInfo();
        ObjectMaterial component5;

        if (cj_object != null)
        {
            component5 = cj_object.gameObject.GetComponent <ObjectMaterial>();
        }
        else
        {
            component5 = coll.gameObject.GetComponent <ObjectMaterial>();
        }
        EObjectMaterial mat = (component5 == null) ? EObjectMaterial.Unknown : component5.m_ObjectMaterial;

        damageInfo.m_Damage     = currentItem.m_Info.m_DamageSelf * ObjectMaterial.GetDamageSelfMul(mat);
        damageInfo.m_DamageItem = currentItem;
        this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
        currentItem.TakeDamage(damageInfo);
        this.OnHit();
    }
예제 #13
0
    protected virtual void HitObject(CJObject obj, Vector3 hit_pos, Vector3 hit_dir)
    {
        this.m_AudioModule.PlayHitSound(1f, false);
        if (obj.GetParticleOnHit().Length > 3)
        {
            this.SpawnFX(obj.GetParticleOnHit(), hit_pos);
        }
        Item   currentItem = this.m_Player.GetCurrentItem(Hand.Right);
        Weapon weapon      = null;

        if (currentItem.m_Info.IsWeapon())
        {
            weapon = (Weapon)currentItem;
        }
        bool flag      = true;
        Item component = obj.GetComponent <Item>();

        if (component && component.m_IsPlant)
        {
            this.m_AlreadyHit = false;
        }
        else
        {
            this.m_AlreadyHit = true;
        }
        if (obj.CanReceiveDamageOfType(currentItem.m_Info.m_DamageType))
        {
            DamageInfo damageInfo = new DamageInfo();
            if (weapon != null)
            {
                WeaponInfo weaponInfo = (WeaponInfo)weapon.m_Info;
                if (obj.IsAI())
                {
                    damageInfo.m_Damage = weaponInfo.m_AnimalDamage;
                    if (((AI)obj).IsDead())
                    {
                        flag = false;
                    }
                }
                else if (component)
                {
                    if (component.m_IsPlant)
                    {
                        damageInfo.m_Damage = weaponInfo.m_PlantDamage;
                    }
                    else if (component.m_IsTree)
                    {
                        damageInfo.m_Damage = weaponInfo.m_TreeDamage;
                    }
                    else
                    {
                        damageInfo.m_Damage = weaponInfo.m_DefaultDamage;
                    }
                }
                else
                {
                    damageInfo.m_Damage = weaponInfo.m_DefaultDamage;
                }
            }
            else if (component && component.m_IsTree && weapon.m_Info.IsTorch())
            {
                damageInfo.m_Damage = 0f;
            }
            else
            {
                damageInfo.m_Damage = 1000f;
            }
            damageInfo.m_Damage    *= this.GetDamageMultiplier(currentItem);
            damageInfo.m_Damager    = this.m_Player.gameObject;
            damageInfo.m_Position   = hit_pos;
            damageInfo.m_HitDir     = hit_dir;
            damageInfo.m_Normal     = Vector3.up;
            damageInfo.m_DamageItem = currentItem;
            obj.TakeDamage(damageInfo);
            this.HitDestroyableChunkSource(obj.GetComponent <Collider>(), hit_pos, hit_dir, currentItem);
            if (flag)
            {
                this.ExecuteSkill(currentItem);
            }
        }
    }
예제 #14
0
    protected virtual bool UpdateCollisions(Triangle blade_t0, Triangle blade_t1, Triangle handle_t0, Triangle handle_t1, Vector3 hit_dir, bool damage_window, out CJObject cj_obj, out Collider collider, out bool collision_with_handle, float damage_window_start, float damage_window_end, out Vector3 hit_pos)
    {
        collision_with_handle = false;
        Vector3    zero     = Vector3.zero;
        Vector3    zero2    = Vector3.zero;
        Quaternion identity = Quaternion.identity;

        hit_pos = blade_t0.p0;
        this.GetBoxParameters(blade_t0, blade_t1, out zero2, out zero, out identity);
        if (!damage_window)
        {
            this.m_LastBoxHalfSizes  = zero;
            this.m_LastBoxPos        = zero2;
            this.m_LastBoxQuaternion = identity;
            this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
            cj_obj   = null;
            collider = null;
            hit_pos  = Vector3.zero;
            return(false);
        }
        Collider[] array = Physics.OverlapBox(zero2, zero, identity);
        for (int i = 0; i < array.Length; i++)
        {
            bool     flag      = false;
            Collider collider2 = array[i];
            if (collider2.gameObject.IsWater())
            {
                this.OnHitWater(collider2);
            }
            if (!collider2.isTrigger || collider2.gameObject.IsAI())
            {
                if (!(collider2.gameObject == this.m_Player.gameObject) && !(collider2.gameObject == this.m_Player.GetCurrentItem(Hand.Right).gameObject))
                {
                    if (!(collider2.gameObject.GetComponent <Player>() != null))
                    {
                        CJObject component = collider2.gameObject.GetComponent <CJObject>();
                        if (component == null && collider2.gameObject.transform.parent != null)
                        {
                            component = collider2.gameObject.transform.parent.GetComponent <CJObject>();
                        }
                        if (component != null && component.GetHitCollisionType() == HitCollisionType.Bones)
                        {
                            if (this.CheckBonesIntersection(blade_t0, blade_t1, component))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            flag = true;
                        }
                        if (flag)
                        {
                            float anim_frame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
                            this.SetupAnimFrameForHit(zero2, zero, identity, anim_frame, collider2);
                            this.m_LastBoxHalfSizes  = zero;
                            this.m_LastBoxPos        = zero2;
                            this.m_LastBoxQuaternion = identity;
                            this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
                            cj_obj   = component;
                            collider = collider2;
                            hit_pos  = blade_t0.p0;
                            return(true);
                        }
                    }
                }
            }
        }
        this.m_LastBoxHalfSizes  = zero;
        this.m_LastBoxPos        = zero2;
        this.m_LastBoxQuaternion = identity;
        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
        cj_obj   = null;
        collider = null;
        return(false);
    }
예제 #15
0
    private void Hit(CJObject cj_object, Collider coll, Vector3 hit_pos, Vector3 hit_dir)
    {
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (cj_object)
        {
            HumanAI component = cj_object.GetComponent <HumanAI>();
            if (component)
            {
                if (component.m_Hallucination && component.m_HallucinationDisappearing)
                {
                    return;
                }
                this.HitHumanAI(component, hit_pos, hit_dir);
                this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
                this.m_AlreadyHit = true;
                return;
            }
            else
            {
                this.HitObject(cj_object, hit_pos, hit_dir);
            }
        }
        else
        {
            RagdollBone component2 = coll.gameObject.GetComponent <RagdollBone>();
            if (component2 && component2.m_Parent)
            {
                DeadBody component3 = component2.m_Parent.GetComponent <DeadBody>();
                if (component3)
                {
                    component3.OnTakeDamage(new DamageInfo
                    {
                        m_DamageItem = currentItem,
                        m_Damager    = base.gameObject,
                        m_Position   = hit_pos,
                        m_HitDir     = hit_dir,
                        m_Normal     = -hit_dir
                    });
                    return;
                }
            }
        }
        DamageInfo     damageInfo = new DamageInfo();
        ObjectMaterial component4;

        if (cj_object != null)
        {
            component4 = cj_object.gameObject.GetComponent <ObjectMaterial>();
        }
        else
        {
            component4 = coll.gameObject.GetComponent <ObjectMaterial>();
        }
        EObjectMaterial mat = (!(component4 == null)) ? component4.m_ObjectMaterial : EObjectMaterial.Unknown;

        damageInfo.m_Damage     = currentItem.m_Info.m_DamageSelf * ObjectMaterial.GetDamageSelfMul(mat);
        damageInfo.m_DamageItem = currentItem;
        this.MakeHitSound(coll.gameObject, currentItem.m_Info.m_ID);
        currentItem.TakeDamage(damageInfo);
        this.OnHit();
    }
예제 #16
0
    private void UpdateAttack()
    {
        if (!this.IsAttack())
        {
            this.m_DamagerLastPosEnd   = Vector3.zero;
            this.m_DamagerLastPosStart = Vector3.zero;
            this.m_HandleLastPosEnd    = Vector3.zero;
            this.m_AlreadyHit          = false;
            this.m_HitObjects.Clear();
            return;
        }
        if (this.m_AlreadyHit)
        {
            return;
        }
        if (this.m_State != WeaponControllerState.Swing)
        {
            return;
        }
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (!currentItem)
        {
            return;
        }
        if (!currentItem.m_DamagerStart || !currentItem.m_DamagerEnd)
        {
            return;
        }
        Vector3 position   = currentItem.m_DamagerStart.transform.position;
        Vector3 position2  = currentItem.m_DamagerEnd.transform.position;
        Vector3 position3  = this.m_HandleEndTransform.position;
        Vector3 normalized = (position - this.m_DamagerLastPosStart).normalized;

        if (this.m_DamagerLastPosEnd.magnitude < 0.1f)
        {
            this.m_DamagerLastPosEnd  = Vector3.Cross(position2 - position, Vector3.up) * 0.1f;
            this.m_DamagerLastPosEnd += position2;
        }
        if (this.m_DamagerLastPosStart.magnitude < 0.1f)
        {
            this.m_DamagerLastPosStart  = Vector3.Cross(position2 - position, Vector3.up) * 0.1f;
            this.m_DamagerLastPosStart += position;
        }
        if (this.m_HandleLastPosEnd.magnitude < 0.1f)
        {
            this.m_HandleLastPosEnd  = Vector3.Cross(position3 - position2, Vector3.up) * 0.1f;
            this.m_HandleLastPosEnd += this.m_HandleEndTransform.position;
        }
        this.m_BladeT0.p0          = position;
        this.m_BladeT0.p1          = this.m_DamagerLastPosStart;
        this.m_BladeT0.p2          = position2;
        this.m_BladeT1.p0          = this.m_DamagerLastPosStart;
        this.m_BladeT1.p1          = this.m_DamagerLastPosEnd;
        this.m_BladeT1.p2          = position2;
        this.m_DamagerLastPosStart = position;
        this.m_DamagerLastPosEnd   = position2;
        this.m_HandleLastPosEnd    = position3;
        AnimatorStateInfo currentAnimatorStateInfo = this.m_Animator.GetCurrentAnimatorStateInfo(1);

        AnimatorClipInfo[] currentAnimatorClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(1);
        bool  damage_window = true;
        float num           = float.MinValue;
        int   num2          = -1;

        for (int i = 0; i < currentAnimatorClipInfo.Length; i++)
        {
            AnimatorClipInfo animatorClipInfo = currentAnimatorClipInfo[i];
            if (animatorClipInfo.weight > num)
            {
                num2 = i;
                num  = animatorClipInfo.weight;
            }
        }
        float num3 = -1f;
        float num4 = -1f;

        if (num2 >= 0)
        {
            AnimatorClipInfo animatorClipInfo2 = currentAnimatorClipInfo[num2];
            if (animatorClipInfo2.clip.events.Length > 0)
            {
                for (int j = 0; j < animatorClipInfo2.clip.events.Length; j++)
                {
                    AnimationEvent animationEvent = animatorClipInfo2.clip.events[j];
                    if (animationEvent.intParameter == 9)
                    {
                        num3 = animationEvent.time / animatorClipInfo2.clip.length;
                    }
                    else if (animationEvent.intParameter == 10)
                    {
                        num4 = animationEvent.time / animatorClipInfo2.clip.length;
                    }
                }
                if (num3 < 0f && num4 >= 0f)
                {
                    DebugUtils.Assert("Missing DamageStart event in anim " + animatorClipInfo2.clip.name, true, DebugUtils.AssertType.Info);
                }
                else if (num3 >= 0f && num4 < 0f)
                {
                    DebugUtils.Assert("Missing DamageEnd event in anim " + animatorClipInfo2.clip.name, true, DebugUtils.AssertType.Info);
                }
                damage_window = (num3 >= 0f && num4 >= 0f && (num3 <= currentAnimatorStateInfo.normalizedTime && num4 >= num3 && num4 >= currentAnimatorStateInfo.normalizedTime));
            }
        }
        CJObject cjobject = null;
        Collider collider = null;
        bool     flag     = false;
        Vector3  zero     = Vector3.zero;

        if (this.UpdateCollisions(this.m_BladeT0, this.m_BladeT1, null, null, normalized, damage_window, out cjobject, out collider, out flag, num3, num4, out zero) && !this.m_HitObjects.Contains(collider.gameObject))
        {
            this.m_HitObjects.Add(collider.gameObject);
            if (flag)
            {
                this.EndAttack();
            }
            else
            {
                this.Hit(cjobject, collider, zero, normalized);
                if (this.StopAnimOnHit(cjobject, collider))
                {
                    this.StopAnimation();
                }
                else
                {
                    this.EndAttackNonStop();
                }
            }
            this.m_LastHitTime = Time.time;
        }
    }
예제 #17
0
    protected virtual bool UpdateCollisions(Triangle blade_t0, Triangle blade_t1, Triangle handle_t0, Triangle handle_t1, Vector3 hit_dir, bool damage_window, out CJObject cj_obj, out Collider collider, out bool collision_with_handle, float damage_window_start, float damage_window_end, out Vector3 hit_pos)
    {
        collision_with_handle = false;
        Vector3    zero     = Vector3.zero;
        Vector3    zero2    = Vector3.zero;
        Quaternion identity = Quaternion.identity;

        hit_pos = blade_t0.p0;
        this.GetBoxParameters(blade_t0, blade_t1, out zero2, out zero, out identity);
        if (!damage_window)
        {
            this.m_LastBoxHalfSizes  = zero;
            this.m_LastBoxPos        = zero2;
            this.m_LastBoxQuaternion = identity;
            this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
            cj_obj   = null;
            collider = null;
            hit_pos  = Vector3.zero;
            return(false);
        }
        int num = Physics.OverlapBoxNonAlloc(zero2, zero, this.m_HitCollidersTmp, identity);

        for (int i = 0; i < num; i++)
        {
            bool     flag      = false;
            Collider collider2 = this.m_HitCollidersTmp[i];
            if (collider2.gameObject.IsWater())
            {
                this.OnHitWater(collider2);
            }
            if (!(collider2 == this.m_Player.m_CharacterController.m_Controller) && (!collider2.isTrigger || collider2.gameObject.IsAI() || collider2.gameObject.IsFish()) && !(collider2.gameObject == this.m_Player.gameObject) && !(collider2.gameObject == this.m_Player.GetCurrentItem(Hand.Right).gameObject) && !(collider2.gameObject.GetComponent <Player>() != null) && !PlayerArmorModule.Get().IsgameObjectEquipedArmor(collider2.gameObject))
            {
                CJObject component = collider2.gameObject.GetComponent <CJObject>();
                if (!this.m_HitObjects.Contains(collider2.gameObject))
                {
                    Item component2 = collider2.gameObject.GetComponent <Item>();
                    if (!component2 || !component2.m_Info.IsParasite())
                    {
                        AI component3 = collider2.gameObject.GetComponent <AI>();
                        if (!component3 || !component3.m_GoalsModule || component3.m_GoalsModule.m_ActiveGoal == null || component3.m_GoalsModule.m_ActiveGoal.m_Type != AIGoalType.HumanJumpBack || component3.m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.5f)
                        {
                            if (component == null && collider2.gameObject.transform.parent != null)
                            {
                                component = collider2.gameObject.transform.parent.GetComponent <CJObject>();
                            }
                            if (component != null && component.GetHitCollisionType() == HitCollisionType.Bones)
                            {
                                if (this.CheckBonesIntersection(blade_t0, blade_t1, component))
                                {
                                    flag = true;
                                }
                            }
                            else
                            {
                                flag = true;
                            }
                            if (flag)
                            {
                                float anim_frame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
                                this.SetupAnimFrameForHit(zero2, zero, identity, anim_frame, collider2);
                                this.m_LastBoxHalfSizes  = zero;
                                this.m_LastBoxPos        = zero2;
                                this.m_LastBoxQuaternion = identity;
                                this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
                                cj_obj   = component;
                                collider = collider2;
                                hit_pos  = blade_t0.p0;
                                return(true);
                            }
                        }
                    }
                }
            }
        }
        this.m_LastBoxHalfSizes  = zero;
        this.m_LastBoxPos        = zero2;
        this.m_LastBoxQuaternion = identity;
        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
        cj_obj   = null;
        collider = null;
        return(false);
    }
예제 #18
0
    protected virtual void HitObject(CJObject obj, Vector3 hit_pos, Vector3 hit_dir)
    {
        bool flag = false;

        if (Time.time - this.m_LastPlayHitSound > 0.5f)
        {
            this.m_AudioModule.PlayHitSound(1f, false);
            this.m_LastPlayHitSound = Time.time;
        }
        if (obj.GetParticleOnHit().Length > 3)
        {
            this.SpawnFX(obj.GetParticleOnHit(), hit_pos);
        }
        Item   currentItem = this.m_Player.GetCurrentItem(Hand.Right);
        Weapon weapon      = null;

        if (currentItem.m_Info.IsWeapon())
        {
            weapon = (Weapon)currentItem;
        }
        bool flag2     = true;
        Item component = obj.GetComponent <Item>();

        if (component && component.m_IsPlant)
        {
            this.m_AlreadyHit = false;
        }
        else
        {
            this.m_AlreadyHit = true;
        }
        if (obj.CanReceiveDamageOfType(currentItem.m_Info.m_DamageType))
        {
            DamageInfo damageInfo = new DamageInfo();
            if (weapon != null)
            {
                WeaponInfo weaponInfo = (WeaponInfo)weapon.m_Info;
                if (obj.IsAI())
                {
                    damageInfo.m_Damage = weaponInfo.m_AnimalDamage;
                    if (((AI)obj).IsDead())
                    {
                        flag2 = false;
                    }
                    else
                    {
                        AI ai = (AI)obj;
                        if (ai && ai.m_ID == AI.AIID.ArmadilloThreeBanded && ai.m_GoalsModule != null && ai.m_GoalsModule.m_ActiveGoal != null && ai.m_GoalsModule.m_ActiveGoal.m_Type == AIGoalType.Hide)
                        {
                            flag2 = false;
                        }
                    }
                }
                else if (component)
                {
                    if (component.GetInfoID() == ItemID.iron_vein)
                    {
                        damageInfo.m_Damage = weaponInfo.m_IronVeinDamage;
                    }
                    else if (component.m_IsPlant)
                    {
                        damageInfo.m_Damage = weaponInfo.m_PlantDamage;
                        flag = true;
                    }
                    else if (component.m_IsTree)
                    {
                        damageInfo.m_Damage = weaponInfo.m_TreeDamage;
                        flag = true;
                    }
                    else
                    {
                        damageInfo.m_Damage = weaponInfo.m_DefaultDamage;
                    }
                }
                else
                {
                    damageInfo.m_Damage = weaponInfo.m_DefaultDamage;
                }
            }
            else if (component && component.m_IsTree && weapon.m_Info.IsTorch())
            {
                damageInfo.m_Damage = 0f;
            }
            else
            {
                damageInfo.m_Damage = 1000f;
            }
            damageInfo.m_Damage    *= this.GetDamageMultiplier(currentItem);
            damageInfo.m_Damager    = this.m_Player.gameObject;
            damageInfo.m_Position   = hit_pos;
            damageInfo.m_HitDir     = hit_dir;
            damageInfo.m_Normal     = Vector3.up;
            damageInfo.m_DamageItem = currentItem;
            obj.TakeDamage(damageInfo);
            if (flag)
            {
                PlayerConditionModule.Get().GetDirtinessAdd(GetDirtyReason.ChopPlants, null);
            }
            this.HitDestroyableChunkSource(obj.GetComponent <Collider>(), hit_pos, hit_dir, currentItem);
            if (flag2)
            {
                this.ExecuteSkill(currentItem);
            }
        }
    }
예제 #19
0
    protected override bool UpdateCollisions(Triangle blade_t0, Triangle blade_t1, Triangle handle_t0, Triangle handle_t1, Vector3 hit_dir, bool damage_window, out CJObject cj_obj, out Collider collider, out bool collision_with_handle, float damage_window_start, float damage_window_end, out Vector3 hit_pos)
    {
        collision_with_handle = false;
        Vector3    zero     = Vector3.zero;
        Vector3    zero2    = Vector3.zero;
        Quaternion identity = Quaternion.identity;

        cj_obj   = null;
        collider = null;
        hit_pos  = Vector3.zero;
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (currentItem == null || currentItem.m_Info == null)
        {
            return(false);
        }
        ItemID id = currentItem.m_Info.m_ID;

        if (!this.m_PredictionData.ContainsKey((int)id))
        {
            return(false);
        }
        AnimatorClipInfo[] currentAnimatorClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(1);
        AnimationClip      animationClip           = null;

        for (int i = 0; i < currentAnimatorClipInfo.Length; i++)
        {
            if (this.m_PredictionData[(int)id].ContainsKey(currentAnimatorClipInfo[i].clip))
            {
                animationClip = currentAnimatorClipInfo[i].clip;
            }
        }
        if (animationClip == null)
        {
            return(false);
        }
        List <MeleeAttackPredictionData> list      = this.m_PredictionData[(int)id][animationClip];
        AnimatorStateInfo currentAnimatorStateInfo = this.m_Animator.GetCurrentAnimatorStateInfo(1);
        float             num  = 0.02f;
        float             num2 = (this.m_LastAnimFrame < 0f) ? 0f : (this.m_LastAnimFrame / currentAnimatorStateInfo.length);
        float             time = num2;
        float             num3 = currentAnimatorStateInfo.normalizedTime - num2;
        int num4 = (int)(num3 / num);

        if (num4 < 1)
        {
            num4 = 1;
        }
        num3 /= (float)num4;
        for (int j = 0; j < num4; j++)
        {
            float num5 = num2 + num3 * (float)(j + 1);
            if (num5 < damage_window_start || num5 > damage_window_end)
            {
                this.m_LastAnimFrame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5;
                cj_obj   = null;
                collider = null;
                time     = num5;
            }
            else
            {
                Vector3 damagerStartPos  = this.GetDamagerStartPos(num5, ref list);
                Vector3 damagerEndPos    = this.GetDamagerEndPos(num5, ref list);
                Vector3 damagerStartPos2 = this.GetDamagerStartPos(time, ref list);
                Vector3 damagerEndPos2   = this.GetDamagerEndPos(time, ref list);
                this.m_BladeT0Triangle.p0 = damagerStartPos;
                this.m_BladeT0Triangle.p1 = damagerStartPos2;
                this.m_BladeT0Triangle.p2 = damagerEndPos;
                this.m_BladeT1Triangle.p0 = damagerStartPos2;
                this.m_BladeT1Triangle.p1 = damagerEndPos2;
                this.m_BladeT1Triangle.p2 = damagerEndPos;
                base.GetBoxParameters(this.m_BladeT0Triangle, this.m_BladeT1Triangle, out zero2, out zero, out identity);
                Collider[] array = Physics.OverlapBox(zero2, zero, identity);
                this.SortCollisions(array);
                for (int k = 0; k < array.Length; k++)
                {
                    bool     flag      = false;
                    Collider collider2 = array[k];
                    if (collider2.gameObject.IsWater())
                    {
                        this.OnHitWater(collider2);
                    }
                    if (!collider2.isTrigger || collider2.gameObject.IsAI())
                    {
                        if (!(collider2.gameObject == this.m_Player.gameObject) && !(collider2.gameObject == this.m_Player.GetCurrentItem(Hand.Right).gameObject))
                        {
                            if (!this.m_HitObjects.Contains(collider2.gameObject))
                            {
                                if (!(collider2.gameObject.GetComponent <Player>() != null))
                                {
                                    CJObject component = collider2.gameObject.GetComponent <CJObject>();
                                    if (component == null && collider2.gameObject.transform.parent != null)
                                    {
                                        component = collider2.gameObject.transform.parent.GetComponent <CJObject>();
                                    }
                                    if (component != null && component.GetHitCollisionType() == HitCollisionType.Bones)
                                    {
                                        if (base.CheckBonesIntersection(blade_t0, blade_t1, component))
                                        {
                                            flag = true;
                                        }
                                    }
                                    else
                                    {
                                        flag = true;
                                    }
                                    if (flag && damage_window)
                                    {
                                        float anim_frame = num5 * currentAnimatorStateInfo.length;
                                        this.SetupAnimFrameForHit(zero2, zero, identity, anim_frame, collider2);
                                        this.m_LastBoxHalfSizes  = zero;
                                        this.m_LastBoxPos        = zero2;
                                        this.m_LastBoxQuaternion = identity;
                                        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5;
                                        cj_obj   = component;
                                        collider = collider2;
                                        hit_pos  = this.m_BladeT0Triangle.p0;
                                        float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, num5, num2, currentAnimatorStateInfo.normalizedTime);
                                        this.m_AnimationStoppedHandPos = Vector3.Lerp(this.m_LastHandPos, this.m_RHand.transform.position, proportionalClamp);
                                        this.m_LastHandPos             = this.m_RHand.position;
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
                time = num5;
            }
        }
        this.m_LastBoxHalfSizes  = zero;
        this.m_LastBoxPos        = zero2;
        this.m_LastBoxQuaternion = identity;
        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
        this.m_LastHandPos       = this.m_RHand.position;
        cj_obj   = null;
        collider = null;
        return(false);
    }
예제 #20
0
    protected override bool UpdateCollisions(Triangle blade_t0, Triangle blade_t1, Triangle handle_t0, Triangle handle_t1, Vector3 hit_dir, bool damage_window, out CJObject cj_obj, out Collider collider, out bool collision_with_handle, float damage_window_start, float damage_window_end, out Vector3 hit_pos)
    {
        collision_with_handle = false;
        Vector3    zero     = Vector3.zero;
        Vector3    zero2    = Vector3.zero;
        Quaternion identity = Quaternion.identity;

        cj_obj   = null;
        collider = null;
        hit_pos  = Vector3.zero;
        Item currentItem = this.m_Player.GetCurrentItem(Hand.Right);

        if (currentItem == null || currentItem.m_Info == null)
        {
            return(false);
        }
        ItemID id = currentItem.m_Info.m_ID;

        if (!this.m_PredictionData.ContainsKey((int)id))
        {
            return(base.UpdateCollisions(blade_t0, blade_t1, handle_t0, handle_t1, hit_dir, damage_window, out cj_obj, out collider, out collision_with_handle, damage_window_start, damage_window_end, out hit_pos));
        }
        AnimatorClipInfo[] currentAnimatorClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(1);
        AnimationClip      animationClip           = null;

        for (int i = 0; i < currentAnimatorClipInfo.Length; i++)
        {
            if (this.m_PredictionData[(int)id].ContainsKey(currentAnimatorClipInfo[i].clip))
            {
                animationClip = currentAnimatorClipInfo[i].clip;
            }
        }
        if (animationClip == null)
        {
            return(base.UpdateCollisions(blade_t0, blade_t1, handle_t0, handle_t1, hit_dir, damage_window, out cj_obj, out collider, out collision_with_handle, damage_window_start, damage_window_end, out hit_pos));
        }
        List <MeleeAttackPredictionData> list      = this.m_PredictionData[(int)id][animationClip];
        AnimatorStateInfo currentAnimatorStateInfo = this.m_Animator.GetCurrentAnimatorStateInfo(1);
        float             num  = 0.02f;
        float             num2 = (this.m_LastAnimFrame >= 0f) ? (this.m_LastAnimFrame / currentAnimatorStateInfo.length) : 0f;
        float             time = num2;
        float             num3 = currentAnimatorStateInfo.normalizedTime - num2;
        int num4 = (int)(num3 / num);

        if (num4 < 1)
        {
            num4 = 1;
        }
        num3 /= (float)num4;
        for (int j = 0; j < num4; j++)
        {
            float num5 = num2 + num3 * (float)(j + 1);
            if (num5 < damage_window_start || num5 > damage_window_end)
            {
                this.m_LastAnimFrame = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5;
                cj_obj   = null;
                collider = null;
                time     = num5;
            }
            else
            {
                Vector3 damagerStartPos  = this.GetDamagerStartPos(num5, ref list);
                Vector3 damagerEndPos    = this.GetDamagerEndPos(num5, ref list);
                Vector3 damagerStartPos2 = this.GetDamagerStartPos(time, ref list);
                Vector3 damagerEndPos2   = this.GetDamagerEndPos(time, ref list);
                this.m_BladeT0Triangle.p0 = damagerStartPos;
                this.m_BladeT0Triangle.p1 = damagerStartPos2;
                this.m_BladeT0Triangle.p2 = damagerEndPos;
                this.m_BladeT1Triangle.p0 = damagerStartPos2;
                this.m_BladeT1Triangle.p1 = damagerEndPos2;
                this.m_BladeT1Triangle.p2 = damagerEndPos;
                base.GetBoxParameters(this.m_BladeT0Triangle, this.m_BladeT1Triangle, out zero2, out zero, out identity);
                int num6 = Physics.OverlapBoxNonAlloc(zero2, zero, this.m_HitCollidersTmp, identity);
                this.SortCollisions(this.m_HitCollidersTmp, num6);
                for (int k = 0; k < num6; k++)
                {
                    bool     flag      = false;
                    Collider collider2 = this.m_HitCollidersTmp[k];
                    if (!(collider2 == this.m_Player.m_CharacterController.m_Controller))
                    {
                        if (collider2.gameObject.IsWater())
                        {
                            this.OnHitWater(collider2);
                        }
                        if ((!collider2.isTrigger || collider2.gameObject.IsAI() || collider2.gameObject.IsFish() || collider2.gameObject.GetComponent <Spikes>()) && !(collider2.gameObject == this.m_Player.gameObject) && !(collider2.gameObject == currentItem.gameObject) && !(collider2.transform.parent == Player.Get().transform.GetChild(0)) && !this.m_HitObjects.Contains(collider2.gameObject) && !(collider2.gameObject.GetComponent <Player>() != null) && !PlayerArmorModule.Get().IsgameObjectEquipedArmor(collider2.gameObject))
                        {
                            Item component = collider2.gameObject.GetComponent <Item>();
                            if (!(component != null) || component.m_Info == null || (!component.m_Info.IsParasite() && !component.m_Info.IsArmor()))
                            {
                                ItemReplacer component2 = collider2.gameObject.GetComponent <ItemReplacer>();
                                if (component2)
                                {
                                    string text = component2.m_ReplaceInfoName.ToString().ToLower();
                                    if ((text.Contains("plant") && text != "plantain_lily_leaf") || text.Contains("leaf"))
                                    {
                                        goto IL_62D;
                                    }
                                }
                                ItemHold component3 = collider2.gameObject.GetComponent <ItemHold>();
                                if (component3)
                                {
                                    string text2 = component3.m_InfoName.ToString().ToLower();
                                    if ((text2.Contains("plant") && text2 != "plantain_lily_leaf") || text2.Contains("leaf"))
                                    {
                                        goto IL_62D;
                                    }
                                }
                                AI component4 = collider2.gameObject.GetComponent <AI>();
                                if (!component4 || !component4.m_GoalsModule || component4.m_GoalsModule.m_ActiveGoal == null || component4.m_GoalsModule.m_ActiveGoal.m_Type != AIGoalType.HumanJumpBack || component4.m_Animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 0.5f)
                                {
                                    CJObject component5 = collider2.gameObject.GetComponent <CJObject>();
                                    if (component5 == null)
                                    {
                                        Transform parent = collider2.gameObject.transform.parent;
                                        while (parent != null)
                                        {
                                            component5 = parent.GetComponent <CJObject>();
                                            if (component5)
                                            {
                                                break;
                                            }
                                            parent = parent.parent;
                                        }
                                    }
                                    if (component5 != null && component5.GetHitCollisionType() == HitCollisionType.Bones)
                                    {
                                        if (base.CheckBonesIntersection(blade_t0, blade_t1, component5))
                                        {
                                            flag = true;
                                        }
                                    }
                                    else
                                    {
                                        flag = true;
                                    }
                                    if (flag && damage_window)
                                    {
                                        float anim_frame = num5 * currentAnimatorStateInfo.length;
                                        this.SetupAnimFrameForHit(zero2, zero, identity, anim_frame, collider2);
                                        this.m_LastBoxHalfSizes  = zero;
                                        this.m_LastBoxPos        = zero2;
                                        this.m_LastBoxQuaternion = identity;
                                        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *num5;
                                        cj_obj   = component5;
                                        collider = collider2;
                                        hit_pos  = this.m_BladeT0Triangle.p0;
                                        float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, num5, num2, currentAnimatorStateInfo.normalizedTime);
                                        this.m_AnimationStoppedHandPos = Vector3.Lerp(this.m_LastHandPos, this.m_RHand.transform.position, proportionalClamp);
                                        this.m_LastHandPos             = this.m_RHand.position;
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                    IL_62D :;
                }
                time = num5;
            }
        }
        this.m_LastBoxHalfSizes  = zero;
        this.m_LastBoxPos        = zero2;
        this.m_LastBoxQuaternion = identity;
        this.m_LastAnimFrame     = this.m_Animator.GetCurrentAnimatorStateInfo(1).length *this.m_Animator.GetCurrentAnimatorStateInfo(1).normalizedTime;
        this.m_LastHandPos       = this.m_RHand.position;
        cj_obj   = null;
        collider = null;
        return(false);
    }
예제 #21
0
 public virtual bool StopAnimOnHit(CJObject hit_obj, Collider coll = null)
 {
     return(false);
 }