// Token: 0x0600211F RID: 8479 RVA: 0x0008F0C0 File Offset: 0x0008D2C0
        public virtual void OnBodyStart(CharacterBody newBody)
        {
            this.body                   = newBody;
            this.bodyTransform          = newBody.transform;
            this.bodyCharacterDirection = newBody.GetComponent <CharacterDirection>();
            this.bodyCharacterMotor     = newBody.GetComponent <CharacterMotor>();
            this.bodyInputBank          = newBody.GetComponent <InputBankTest>();
            this.bodyHealthComponent    = newBody.GetComponent <HealthComponent>();
            this.bodySkillLocator       = newBody.GetComponent <SkillLocator>();
            this.localNavigator.SetBody(newBody);
            this.PickCurrentNodeGraph();
            if (this.stateMachine && Util.HasEffectiveAuthority(this.networkIdentity))
            {
                this.stateMachine.enabled = true;
                this.stateMachine.SetNextState(EntityState.Instantiate(this.scanState));
            }
            base.enabled = true;
            if (this.bodyInputBank)
            {
                this.desiredAimDirection = this.bodyInputBank.aimDirection;
            }
            Action <CharacterBody> action = this.onBodyDiscovered;

            if (action == null)
            {
                return;
            }
            action(newBody);
        }
 private void CharacterBody_RecalculateStats(On.RoR2.CharacterBody.orig_RecalculateStats orig, CharacterBody self)
 {
     try
     {
         if (self.name.StartsWith(CharBodyStrings.Engineer))
         {
             if (TurretStockIncreasesWithBackup.Value)
             {
                 self.GetComponent <SkillLocator>().special.SetBonusStockFromBody(self.inventory.GetItemCount(ItemIndex.SecondarySkillMagazine));
             }
         }
         if (self.name.StartsWith(CharBodyStrings.Mage))
         {
             if (PrimaryIncreasesWitBackup.Value)
             {
                 self.GetComponent <SkillLocator>().primary.SetBonusStockFromBody(self.inventory.GetItemCount(ItemIndex.SecondarySkillMagazine));
             }
         }
     }
     catch (System.Exception ex)
     {
         Logger.LogError(ex);
     }
     orig(self);
 }
Example #3
0
        private void On_CBFixedUpdate(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);
            var cpt = self.GetComponent <GoldenGunComponent>();

            if (!cpt)
            {
                return;
            }
            var newMoney = self.master?.money ?? 0;

            if (inclDeploys)
            {
                var dplc = self.GetComponent <Deployable>();
                if (dplc)
                {
                    newMoney += dplc.ownerMaster?.money ?? 0;
                }
            }
            if (cpt.cachedMoney != newMoney || cpt.cachedDiff != Run.instance.difficultyCoefficient)
            {
                cpt.cachedMoney = newMoney;
                cpt.cachedDiff  = Run.instance.difficultyCoefficient;
                UpdateGGBuff(self);
            }
        }
        public void AimBot()
        {
            InputBankTest component  = body.GetComponent <InputBankTest>();
            Ray           ray        = new Ray(component.aimOrigin, component.aimDirection);
            TeamComponent component2 = body.GetComponent <TeamComponent>();

            bullseyeSearch.teamMaskFilter = TeamMask.all;
            bullseyeSearch.teamMaskFilter.RemoveTeam(component2.teamIndex);
            bullseyeSearch.filterByLoS = true;
            //bullseyeSearch.filterByDistinctEntity = true;
            bullseyeSearch.searchOrigin      = ray.origin;
            bullseyeSearch.searchDirection   = ray.direction;
            bullseyeSearch.sortMode          = BullseyeSearch.SortMode.Angle;
            bullseyeSearch.maxDistanceFilter = cachedIcnt;
            bullseyeSearch.maxAngleFilter    = 60f;
            bullseyeSearch.itemMult          = (float)cachedIcnt;
            bullseyeSearch.RefreshCandidates();
            HurtBox hurtBox = bullseyeSearch.GetResults().FirstOrDefault <HurtBox>();
            bool    flag    = hurtBox;

            if (flag)
            {
                target = hurtBox;
                Vector3 aimDirection = hurtBox.transform.position - ray.origin;
                component.aimDirection = aimDirection;
            }
        }
