Exemple #1
0
        public static GenericSkill GetSkill(ExpandedSkillSlot expandedSlot, GameObject bodyPrefab)
        {
            GenericSkill skill = null;

            if (expandedSlot == ExpandedSkillSlot.Jump)
            {
                // Get jump skill when implemented...
            }
            else if (expandedSlot != ExpandedSkillSlot.None)
            {
                SkillLocator locator = bodyPrefab.GetComponent <SkillLocator>();
                skill = locator?.GetSkill(expandedSlot.ToBaseSkillSlot());
            }
            return(skill);
        }
Exemple #2
0
 // Token: 0x06002276 RID: 8822 RVA: 0x000952EC File Offset: 0x000934EC
 private void SetSkillStockDisplays()
 {
     if (this.hudElement.targetCharacterBody)
     {
         SkillLocator component = this.hudElement.targetCharacterBody.GetComponent <SkillLocator>();
         for (int i = 0; i < this.skillStockSpriteDisplays.Length; i++)
         {
             bool active = false;
             CrosshairController.SkillStockSpriteDisplay skillStockSpriteDisplay = this.skillStockSpriteDisplays[i];
             GenericSkill skill = component.GetSkill(skillStockSpriteDisplay.skillSlot);
             if (skill && skill.stock >= skillStockSpriteDisplay.minimumStockCountToBeValid && skill.stock <= skillStockSpriteDisplay.maximumStockCountToBeValid)
             {
                 active = true;
             }
             skillStockSpriteDisplay.target.SetActive(active);
         }
     }
 }
            public override void WriteNewHooks()
            {
                if (BarrageScalesWithAttackSpeed.Value && BarrageScaleModifier.IsNotDefault())
                {
                    On.EntityStates.Commando.CommandoWeapon.FireBarrage.OnEnter += (orig, self) =>
                    {
                        orig(self);

                        Assembly assembly = self.GetType().Assembly;

                        Type      fireBarr    = assembly.GetClass("EntityStates.Commando.CommandoWeapon", "FireBarrage");
                        FieldInfo attackSpeed = typeof(BaseState).GetField("attackSpeedStat",
                                                                           BindingFlags.NonPublic | BindingFlags.Instance);

                        FieldInfo durationBetweenShots = fireBarr.GetField("durationBetweenShots",
                                                                           BindingFlags.NonPublic | BindingFlags.Instance);

                        float attackSpeedF = (float)attackSpeed?.GetValue(self);

                        int baseShot = BarrageBaseShotAmount.ValueConfigWrapper.IsDefault()
                            ? VanillaBarrageBaseShotAmount
                            : BarrageBaseShotAmount.ValueConfigWrapper.Value;

                        durationBetweenShots?.SetValue(self,
                                                       (BarrageBaseDurationBetweenShots.ValueConfigWrapper.IsDefault()
                                ? VanillaBarrageBaseDurationBetweenShots
                                : BarrageBaseDurationBetweenShots.ValueConfigWrapper.FloatValue) / attackSpeedF /
                                                       BarrageScaleModifier.FloatValue);

                        fireBarr.SetFieldValue("bulletCount",
                                               baseShot + (int)((attackSpeedF - 1) * BarrageScaleModifier.FloatValue * baseShot));
                    };
                }


                On.EntityStates.Commando.DodgeState.OnEnter += (orig, self) =>
                {
                    orig(self);

                    if (DashResetsSecondCooldown.Value)
                    {
                        Assembly assembly = self.GetType().Assembly;

                        Type entityState = assembly.GetClass("EntityStates", "EntityState");

                        SkillLocator locator = (SkillLocator)entityState
                                               .GetProperty("skillLocator", BindingFlags.NonPublic | BindingFlags.Instance)
                                               ?.GetValue(self, null);

                        GenericSkill skill2 = locator.GetSkill(SkillSlot.Secondary);
                        skill2.Reset();
                    }

                    if (DashInvulnerability.Value)
                    {
                        if (DashInvulnerabilityTimer.IsDefault())
                        {
                            Transform transform = self.InvokeMethod <Transform>("GetModelTransform");

                            HurtBoxGroup hurtBoxGroup = transform.GetComponent <HurtBoxGroup>();
                            ++hurtBoxGroup.hurtBoxesDeactivatorCounter;
                        }
                        else
                        {
                            self.outer.commonComponents.characterBody.AddTimedBuff(BuffIndex.HiddenInvincibility,
                                                                                   DashInvulnerabilityTimer.FloatValue);
                        }
                    }
                };

                On.EntityStates.Commando.DodgeState.OnExit += (orig, self) =>
                {
                    if (DashInvulnerability.Value && DashInvulnerabilityTimer.IsDefault())
                    {
                        Transform transform = self.InvokeMethod <Transform>("GetModelTransform");

                        HurtBoxGroup hurtBoxGroup = transform.GetComponent <HurtBoxGroup>();
                        --hurtBoxGroup.hurtBoxesDeactivatorCounter;
                    }

                    orig(self);
                };


                if (PistolHitLowerBarrageCooldown.Value && PistolHitLowerBarrageCooldownPercent.IsNotDefault())
                {
                    Type      gsType            = typeof(GenericSkill);
                    FieldInfo rechargeStopwatch = gsType.GetField("rechargeStopwatch",
                                                                  BindingFlags.NonPublic | BindingFlags.Instance);
                    FieldInfo finalRechargeInterval = gsType.GetField("finalRechargeInterval",
                                                                      BindingFlags.NonPublic | BindingFlags.Instance);

                    IL.EntityStates.Commando.CommandoWeapon.FirePistol2.FireBullet += il =>
                    {
                        ILCursor c = new ILCursor(il);

                        c.GotoNext(x => x.MatchCallvirt(typeof(RoR2.BulletAttack).FullName, "Fire"));
                        c.EmitDelegate <Func <BulletAttack, BulletAttack> >((BulletAttack ba) =>
                        {
                            ba.hitCallback = (ref BulletAttack.BulletHit info) =>
                            {
                                bool result = ba.DefaultHitCallback(ref info);
                                if (info.entityObject?.GetComponent <HealthComponent>())
                                {
                                    SkillLocator skillLocator = ba.owner.GetComponent <SkillLocator>();
                                    GenericSkill special      = skillLocator.special;
                                    rechargeStopwatch.SetValue(special,
                                                               (float)rechargeStopwatch.GetValue(special) +
                                                               (float)finalRechargeInterval.GetValue(special) *
                                                               PistolHitLowerBarrageCooldownPercent.FloatValue);
                                }

                                return(result);
                            };
                            return(ba);
                        });
                    };
                }
            }