Beispiel #1
0
        public override void FixedUpdate()
        {
            base.FixedUpdate();
            if (this.animator)
            {
                this.animator.SetBool("isGrounded", false);
            }

            if (base.fixedAge >= this.duration / 2f && base.isAuthority && !this.hasInputJump)
            {
                this.hasInputJump = true;
                base.characterMotor.moveDirection = base.inputBank.moveVector;

                // wax quail
                int   itemCount       = base.characterBody.inventory.GetItemCount(RoR2Content.Items.JumpBoost);
                float horizontalBonus = 1f;
                float verticalBonus   = 1f;
                bool  quailJump       = false;

                if (itemCount > 0 && base.characterBody.isSprinting)
                {
                    float bonus = base.characterBody.acceleration * base.characterMotor.airControl;
                    if (base.characterBody.moveSpeed > 0f && bonus > 0f)
                    {
                        quailJump = true;
                        float num2 = Mathf.Sqrt(10f * (float)itemCount / bonus);
                        float num3 = base.characterBody.moveSpeed / bonus;
                        horizontalBonus = (num2 + num3) / num3;
                    }
                }

                GenericCharacterMain.ApplyJumpVelocity(base.characterMotor, base.characterBody, horizontalBonus, verticalBonus, false);

                if (quailJump)
                {
                    EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BoostJumpEffect"), new EffectData
                    {
                        origin   = base.characterBody.footPosition,
                        rotation = Util.QuaternionSafeLookRotation(base.characterMotor.velocity)
                    }, true);
                }
            }

            if (base.fixedAge >= this.duration && base.isAuthority)
            {
                this.outer.SetNextStateToMain();
            }
        }
        internal static void GatherInputsOverrideHook(On.EntityStates.GenericCharacterMain.orig_GatherInputs orig, GenericCharacterMain self)
        {
            orig(self);

            if (!instances.TryGetValue(self, out var extraGenericCharacterMain))
            {
                instances.Add(self, extraGenericCharacterMain = new ExtraGenericCharacterMain
                {
                    ExtraSkillLocator  = self.outer.GetComponent <ExtraSkillLocator>(),
                    ExtraInputBankTest = self.outer.GetComponent <ExtraInputBankTest>()
                });
            }

            var extraInputBankTest = extraGenericCharacterMain.ExtraInputBankTest;

            if (!extraInputBankTest)
            {
                return;
            }

            extraGenericCharacterMain.extraSkill1InputReceived |= extraInputBankTest.extraSkill1.down;
            extraGenericCharacterMain.extraSkill2InputReceived |= extraInputBankTest.extraSkill2.down;
            extraGenericCharacterMain.extraSkill3InputReceived |= extraInputBankTest.extraSkill3.down;
            extraGenericCharacterMain.extraSkill4InputReceived |= extraInputBankTest.extraSkill4.down;
        }
        internal static void PerformInputsOverrideHook(On.EntityStates.GenericCharacterMain.orig_PerformInputs orig, GenericCharacterMain self)
        {
            orig(self);

            if (!self.isAuthority)
            {
                return;
            }

            if (!instances.TryGetValue(self, out var extraGenericCharacterMain))
            {
                instances.Add(self, extraGenericCharacterMain = new ExtraGenericCharacterMain
                {
                    ExtraSkillLocator  = self.outer.GetComponent <ExtraSkillLocator>(),
                    ExtraInputBankTest = self.outer.GetComponent <ExtraInputBankTest>()
                });
            }

            var extraSkillLocator  = extraGenericCharacterMain.ExtraSkillLocator;
            var extraInputBankTest = extraGenericCharacterMain.ExtraInputBankTest;

            if (extraSkillLocator && extraInputBankTest && extraGenericCharacterMain != null)
            {
                HandleSkill(extraSkillLocator.extraFirst, ref extraGenericCharacterMain.extraSkill1InputReceived, extraInputBankTest.extraSkill1.justPressed);
                HandleSkill(extraSkillLocator.extraSecond, ref extraGenericCharacterMain.extraSkill2InputReceived, extraInputBankTest.extraSkill2.justPressed);
                HandleSkill(extraSkillLocator.extraThird, ref extraGenericCharacterMain.extraSkill3InputReceived, extraInputBankTest.extraSkill3.justPressed);
                HandleSkill(extraSkillLocator.extraFourth, ref extraGenericCharacterMain.extraSkill4InputReceived, extraInputBankTest.extraSkill4.justPressed);
            }

            void HandleSkill(GenericSkill skillSlot, ref bool inputReceived, bool justPressed)
            {
                bool flag = inputReceived;

                inputReceived = false;
                if (!skillSlot || !justPressed && (!flag || skillSlot.mustKeyPress) || !self.CanExecuteSkill(skillSlot))
                {
                    return;
                }
                skillSlot.ExecuteIfReady();
            }
        }