Example #5
0
 // Token: 0x0600109F RID: 4255 RVA: 0x00048E20 File Offset: 0x00047020
 private void UpdatePull(float deltaTime)
 {
     if (!this.pulling)
     {
         return;
     }
     for (int i = 0; i < this.victimBodyList.Count; i++)
     {
         CharacterBody  characterBody = this.victimBodyList[i];
         Vector3        vector        = base.transform.position - characterBody.corePosition;
         float          d             = this.pullStrengthCurve.Evaluate(vector.magnitude / this.pullRadius);
         Vector3        b             = vector.normalized * d * deltaTime;
         CharacterMotor component     = characterBody.GetComponent <CharacterMotor>();
         if (component)
         {
             component.rootMotion += b;
         }
         else
         {
             Rigidbody component2 = characterBody.GetComponent <Rigidbody>();
             if (component2)
             {
                 component2.velocity += b;
             }
         }
     }
 }
 private void PullEnemies(float deltaTime)
 {
     if (!this.pulling)
     {
         InitializePull();
     }
     for (int i = 0; i < this.pullList.Count; i++)
     {
         CharacterBody characterBody = this.pullList[i];
         if (characterBody && characterBody.transform)
         {
             Vector3        vector    = ((this.pullOrigin) ? this.pullOrigin.position : base.transform.position) - characterBody.corePosition;
             float          d         = this.pullStrengthCurve.Evaluate(vector.magnitude / pullRadius);
             Vector3        b         = vector.normalized * d * deltaTime * pullForce;
             CharacterMotor component = characterBody.GetComponent <CharacterMotor>();
             if (component)
             {
                 component.rootMotion += b;
                 if (component.useGravity)
                 {
                     component.rootMotion.y -= (Physics.gravity.y * deltaTime * d);
                 }
             }
             else
             {
                 Rigidbody component2 = characterBody.GetComponent <Rigidbody>();
                 if (component2)
                 {
                     component2.velocity += b;
                 }
             }
         }
     }
 }
Example #7
0
        // Token: 0x06000CF7 RID: 3319 RVA: 0x00040230 File Offset: 0x0003E430
        public void OnBodyStart(CharacterBody body)
        {
            this.preventGameOver = true;
            this.killerBodyIndex = -1;
            TeamComponent component = body.GetComponent <TeamComponent>();

            if (component)
            {
                component.teamIndex = this.teamIndex;
            }
            body.RecalculateStats();
            if (NetworkServer.active)
            {
                BaseAI[] components = base.GetComponents <BaseAI>();
                for (int i = 0; i < components.Length; i++)
                {
                    components[i].OnBodyStart(body);
                }
            }
            bool flag = false;
            PlayerCharacterMasterController component2 = base.GetComponent <PlayerCharacterMasterController>();

            if (component2)
            {
                if (component2.networkUserObject)
                {
                    flag = component2.networkUserObject.GetComponent <NetworkIdentity>().isLocalPlayer;
                }
                component2.OnBodyStart();
            }
            if (flag)
            {
                GlobalEventManager.instance.OnLocalPlayerBodySpawn(body);
            }
            if (this.inventory.GetItemCount(ItemIndex.Ghost) > 0)
            {
                Util.PlaySound("Play_item_proc_ghostOnKill", body.gameObject);
            }
            if (NetworkServer.active)
            {
                HealthComponent component3 = body.GetComponent <HealthComponent>();
                if (component3)
                {
                    component3.Networkhealth = component3.fullHealth;
                }
                this.UpdateBodyGodMode();
                this.StartLifeStopwatch();
                GlobalEventManager.instance.OnCharacterBodySpawn(body);
            }
            Action <CharacterBody> action = this.onBodyStart;

            if (action == null)
            {
                return;
            }
            action(body);
        }
        public override void OnEnter()
        {
            base.OnEnter();

            if (base.teamComponent && NetworkServer.active)
            {
                ReadOnlyCollection <TeamComponent> teamMembers = TeamComponent.GetTeamMembers(base.teamComponent.teamIndex);
                Vector3 position = base.transform.position;
                for (int i = 0; i < teamMembers.Count; i++)
                {
                    CharacterBody component = teamMembers[i].GetComponent <CharacterBody>();
                    if (component)
                    {
                        if (base.characterBody.skillLocator.utility.stock > 0 && !component.HasBuff(BuffIndex.EngiTeamShield))
                        {
                            component.AddTimedBuff(BuffIndex.EngiTeamShield, 8f);
                            component.AddTimedBuff(BuffIndex.TeslaField, 2f);

                            HealthComponent component2 = component.GetComponent <HealthComponent>();
                            if (component2)
                            {
                                component2.RechargeShieldFull();
                            }

                            base.skillLocator.utility.DeductStock(1);
                        }
                    }
                }
            }
        }
        private void UpdatePhotonFuel(CharacterBody tgt)
        {
            var cpt = tgt.GetComponent <PhotonJetpackComponent>();

            if (!cpt)
            {
                cpt = tgt.gameObject.AddComponent <PhotonJetpackComponent>();
            }

            int stacks = GetCount(tgt);

            cpt.fuelCap = stacks > 0 ? baseFuel + stackFuel * (stacks - 1) : 0;
            if (stacks > 0 && extraJumpInteraction == ExtraJumpInteractionType.ConvertJumpsToFuel)
            {
                cpt.fuelCap += (tgt.maxJumpCount - 1) * jumpFuel;
            }
            if (cpt.fuel > cpt.fuelCap)
            {
                cpt.fuel = cpt.fuelCap;
            }
            if (cpt.fuelCap == 0)
            {
                tgt.SetBuffCount(photonFuelBuff.buffIndex, 0);
            }
        }
