Esempio n. 1
0
        public override bool stickArrowToNearestBone(Transform arrow)
        {
            Transform parent = arrow.parent;

            TheForest.Items.Craft.WeaponStatUpgrade.Types types      = (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1);
            TheForest.Items.Inventory.ItemProperties      properties = parent.GetComponent <global::arrowTrajectory>()._pickup.GetComponent <TheForest.Items.World.PickUp>()._properties;
            if (properties != null && properties.ActiveBonus != (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1))
            {
                types = properties.ActiveBonus;
            }
            int  item = 0;
            bool flag = false;
            global::ArrowDamage component = arrow.GetComponent <global::ArrowDamage>();

            if (component.crossbowBoltType)
            {
                flag = true;
            }
            GameObject gameObject;

            if (flag)
            {
                gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeBoltPickup, parent.transform.position, parent.transform.rotation);
            }
            else if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.BoneAmmo)
            {
                if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.ModernAmmo)
                {
                    gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowPickup, parent.transform.position, parent.transform.rotation);
                    item       = 0;
                }
                else
                {
                    gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowModernPickup, parent.transform.position, parent.transform.rotation);
                    item       = 2;
                }
            }
            else
            {
                gameObject = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowBonePickup, parent.transform.position, parent.transform.rotation);
                item       = 1;
            }
            if (ModdedPlayer.instance.ReusabilityChance > 0.35f || (int)ModSettings.difficulty > 2)
            {
                float multishotMult = Mathf.Min(14.4f, ModdedPlayer.instance.MultishotCount / 0.9f);
                Destroy(gameObject, 15 - multishotMult);
            }
            if (flag)
            {
                item = 3;
            }
            Collider component2 = gameObject.GetComponent <Collider>();

            if (component2)
            {
                component2.enabled = false;
            }
            Transform tip = gameObject.GetComponent <global::fakeArrowSetup>().tip;

            tip.position -= tip.forward * 1.4f;
            int num = this.returnNearestJointMidPoint(tip);

            if (this.singleJointMode)
            {
                num = 0;
                Vector3 vector = (gameObject.transform.position - this.baseJoint.position).normalized;
                vector = this.baseJoint.position + vector * 0.2f;
                gameObject.transform.parent   = this.baseJoint;
                gameObject.transform.position = vector;
                gameObject.transform.rotation = Quaternion.LookRotation(gameObject.transform.position - this.baseJoint.position) * Quaternion.Euler(-90f, 0f, 0f);
            }
            else
            {
                Transform   transform  = this.stickToJoints[num];
                IEnumerator enumerator = this.stickToJoints[num].GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        object    obj        = enumerator.Current;
                        Transform transform2 = (Transform)obj;
                        if (!transform2.GetComponent <MonoBehaviour>())
                        {
                            transform = transform2;
                            break;
                        }
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                //if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                //{
                //    SpellActions.SeekingArrow = true;
                //    SpellActions.SeekingArrow_Target.gameObject.SetActive(true);
                //    SpellActions.SeekingArrow_Target.transform.parent = this.stickToJoints[num];
                //    SpellActions.SeekingArrow_Target.transform.position = this.stickToJoints[num].position;
                //    SpellActions.SeekingArrow_TimeStamp = Time.time;
                //    startposition = transform.position;
                //    SpellActions.SeekingArrow_ChangeTargetOnHit = false;
                //}



                Vector3 vector2 = (this.stickToJoints[num].position + transform.position) / 2f;
                Vector3 vector3 = (gameObject.transform.position - vector2).normalized;
                vector3 = vector2 + vector3 * 0.35f;
                gameObject.transform.parent   = this.stickToJoints[num];
                gameObject.transform.position = vector3;
                gameObject.transform.rotation = Quaternion.LookRotation(gameObject.transform.position - vector2) * Quaternion.Euler(-90f, 0f, 0f);
            }
            bool result = false;

            if (this.stickToJoints.Length > 0 && this.stickToJoints[num] && this.stickToJoints[num].GetComponent <global::headShotObject>())
            {
                result = true;
            }
            if (!this.stuckArrows.ContainsKey(gameObject.transform))
            {
                this.stuckArrows.Add(gameObject.transform, num);
                this.stuckArrowsTypeList.Add(item);
                global::fakeArrowSetup component3 = gameObject.GetComponent <global::fakeArrowSetup>();
                if (component3 && BoltNetwork.isRunning)
                {
                    component3.storedIndex  = this.stuckArrows.Count - 1;
                    component3.entityTarget = base.transform.root.GetComponent <BoltEntity>();
                }
                this.numStuckArrows++;
            }
            if (BoltNetwork.isRunning)
            {
                BoltEntity component4 = parent.GetComponent <BoltEntity>();
                if (component4.isAttached && component4.isOwner)
                {
                    if (this.IsCreature && BoltNetwork.isServer)
                    {
                        base.StartCoroutine(this.SendArrowMPDelayed(gameObject, num, types, flag));
                    }
                    else
                    {
                        this.sendArrowMP(gameObject, num, types, flag);
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        public override bool stickArrowToNearestBone(Transform arrow)
        {
            Transform parent = arrow.parent;

            TheForest.Items.Craft.WeaponStatUpgrade.Types types      = (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1);
            TheForest.Items.Inventory.ItemProperties      properties = parent.GetComponent <global::arrowTrajectory>()._pickup.GetComponent <TheForest.Items.World.PickUp>()._properties;
            if (properties != null && properties.ActiveBonus != (TheForest.Items.Craft.WeaponStatUpgrade.Types)(-1))
            {
                types = properties.ActiveBonus;
            }
            int  item = 0;
            bool flag = false;
            global::ArrowDamage component = arrow.GetComponent <global::ArrowDamage>();

            if (component.crossbowBoltType)
            {
                flag = true;
            }
            GameObject attached;

            if (flag)
            {
                attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeBoltPickup, parent.transform.position, parent.transform.rotation);
                item     = 3;
            }
            else if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.BoneAmmo)
            {
                if (types != TheForest.Items.Craft.WeaponStatUpgrade.Types.ModernAmmo)
                {
                    attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowPickup, parent.transform.position, parent.transform.rotation);
                    item     = 0;
                }
                else
                {
                    attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowModernPickup, parent.transform.position, parent.transform.rotation);
                    item     = 2;
                }
            }
            else
            {
                attached = UnityEngine.Object.Instantiate <GameObject>(this.fakeArrowBonePickup, parent.transform.position, parent.transform.rotation);
                item     = 1;
            }

            Collider component2 = attached.GetComponent <Collider>();

            if (component2)
            {
                component2.enabled = false;
            }
            Transform tip = attached.GetComponent <global::fakeArrowSetup>().tip;
            int       num = this.returnNearestJointMidPoint(tip);

            if (this.singleJointMode)
            {
                num = 0;
                Vector3 vector = (attached.transform.position - this.baseJoint.position).normalized;
                vector = this.baseJoint.position + vector * 0.2f;
                attached.transform.parent   = this.baseJoint;
                attached.transform.position = vector;
                attached.transform.rotation = Quaternion.LookRotation(attached.transform.position - this.baseJoint.position) * Quaternion.Euler(-90f, 0f, 0f);
            }
            else
            {
                Transform tr = this.stickToJoints[num];
                foreach (Transform transform2 in this.stickToJoints[num])
                {
                    if (transform2.GetComponent <MonoBehaviour>() == null)
                    {
                        tr = transform2;
                        break;
                    }
                }
                Vector3 vector2 = (this.stickToJoints[num].position + tr.position) / 2f;
                Vector3 vector3 = (attached.transform.position - vector2).normalized;
                vector3 = vector2 + vector3 * 0.35f;
                attached.transform.parent   = this.stickToJoints[num];
                attached.transform.position = vector3;
                attached.transform.rotation = Quaternion.LookRotation(attached.transform.position - vector2) * Quaternion.Euler(-90f, 0f, 0f);
                if (SpellActions.SeekingArrow_ChangeTargetOnHit)
                {
                    SpellActions.SetSeekingArrowTarget(this.stickToJoints[num]);
                }
            }
            bool isHeadshot = false;

            if (this.stickToJoints.Length > 0 && this.stickToJoints[num] && this.stickToJoints[num].GetComponent <global::headShotObject>())
            {
                isHeadshot = true;
            }
            if (numStuckArrows < 20)
            {
                if (!this.stuckArrows.ContainsKey(attached.transform))
                {
                    this.stuckArrows.Add(attached.transform, num);
                    this.stuckArrowsTypeList.Add(item);
                    global::fakeArrowSetup component3 = attached.GetComponent <global::fakeArrowSetup>();
                    if (component3 && BoltNetwork.isRunning)
                    {
                        component3.storedIndex  = this.stuckArrows.Count - 1;
                        component3.entityTarget = base.transform.root.GetComponent <BoltEntity>();
                    }
                    this.numStuckArrows++;
                }
                if (BoltNetwork.isRunning)
                {
                    BoltEntity component4 = parent.GetComponent <BoltEntity>();
                    if (component4.isAttached && component4.isOwner)
                    {
                        if (this.IsCreature && BoltNetwork.isServer)
                        {
                            base.StartCoroutine(this.SendArrowMPDelayed(attached, num, types, flag));
                        }
                        else
                        {
                            this.sendArrowMP(attached, num, types, flag);
                        }
                    }
                }
            }
            else
            {
                Destroy(attached, 1f);
            }
            return(isHeadshot);
        }