Beispiel #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 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);
        }
Beispiel #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 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);
        }
Beispiel #3
0
 protected override void Update()
 {
     if (UCheatmenu.FastFlint)
     {
         if (this._player.CurrentView == TheForest.Items.Inventory.PlayerInventory.PlayerViews.World)
         {
             if (this._player.AmountOf(this._ammoItemId, true) > 0)
             {
                 TheForest.Utils.LocalPlayer.Animator.SetBool("noAmmo", false);
             }
             else
             {
                 TheForest.Utils.LocalPlayer.Animator.SetBool("noAmmo", true);
             }
             if (!TheForest.Utils.LocalPlayer.Create.Grabber.Target && TheForest.Utils.LocalPlayer.MainCamTr.forward.y < -0.85f)
             {
                 TheForest.Items.Craft.WeaponStatUpgrade.Types types = this.NextAvailableArrowBonus(this.BowItemView.ActiveBonus);
                 if (types != this.BowItemView.ActiveBonus)
                 {
                     this._showRotateArrowType = true;
                     if (!TheForest.Utils.Scene.HudGui.ToggleArrowBonusIcon.activeSelf)
                     {
                         TheForest.Utils.Scene.HudGui.ToggleArrowBonusIcon.SetActive(true);
                     }
                     if (TheForest.Utils.Input.GetButtonDown("Rotate"))
                     {
                         TheForest.Utils.LocalPlayer.Sfx.PlayWhoosh();
                         this.SetActiveBowBonus(types);
                         TheForest.Utils.Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
                     }
                 }
                 else if (this._showRotateArrowType)
                 {
                     this._showRotateArrowType = false;
                     TheForest.Utils.Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
                 }
             }
             else if (this._showRotateArrowType)
             {
                 this._showRotateArrowType = false;
                 TheForest.Utils.Scene.HudGui.ToggleArrowBonusIcon.SetActive(false);
             }
             if (this.CurrentArrowItemView.ActiveBonus != this.BowItemView.ActiveBonus)
             {
                 TheForest.Utils.LocalPlayer.Inventory.SortInventoryViewsByBonus(this.CurrentArrowItemView, this.BowItemView.ActiveBonus, false);
                 if (this.CurrentArrowItemView.ActiveBonus != this.BowItemView.ActiveBonus)
                 {
                     this.SetActiveBowBonus(this.CurrentArrowItemView.ActiveBonus);
                 }
                 this.UpdateArrowRenderer();
             }
             TheForest.Items.Craft.WeaponStatUpgrade.Types activeBonus = this.CurrentArrowItemView.ActiveBonus;
             bool canSetArrowOnFire = this.CanSetArrowOnFire;
             if (canSetArrowOnFire && TheForest.Utils.Input.GetButton("Lighter"))
             {
                 TheForest.Utils.Scene.HudGui.SetDelayedIconController(this);
             }
             else
             {
                 TheForest.Utils.Scene.HudGui.UnsetDelayedIconController(this);
             }
             if (canSetArrowOnFire)
             {
                 if (TheForest.Utils.Input.GetButtonAfterDelay("Lighter", 0.5f, false))
                 {
                     this.SetArrowOnFire();
                 }
             }
             else if (activeBonus != TheForest.Items.Craft.WeaponStatUpgrade.Types.BurningAmmo && this._activeAmmoBonus != activeBonus)
             {
                 this.SetActiveArrowBonus(activeBonus);
             }
             if (!this._lightingArrow)
             {
                 if (TheForest.Utils.Input.GetButtonDown("Fire1") && !TheForest.Utils.LocalPlayer.Animator.GetBool("ballHeld"))
                 {
                     this._animator.speed    = 20f;
                     this._bowAnimator.speed = 20f;
                     TheForest.Utils.LocalPlayer.Inventory.CancelNextChargedAttack = false;
                     if (this._aimingReticle)
                     {
                         this._aimingReticle.enabled = true;
                     }
                     this.ReArm();
                     this._animator.SetBoolReflected("drawBowBool", true);
                     this._bowAnimator.SetBoolReflected("drawBool", true);
                     this._bowAnimator.SetBoolReflected("bowFireBool", false);
                     this._animator.SetBoolReflected("bowFireBool", false);
                     this._player.StashLeftHand();
                     this._animator.SetBoolReflected("checkArms", false);
                     this._animator.SetBoolReflected("onHand", false);
                 }
                 else if (TheForest.Utils.Input.GetButtonDown("AltFire") || TheForest.Utils.LocalPlayer.Animator.GetBool("ballHeld"))
                 {
                     TheForest.Utils.LocalPlayer.AnimControl.animEvents.enableSpine();
                     this._player.CancelNextChargedAttack = true;
                     this._animator.SetBool("drawBowBool", false);
                     this._bowAnimator.SetBool("drawBool", false);
                     this.ShutDown(false);
                 }
                 if (TheForest.Utils.Input.GetButtonUp("Fire1") || TheForest.Utils.LocalPlayer.Animator.GetBool("ballHeld"))
                 {
                     this._currentAmmo = this.CurrentArrowItemView;
                     if (this._aimingReticle)
                     {
                         this._aimingReticle.enabled = false;
                     }
                     base.CancelInvoke();
                     if (this._animator.GetCurrentAnimatorStateInfo(1).tagHash == this._attackHash && this._animator.GetBool("drawBowBool") && !TheForest.Utils.LocalPlayer.Animator.GetBool("ballHeld") && !TheForest.Utils.LocalPlayer.Inventory.blockRangedAttack)
                     {
                         this._animator.SetBoolReflected("bowFireBool", true);
                         this._bowAnimator.SetBoolReflected("bowFireBool", true);
                         this._animator.SetBoolReflected("drawBowBool", false);
                         this._bowAnimator.SetBoolReflected("drawBool", false);
                         TheForest.Utils.LocalPlayer.TargetFunctions.sendPlayerAttacking();
                         this.InitReArm();
                     }
                     else if (TheForest.Utils.LocalPlayer.Animator.GetBool("ballHeld"))
                     {
                         TheForest.Utils.LocalPlayer.AnimControl.animEvents.enableSpine();
                         this._player.CancelNextChargedAttack = true;
                         this._animator.SetBoolReflected("drawBowBool", false);
                         this._bowAnimator.SetBoolReflected("drawBool", false);
                         this.ShutDown(false);
                     }
                     else if (TheForest.Utils.LocalPlayer.Inventory.blockRangedAttack)
                     {
                         this.ShutDown(false);
                     }
                     else
                     {
                         this.ShutDown(true);
                     }
                     this._animator.speed    = 1f;
                     this._bowAnimator.speed = 1f;
                 }
                 else if (Time.time + 0.1f < Time.time)
                 {
                     this.ReArm();
                 }
             }
             else
             {
                 TheForest.Utils.LocalPlayer.Inventory.CancelNextChargedAttack = true;
             }
         }
     }
     else
     {
         base.Update();
     }
 }