Example #10
0
 // Token: 0x0600310D RID: 12557 RVA: 0x000D300C File Offset: 0x000D120C
 public override void OnEnter()
 {
     base.OnEnter();
     if (base.teamComponent && NetworkServer.active)
     {
         ReadOnlyCollection <TeamComponent> teamMembers = TeamComponent.GetTeamMembers(base.teamComponent.teamIndex);
         float   num      = EngiTeamShield.radius * EngiTeamShield.radius;
         Vector3 position = base.transform.position;
         for (int i = 0; i < teamMembers.Count; i++)
         {
             if ((teamMembers[i].transform.position - position).sqrMagnitude <= num)
             {
                 CharacterBody component = teamMembers[i].GetComponent <CharacterBody>();
                 if (component)
                 {
                     component.AddTimedBuff(BuffIndex.EngiTeamShield, EngiTeamShield.duration);
                     HealthComponent component2 = component.GetComponent <HealthComponent>();
                     if (component2)
                     {
                         component2.RechargeShieldFull();
                     }
                 }
             }
         }
     }
 }
Example #11
0
        ////// Hooks //////

        private string CharacterBody_GetDisplayName(On.RoR2.CharacterBody.orig_GetDisplayName orig, CharacterBody self)
        {
            var retv = orig(self);

            if (self.name == "ItemDroneBody(Clone)")
            {
                var ward = self.GetComponent <ItemWard>();
                if (!ward || ward.itemcounts.Count == 0)
                {
                    return(retv);
                }
                var idef = ItemCatalog.GetItemDef(ward.itemcounts.First().Key);
                if (idef == null)
                {
                    return(retv);
                }

                var color = "FFFFFF";
                var itd   = ItemTierCatalog.GetItemTierDef(idef.tier);
                if (itd)
                {
                    color = ColorCatalog.GetColorHexString(itd.colorIndex);
                }
                return($"{retv} (<color=#{color}>{Language.GetString(idef.nameToken)}</color>)");
            }
            return(retv);
        }
        private static void RecalculateCooldowns(CharacterBody characterBody, float scale, float flatCooldownReduction)
        {
            var extraSkillLocator = characterBody.GetComponent <ExtraSkillLocator>();

            if (!extraSkillLocator)
            {
                return;
            }
            if (extraSkillLocator.extraFirst)
            {
                extraSkillLocator.extraFirst.cooldownScale         = scale;
                extraSkillLocator.extraFirst.flatCooldownReduction = flatCooldownReduction;
            }
            if (extraSkillLocator.extraSecond)
            {
                extraSkillLocator.extraSecond.cooldownScale         = scale;
                extraSkillLocator.extraSecond.flatCooldownReduction = flatCooldownReduction;
            }
            if (extraSkillLocator.extraThird)
            {
                extraSkillLocator.extraThird.cooldownScale         = scale;
                extraSkillLocator.extraThird.flatCooldownReduction = flatCooldownReduction;
            }
            if (extraSkillLocator.extraFourth)
            {
                extraSkillLocator.extraFourth.cooldownScale         = scale;
                extraSkillLocator.extraFourth.flatCooldownReduction = flatCooldownReduction;
            }
        }
        public void ApplyAmmoPackToTeam(TeamIndex teamIndex = TeamIndex.Player, bool restoreEquipmentCharges = true, bool restoreOffhandEquipmentCharges = true)
        {
            ReadOnlyCollection <TeamComponent> teamComponents = TeamComponent.GetTeamMembers(teamIndex);

            foreach (TeamComponent teamComponent in teamComponents)
            {
                CharacterBody body = teamComponent.body;
                if (body)
                {
                    body.GetComponent <SkillLocator>()?.ApplyAmmoPack();

                    var inventory = body.inventory;
                    if (inventory)
                    {
                        if (restoreEquipmentCharges)
                        {
                            inventory.RestockEquipmentCharges(0, 1);
                        }

                        if (restoreOffhandEquipmentCharges)
                        {
                            for (int i = 0; i < inventory.GetEquipmentSlotCount() - 1; i++)
                            {
                                inventory.RestockEquipmentCharges((byte)Math.Min(i, 255), 1);
                            }
                        }
                    }
                    EffectManager.SimpleEffect(pickupEffect, body.transform.position, Quaternion.identity, true);
                }
            }
        }
        private void CultistPassiveItem_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
        {
            var component      = sender.GetComponent <CultistPassiveComponent>();
            var InventoryCount = GetCount(sender);

            if (InventoryCount > 0)
            {
                if (component)
                {
                    var deadAmt = component.deadProtagonists;

                    if (deadAmt > 0)
                    {
                        //float addAmount = CPI_singleplayer;
                        //if (component.isMultiplayer) addAmount = CPI_multiplayer;

                        args.baseAttackSpeedAdd += (BaseAttackSpeedAdd + BaseAttackSpeedAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.baseDamageAdd      += (BaseDamageAdd + BaseDamageAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.healthMultAdd      += (HealthMultAdd + HealthMultAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.baseMoveSpeedAdd   += (BaseMoveSpeedAdd + BaseMoveSpeedAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.regenMultAdd       += (RegenMultAdd + RegenMultAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.armorAdd           += (ArmorAdd + ArmorAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                        args.critAdd            += (CritAdd + CritAdd * (InventoryCount - 1) * StackModifier) * deadAmt;
                    }
                }
            }
        }
Example #15
0
        private void CharacterBody_OnSkillActivated(On.RoR2.CharacterBody.orig_OnSkillActivated orig, CharacterBody self, GenericSkill skill)
        {
            orig(self, skill);
            Inventory inventory = self.inventory;

            if (inventory)
            {
                var itemCount = inventory.GetItemCount(itemDef);
                if (itemCount > 0)
                {
                    if (skill.finalRechargeInterval > 0f && skill.skillDef.stockToConsume > 0)
                    {
                        var coeff = Util.ConvertAmplificationPercentageIntoReductionPercentage(cdr + cdrPerStack * (float)(itemCount - 1)) / 100f;
                        var cooldownsReducedBy = skill.finalRechargeInterval * coeff;
                        foreach (SkillSlot skillSlot in Enum.GetValues(typeof(SkillSlot)))
                        {
                            GenericSkill otherSkill = self.skillLocator.GetSkill(skillSlot);
                            if (skill != otherSkill && otherSkill != null && otherSkill.stock < otherSkill.maxStock)
                            {
                                otherSkill.rechargeStopwatch += cooldownsReducedBy;
                            }
                        }
                        var fxHelper = self.GetComponent <MysticsItemsThoughtProcessorFXHelper>();
                        if (!fxHelper)
                        {
                            fxHelper = self.gameObject.AddComponent <MysticsItemsThoughtProcessorFXHelper>();
                        }
                        fxHelper.OnTrigger(cooldownsReducedBy);
                    }
                }
            }
        }
        public override void OnEnter()
        {
            base.OnEnter();

            if (NetworkServer.active)
            {
                ReadOnlyCollection <TeamComponent> teamMembers = TeamComponent.GetTeamMembers(base.teamComponent.teamIndex);
                Vector3 position = base.transform.position;
                for (int i = 0; i < teamMembers.Count; i++)
                {
                    CharacterBody component = teamMembers[i].GetComponent <CharacterBody>();
                    if (component)
                    {
                        if (base.characterBody.skillLocator.utility.stock > 0 && !component.HasBuff(BuffIndex.EngiShield) && !component.HasBuff(BuffIndex.ElephantArmorBoost))
                        {
                            component.AddTimedBuff(BuffIndex.EngiShield, 3f);
                            component.AddTimedBuff(BuffIndex.Immune, 3f);
                            component.AddTimedBuff(BuffIndex.ElephantArmorBoost, 6f);

                            HealthComponent component2 = component.GetComponent <HealthComponent>();
                            if (component2)
                            {
                                component2.RechargeShieldFull();
                            }

                            base.skillLocator.utility.DeductStock(1);
                        }
                    }
                }
            }

            base.OnExit();
            base.outer.SetNextStateToMain();
        }
        ////// Hooks //////

        private void CharacterBody_onBodyInventoryChangedGlobal(CharacterBody body)
        {
            if (GetCount(body) > 0 && !body.GetComponent <EnterCombatDamageTracker>())
            {
                body.gameObject.AddComponent <EnterCombatDamageTracker>();
            }
        }
Example #18
0
 private void GenericPickupController_AttemptGrant(On.RoR2.GenericPickupController.orig_AttemptGrant orig, GenericPickupController self, CharacterBody body)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::AttemptGrant(RoR2.CharacterBody)' called on client");
         return;
     }
     if (!self.gameObject.GetComponent <SpiceRolled>())
     {
         self.gameObject.AddComponent <SpiceRolled>();
         TeamComponent component = body.GetComponent <TeamComponent>();
         if (component && component.teamIndex == TeamIndex.Player)
         {
             Inventory inventory = body.inventory;
             if (inventory)
             {
                 var spiceCount         = inventory.GetItemCount(SpiceTally);
                 var spiceCountAdjusted = spiceCount < SpiceEquipment_MaxPerPlayer ? spiceCount : 0;
                 if (Util.CheckRoll(spiceCountAdjusted))
                 {
                     self.pickupIndex = PickupCatalog.FindPickupIndex(Spice.instance.EquipmentDef.equipmentIndex);
                 }
             }
         }
     }
     orig(self, body);
 }
Example #19
0
        private void AttemptGrant(CharacterBody body)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::AttemptGrant(RoR2.CharacterBody)' called on client");
                return;
            }
            TeamComponent component = body.GetComponent <TeamComponent>();

            if (component && component.teamIndex == TeamIndex.Player)
            {
                Inventory inventory = body.inventory;
                if (inventory)
                {
                    this.consumed = true;
                    if (this.pickupIndex.itemIndex != ItemIndex.None)
                    {
                        this.GrantItem(body, inventory);
                    }
                    if (this.pickupIndex.equipmentIndex != EquipmentIndex.None)
                    {
                        this.GrantEquipment(body, inventory);
                    }
                    if (this.pickupIndex.coinValue != 0U)
                    {
                        this.GrantLunarCoin(body, this.pickupIndex.coinValue);
                    }
                }
            }
        }
Example #20
0
        public override void Effect(GlobalEventManager globalEventManager, DamageInfo damageInfo, GameObject victim, int itemCount)
        {
            CharacterBody   body              = damageInfo.attacker.GetComponent <CharacterBody>();
            CharacterBody   Attacker          = damageInfo.attacker.GetComponent <CharacterBody>();
            CharacterBody   characterBody     = victim ? victim.GetComponent <CharacterBody>() : null;
            CharacterMaster master            = Attacker.master;
            Inventory       inventory         = master.inventory;
            TeamComponent   Team              = Attacker.GetComponent <TeamComponent>();
            TeamIndex       attackerTeamIndex = Team ? Team.teamIndex : TeamIndex.Neutral;
            Vector3         aimOrigin         = Attacker.aimOrigin;

            damageInfo.procChainMask.SetProcValue(ProcType.Rings, true);



            float      damageCoefficient = (float)(1.25 + 1.25 * itemCount);
            float      num3        = Util.OnHitProcDamage(damageInfo.damage, Attacker.damage, damageCoefficient);
            DamageInfo damageInfo1 = new DamageInfo()
            {
                damage           = num3,
                damageColorIndex = DamageColorIndex.Item,
                damageType       = RoR2.DamageType.Generic,
                attacker         = damageInfo.attacker,
                crit             = damageInfo.crit,
                force            = Vector3.zero,
                inflictor        = (GameObject)null,
                position         = damageInfo.position,
                procChainMask    = damageInfo.procChainMask,
                procCoefficient  = 1f
            };

            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/IceRingExplosion"), damageInfo.position, Vector3.up, true);
            characterBody.AddTimedBuff(BuffIndex.Slow80, 3f);
            victim.GetComponent <HealthComponent>()?.TakeDamage(damageInfo1);
        }
Example #21
0
        public override void OnEnter()
        {
            base.OnEnter();
            if (base.isAuthority)
            {
                //this.targetTracker = base.GetComponent<TargetTracker>();
                this.ownerPrefab = base.gameObject;
                CharacterBody   targetBody      = this.targetPrefab.GetComponent <CharacterBody>();
                CharacterBody   ownerBody       = this.ownerPrefab.GetComponent <CharacterBody>();
                GameObject      bodyPrefab      = BodyCatalog.FindBodyPrefab(targetBody);
                CharacterMaster characterMaster = MasterCatalog.allAiMasters.FirstOrDefault((CharacterMaster master) => master.bodyPrefab == bodyPrefab);
                this.masterSummon         = new MasterSummon();
                masterSummon.masterPrefab = characterMaster.gameObject;
                masterSummon.position     = ownerBody.footPosition;
                CharacterDirection component = ownerBody.GetComponent <CharacterDirection>();
                masterSummon.rotation           = (component ? Quaternion.Euler(0f, component.yaw, 0f) : ownerBody.transform.rotation);
                masterSummon.summonerBodyObject = (ownerBody ? ownerBody.gameObject : null);

                CharacterMaster characterMaster2 = masterSummon.Perform();

                GameObject       trackingTargetAsGO = this.targetTracker.GetTrackingTargetAsGO();
                RoR2.Console.Log log = new RoR2.Console.Log();
                if (trackingTargetAsGO != null)
                {
                    log.message = "REEE";
                    RoR2.Console.logs.Add(log);
                }
                else
                {
                    log.message = "YEET";
                    RoR2.Console.logs.Add(log);
                }
            }
        }
Example #22
0
        //private void GrantBaseShield(ILContext il)
        //{
        //    //Provided by Harb from their HarbCrate mod. Thanks Harb!
        //    ILCursor c = new ILCursor(il);
        //    int shieldsLoc = 33;
        //    c.GotoNext(
        //        MoveType.Before,
        //        x => x.MatchLdloc(out shieldsLoc),
        //        x => x.MatchCallvirt<CharacterBody>("set_maxShield")
        //    );
        //    c.Emit(OpCodes.Ldloc, shieldsLoc);
        //    c.EmitDelegate<Func<CharacterBody, float, float>>((self, shields) =>
        //    {
        //        var InventoryCount = GetCount(self);
        //        if (InventoryCount > 0)
        //        {
        //            shields += self.maxHealth * 0.04f;
        //        }
        //        return shields;
        //    });
        //    c.Emit(OpCodes.Stloc, shieldsLoc);
        //    c.Emit(OpCodes.Ldarg_0);
        //}

        private void ShieldedCoreValidator(On.RoR2.CharacterBody.orig_FixedUpdate orig, CharacterBody self)
        {
            orig(self);

            var shieldComponent = self.GetComponent <ShieldedCoreComponent>();

            if (!shieldComponent)
            {
                shieldComponent = self.gameObject.AddComponent <ShieldedCoreComponent>();
            }

            var newInventoryCount = GetCount(self);
            var IsShielded        = self.healthComponent.shield > 0 ? true : false;

            bool IsDifferent = false;

            if (shieldComponent.cachedInventoryCount != newInventoryCount)
            {
                IsDifferent = true;
                shieldComponent.cachedInventoryCount = newInventoryCount;
            }
            if (shieldComponent.cachedIsShielded != IsShielded)
            {
                IsDifferent = true;
                shieldComponent.cachedIsShielded = IsShielded;
            }

            if (!IsDifferent)
            {
                return;
            }

            self.statsDirty = true;
        }
Example #23
0
        private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, RecalculateStatsAPI.StatHookEventArgs args)
        {
            if (!sender || !sender.master)
            {
                return;
            }
            var cpt = sender.GetComponent <GoldenGunComponent>();

            if (cpt)
            {
                var icnt = GetCount(sender.master.inventory);
                if (icnt == 0)
                {
                    return;
                }
                var moneyFac = sender.master.money;
                if (inclDeploys)
                {
                    var dplc = sender.master.GetComponent <Deployable>();
                    if (dplc)
                    {
                        moneyFac += dplc.ownerMaster.money;
                    }
                }
                var moneyCoef = moneyFac / (Run.instance.GetDifficultyScaledCost(goldAmt) * Mathf.Pow(goldReduc, icnt - 1));
                args.damageMultAdd += Mathf.Lerp(0, damageBoost, moneyCoef);
            }
        }
        private void CharacterBody_OnClientBuffsChanged(On.RoR2.CharacterBody.orig_OnClientBuffsChanged orig, CharacterBody self)
        {
            orig(self);
            var component = self.GetComponent <MysticsItemsCoffeeBoostHelper>();

            if (!component)
            {
                component = self.gameObject.AddComponent <MysticsItemsCoffeeBoostHelper>();
            }
            var currentCount = self.GetBuffCount(buffDef);

            if (currentCount > component.oldCount)
            {
                Util.PlayAttackSpeedSound("Play_item_proc_coffee", self.gameObject, 1f + 0.2f * (float)(currentCount - 1));

                EffectData effectData = new EffectData
                {
                    origin   = self.corePosition,
                    scale    = self.radius,
                    rotation = Util.QuaternionSafeLookRotation(Vector3.forward)
                };
                effectData.SetHurtBoxReference(self.gameObject);
                EffectManager.SpawnEffect(Items.CoffeeBoostOnItemPickup.visualEffect, effectData, false);
            }
            component.oldCount = currentCount;
        }
        private void GenericPickupController_AttemptGrant(On.RoR2.GenericPickupController.orig_AttemptGrant orig, GenericPickupController self, CharacterBody body)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::AttemptGrant(RoR2.CharacterBody)' called on client");
                return;
            }
            if (!ArtifactEnabled)
            {
                return;
            }

            if (!body.masterObject)
            {
                return;
            }

            TeamComponent component = body.GetComponent <TeamComponent>();

            if (component)
            {
                Inventory inventory = body.inventory;
                if (inventory)
                {
                    PlayerCharacterMasterController isPlayer = body.masterObject.GetComponent <PlayerCharacterMasterController>();

                    self.consumed = true;
                    PickupDef            pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex);
                    DropInventoryOnDeath comp      = null;
                    if (!isPlayer && body.teamComponent.teamIndex != TeamIndex.Player)
                    {
                        comp = body.gameObject.GetComponent <DropInventoryOnDeath>();
                        if (!comp)
                        {
                            comp = body.gameObject.AddComponent <DropInventoryOnDeath>();
                        }
                    }
                    if (pickupDef.itemIndex != ItemIndex.None)
                    {
                        self.GrantItem(body, inventory);
                    }
                    if (pickupDef.coinValue != 0U)
                    {
                        self.GrantLunarCoin(body, pickupDef.coinValue);
                    }
                    if (isPlayer)
                    {
                        if (pickupDef.equipmentIndex != EquipmentIndex.None)
                        {
                            self.GrantEquipment(body, inventory);
                        }
                        if (pickupDef.artifactIndex != ArtifactIndex.None)
                        {
                            self.GrantArtifact(body, pickupDef.artifactIndex);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Loops through all the Options of the minion. The action has 4 useful parameters to use.
        /// The first parameter refers to the Option/Multiple itself. It is a GameObject.
        /// The second parameter refers to the OptionBehavior component in the Option/Multiple.
        /// The third parameter refers to the target of the Option/Multiple owner. It is also a GameObject.
        /// The last parameter refers to the direction from the option to the target. It is a normalized Vector3.
        /// </summary>
        /// <param name="optionOwner">The owner of the option.</param>
        /// <param name="actionToRun">An action to execute for each Option. The inputs are as follows:
        /// GameObject option, OptionBehavior behavior, GameObject target, Vector3 direction.</param>
        public void FireForAllOptions(CharacterBody optionOwner, Action <GameObject, OptionBehavior, GameObject, Vector3> actionToRun)
        {
            if (!optionOwner)
            {
                return;
            }
            OptionTracker optionTracker = optionOwner.GetComponent <OptionTracker>();

            if (!optionTracker)
            {
                return;
            }

            GameObject target       = null;
            GameObject masterObject = optionOwner.masterObject;

            if (masterObject)
            {
                BaseAI        ai         = masterObject.GetComponent <BaseAI>();
                BaseAI.Target mainTarget = ai.currentEnemy;
                if (mainTarget != null && mainTarget.gameObject)
                {
                    target = mainTarget.gameObject;
                }
            }

            foreach (GameObject option in optionTracker.existingOptions)
            {
                OptionBehavior behavior = option.GetComponent <OptionBehavior>();
                if (behavior)
                {
                    Vector3 direction;
                    if (target)
                    {
                        direction = (target.transform.position - option.transform.position).normalized;
                        if (includeModelInsideOrb)
                        {
                            behavior.target = target;
                            NetworkIdentity targetNetworkIdentity = target.GetComponent <NetworkIdentity>();
                            if (targetNetworkIdentity)
                            {
                                OptionSync(optionOwner, (networkIdentity, nullTracker) =>
                                {
                                    optionTracker.targetIds.Add(Tuple.Create(
                                                                    GameObjectType.Body, networkIdentity.netId,
                                                                    (short)behavior.numbering, targetNetworkIdentity.netId
                                                                    ));
                                }, false);
                            }
                        }
                    }
                    else
                    {
                        direction = optionOwner.inputBank.GetAimRay().direction.normalized;
                    }
                    actionToRun(option, behavior, target, direction);
                }
            }
        }
Example #27
0
        private void On_GEMOnHitEnemy(On.RoR2.GlobalEventManager.orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
        {
            orig(self, damageInfo, victim);
            if (!NetworkServer.active || !victim || !damageInfo.attacker || damageInfo.procCoefficient <= 0f)
            {
                return;
            }

            var vicb = victim.GetComponent <CharacterBody>();

            CharacterBody body = damageInfo.attacker.GetComponent <CharacterBody>();

            if (!body || !vicb || !vicb.healthComponent || !vicb.mainHurtBox || (bossImmunity && vicb.isBoss))
            {
                return;
            }

            CharacterMaster chrm = body.master;

            if (!chrm)
            {
                return;
            }

            int icnt = GetCount(body);

            if (icnt == 0)
            {
                return;
            }

            icnt--;
            float tProc = procChance;

            if (icnt > 0)
            {
                tProc += stackChance * icnt;
            }
            if (tProc > capChance)
            {
                tProc = capChance;
            }
            if (!Util.CheckRoll(tProc * damageInfo.procCoefficient, chrm))
            {
                return;
            }

            OrbManager.instance.AddOrb(new TeleSightOrb {
                attacker         = damageInfo.attacker,
                damageColorIndex = DamageColorIndex.WeakPoint,
                damageValue      = vicb.healthComponent.fullCombinedHealth + vicb.healthComponent.fullBarrier,
                isCrit           = true,
                origin           = body.corePosition,
                procChainMask    = damageInfo.procChainMask,
                procCoefficient  = 1f,
                target           = vicb.mainHurtBox,
                teamIndex        = body.GetComponent <TeamComponent>()?.teamIndex ?? TeamIndex.Neutral
            });
        }
Example #28
0
 public static bool CheckJammedStatus(CharacterBody body)
 {
     if (body.inventory)
     {
         return(body.inventory.GetItemCount(isJammedItem) > 0);
     }
     return(body.GetComponent <IsJammed>());
 }
 private void GrantBaseShield(CharacterBody sender, StatHookEventArgs args)
 {
     if (GetCount(sender) > 0)
     {
         HealthComponent healthC = sender.GetComponent <HealthComponent>();
         args.baseShieldAdd += healthC.fullHealth * baseGrantShieldMultiplier;
     }
 }
Example #30
0
 private static void CharacterBody_OnBuffFinalStackLost(On.RoR2.CharacterBody.orig_OnBuffFinalStackLost orig, CharacterBody self, BuffDef buffDef)
 {
     orig(self, buffDef);
     if (buffDef == DebrisShieldBarrierBuff.BuffDef)
     {
         self.GetComponent <TrackDebrisShield>()?.OnBuffLost();
     }
 }