private static void Init()
 {
     GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
     {
         CharacterMaster characterMaster = damageReport.attackerMaster;
         if (characterMaster)
         {
             if (characterMaster.minionOwnership.ownerMaster)
             {
                 characterMaster = characterMaster.minionOwnership.ownerMaster;
             }
             PlayerCharacterMasterController component = characterMaster.GetComponent <PlayerCharacterMasterController>();
             if (component && Util.CheckRoll(1f * component.lunarCoinChanceMultiplier, 0f, null))
             {
                 PickupDropletController.CreatePickupDroplet(PickupIndex.Find("LunarCoin.Coin0"), damageReport.victim.transform.position, Vector3.up * 10f);
                 component.lunarCoinChanceMultiplier *= 0.5f;
             }
         }
     };
 }
示例#2
0
        // Token: 0x060012B1 RID: 4785 RVA: 0x0005BB98 File Offset: 0x00059D98
        public void BlockedDamage(DamageInfo damageInfo, float actualDamageBlocked)
        {
            this.totalDamageBlocked += actualDamageBlocked;
            LightningOrb lightningOrb = new LightningOrb();

            lightningOrb.teamIndex        = this.teamComponent.teamIndex;
            lightningOrb.origin           = damageInfo.position;
            lightningOrb.damageValue      = actualDamageBlocked * this.blockLaserDamageCoefficient;
            lightningOrb.bouncesRemaining = 0;
            lightningOrb.attacker         = damageInfo.attacker;
            lightningOrb.procCoefficient  = this.blockLaserProcCoefficient;
            lightningOrb.lightningType    = LightningOrb.LightningType.PaladinBarrier;
            HurtBox hurtBox = lightningOrb.PickNextTarget(lightningOrb.origin);

            if (hurtBox)
            {
                lightningOrb.target = hurtBox;
                lightningOrb.isCrit = Util.CheckRoll(this.characterBody.crit, this.characterBody.master);
                OrbManager.instance.AddOrb(lightningOrb);
            }
        }
        // Token: 0x06000E5F RID: 3679 RVA: 0x00046EA4 File Offset: 0x000450A4
        private void OnKilled(DamageInfo damageInfo)
        {
            CharacterBody component = base.GetComponent <CharacterBody>();

            EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/CoinEmitter"), new EffectData
            {
                origin       = base.transform.position,
                genericFloat = this.goldReward,
                scale        = (component ? component.radius : 1f)
            }, true);
            if (damageInfo.attacker)
            {
                TeamComponent component2 = base.GetComponent <TeamComponent>();
                CharacterBody component3 = damageInfo.attacker.GetComponent <CharacterBody>();
                if (component3)
                {
                    CharacterMaster master     = component3.master;
                    TeamIndex       objectTeam = TeamComponent.GetObjectTeam(component3.gameObject);
                    TeamManager.instance.GiveTeamMoney(objectTeam, this.goldReward);
                    float num = 1f;
                    if (component2)
                    {
                        num = 1f + (TeamManager.instance.GetTeamLevel(component2.teamIndex) - 1f) * 0.3f;
                    }
                    ExperienceManager.instance.AwardExperience(base.transform.position, component3.GetComponent <CharacterBody>(), (ulong)((uint)(this.expReward * num)));
                }
                if (this.logUnlockableName != "" && Run.instance.selectedDifficulty > DifficultyIndex.Easy && Run.instance.CanUnlockableBeGrantedThisRun(this.logUnlockableName))
                {
                    CharacterBody component4 = base.GetComponent <CharacterBody>();
                    if (Util.CheckRoll((component4 && component4.isChampion) ? 3f : 1f, component3.master))
                    {
                        GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/LogPickup"), base.transform.position, UnityEngine.Random.rotation);
                        gameObject.GetComponentInChildren <UnlockPickup>().unlockableName = this.logUnlockableName;
                        gameObject.GetComponent <TeamFilter>().teamIndex = TeamIndex.Player;
                        NetworkServer.Spawn(gameObject);
                    }
                }
            }
        }
 // Token: 0x060014D8 RID: 5336 RVA: 0x00058D2C File Offset: 0x00056F2C
 public void SetOwner(GameObject newOwner)
 {
     this.ownerInputBank     = null;
     this.ownerCharacterBody = null;
     this.isCrit             = false;
     this.Networkowner       = newOwner;
     if (this.owner)
     {
         this.ownerInputBank     = this.owner.GetComponent <InputBankTest>();
         this.ownerCharacterBody = this.owner.GetComponent <CharacterBody>();
         ModelLocator component = this.owner.GetComponent <ModelLocator>();
         if (component)
         {
             Transform modelTransform = component.modelTransform;
             if (modelTransform)
             {
                 ChildLocator component2 = modelTransform.GetComponent <ChildLocator>();
                 if (component2)
                 {
                     this.targetTransform = component2.FindChild("Chest");
                     if (this.targetTransform)
                     {
                         base.transform.rotation = this.targetTransform.rotation;
                     }
                 }
             }
         }
         base.transform.position = this.owner.transform.position + Vector3.down * 20f;
         if (NetworkServer.active && this.ownerCharacterBody)
         {
             CharacterMaster master = this.ownerCharacterBody.master;
             if (master)
             {
                 this.isCrit = Util.CheckRoll(this.ownerCharacterBody.crit, master);
             }
         }
     }
 }
        // Token: 0x06000EFD RID: 3837 RVA: 0x00049C14 File Offset: 0x00047E14
        private void FireMissile()
        {
            EquipmentIndex equipmentIndex = this.equipmentIndex;
            GameObject     prefab;
            float          num;

            if (equipmentIndex == EquipmentIndex.AffixRed)
            {
                prefab = Resources.Load <GameObject>("Prefabs/Projectiles/RedAffixMissileProjectile");
                num    = 1f;
            }
            else
            {
                prefab = Resources.Load <GameObject>("Prefabs/Projectiles/MissileProjectile");
                num    = 3f;
            }
            bool    crit     = Util.CheckRoll(this.characterBody.crit, this.characterBody.master);
            Vector3 position = this.inputBank ? this.inputBank.aimOrigin : base.transform.position;
            Vector3 vector   = this.inputBank ? this.inputBank.aimDirection : base.transform.forward;
            Vector3 a        = Vector3.up + UnityEngine.Random.insideUnitSphere * 0.1f;

            ProjectileManager.instance.FireProjectile(prefab, position, Util.QuaternionSafeLookRotation(a + UnityEngine.Random.insideUnitSphere * 0f), base.gameObject, this.characterBody.damage * num, 200f, crit, DamageColorIndex.Item, null, -1f);
        }
示例#6
0
 // Token: 0x06000D9E RID: 3486 RVA: 0x00042FD4 File Offset: 0x000411D4
 private void Awake()
 {
     this.interactableSelection = this.GenerateDirectorCardWeightedSelection(this.interactableCategories);
     this.monsterSelection      = this.GenerateDirectorCardWeightedSelection(this.monsterCategories);
     if (NetworkServer.active && Util.CheckRoll(2f, 0f, null))
     {
         Debug.Log("Trying to find family selection...");
         WeightedSelection <ClassicStageInfo.MonsterFamily> weightedSelection = new WeightedSelection <ClassicStageInfo.MonsterFamily>(8);
         for (int i = 0; i < this.possibleMonsterFamilies.Length; i++)
         {
             if (this.possibleMonsterFamilies[i].minimumStageCompletion <= Run.instance.stageClearCount && this.possibleMonsterFamilies[i].maximumStageCompletion > Run.instance.stageClearCount)
             {
                 weightedSelection.AddChoice(this.possibleMonsterFamilies[i], this.possibleMonsterFamilies[i].selectionWeight);
             }
         }
         if (weightedSelection.Count > 0)
         {
             ClassicStageInfo.MonsterFamily monsterFamily = weightedSelection.Evaluate(UnityEngine.Random.value);
             this.monsterSelection = this.GenerateDirectorCardWeightedSelection(monsterFamily.monsterFamilyCategories);
             base.StartCoroutine("BroadcastFamilySelection", monsterFamily);
         }
     }
 }
 // Token: 0x06000FAF RID: 4015 RVA: 0x00044C08 File Offset: 0x00042E08
 public override void FixedUpdate()
 {
     base.FixedUpdate();
     if (NetworkServer.active)
     {
         if (base.fixedAge >= this.controller.fireDuration || !this.controller.ownerBody)
         {
             this.outer.SetNextState(new OrbitalLaserController.OrbitalLaserDecayState());
             return;
         }
         this.bulletAttackTimer -= Time.fixedDeltaTime;
         if (this.controller.ownerBody && this.bulletAttackTimer < 0f)
         {
             this.bulletAttackTimer += 1f / this.controller.fireFrequency;
             new BulletAttack
             {
                 owner              = this.controller.ownerBody.gameObject,
                 weapon             = base.gameObject,
                 origin             = base.transform.position + Vector3.up * 600f,
                 maxDistance        = 1200f,
                 aimVector          = Vector3.down,
                 minSpread          = 0f,
                 maxSpread          = 0f,
                 damage             = Mathf.Lerp(this.controller.damageCoefficientInitial, this.controller.damageCoefficientFinal, base.fixedAge / this.controller.fireDuration) * this.controller.ownerBody.damage / this.controller.fireFrequency,
                 force              = this.controller.force,
                 tracerEffectPrefab = this.controller.tracerEffectPrefab,
                 muzzleName         = "",
                 hitEffectPrefab    = this.controller.hitEffectPrefab,
                 isCrit             = Util.CheckRoll(this.controller.ownerBody.crit, this.controller.ownerBody.master),
                 stopperMask        = LayerIndex.world.mask,
                 damageColorIndex   = DamageColorIndex.Item,
                 procCoefficient    = this.controller.procCoefficient / this.controller.fireFrequency,
                 radius             = 2f
             }.Fire();
         }
     }
 }
示例#8
0
 private static void Init()
 {
     GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
     {
         GameObject attacker = damageReport.damageInfo.attacker;
         if (attacker)
         {
             CharacterBody component = attacker.GetComponent <CharacterBody>();
             if (component)
             {
                 GameObject masterObject = component.masterObject;
                 if (masterObject)
                 {
                     PlayerCharacterMasterController component2 = masterObject.GetComponent <PlayerCharacterMasterController>();
                     if (component2 && Util.CheckRoll(1f * component2.lunarCoinChanceMultiplier, 0f, null))
                     {
                         PickupDropletController.CreatePickupDroplet(PickupIndex.lunarCoin1, damageReport.victim.transform.position, Vector3.up * 10f);
                         component2.lunarCoinChanceMultiplier *= 0.5f;
                     }
                 }
             }
         }
     };
 }
示例#9
0
        // Token: 0x06000A02 RID: 2562 RVA: 0x0002BD0C File Offset: 0x00029F0C
        public void OnKilledServer(DamageReport damageReport)
        {
            CharacterBody attackerBody = damageReport.attackerBody;

            if (attackerBody)
            {
                Vector3 corePosition = this.characterBody.corePosition;
                TeamManager.instance.GiveTeamMoney(damageReport.attackerTeamIndex, this.goldReward);
                EffectManager.SpawnEffect(DeathRewards.coinEffectPrefab, new EffectData
                {
                    origin       = corePosition,
                    genericFloat = this.goldReward,
                    scale        = this.characterBody.radius
                }, true);
                float num = 1f + (this.characterBody.level - 1f) * 0.3f;
                ExperienceManager.instance.AwardExperience(corePosition, attackerBody, (ulong)((uint)(this.expReward * num)));
                if (this.logUnlockableName != "" && Run.instance.CanUnlockableBeGrantedThisRun(this.logUnlockableName) && Util.CheckRoll(this.characterBody.isChampion ? 3f : 1f, damageReport.attackerMaster))
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(DeathRewards.logbookPrefab, corePosition, UnityEngine.Random.rotation);
                    gameObject.GetComponentInChildren <UnlockPickup>().unlockableName = this.logUnlockableName;
                    gameObject.GetComponent <TeamFilter>().teamIndex = TeamIndex.Player;
                    NetworkServer.Spawn(gameObject);
                }
            }
        }
示例#10
0
 // Token: 0x06001C30 RID: 7216 RVA: 0x000837F7 File Offset: 0x000819F7
 public static bool CheckRoll(float percentChance, CharacterMaster master)
 {
     return(Util.CheckRoll(percentChance, master ? master.luck : 0f, master));
 }
示例#11
0
        private bool PerformEquipmentAction(EquipmentIndex equipmentIndex)
        {
            switch (equipmentIndex)
            {
            case EquipmentIndex.CommandMissile:
                remainingMissiles += 12;
                return(true);

            case EquipmentIndex.Saw:
            {
                Vector3 position = transform.position;
                Ray     ray      = new Ray
                {
                    direction = inputBank.aimDirection,
                    origin    = inputBank.aimOrigin
                };
                bool crit = Util.CheckRoll(characterBody.crit, characterBody.master);
                ProjectileManager.instance.FireProjectile(Resources.Load <GameObject>("Prefabs/Projectiles/Sawmerang"), ray.origin, Util.QuaternionSafeLookRotation(ray.direction), gameObject, characterBody.damage, 0f, crit, DamageColorIndex.Default, null, -1f);
                return(true);
            }

            case EquipmentIndex.Fruit:
                if (healthComponent)
                {
                    Util.PlaySound("Play_item_use_fruit", gameObject);
                    EffectData effectData = new EffectData();
                    effectData.origin = transform.position;
                    effectData.SetNetworkedObjectReference(gameObject);
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/FruitHealEffect"), effectData, true);
                    healthComponent.HealFraction(0.5f, default(ProcChainMask));
                    return(true);
                }
                return(true);

            case EquipmentIndex.Meteor:
            {
                MeteorStormController component = Instantiate(Resources.Load <GameObject>("Prefabs/NetworkedObjects/MeteorStorm"), characterBody.corePosition, Quaternion.identity).GetComponent <MeteorStormController>();
                component.owner       = gameObject;
                component.ownerDamage = characterBody.damage;
                component.isCrit      = Util.CheckRoll(characterBody.crit, characterBody.master);
                NetworkServer.Spawn(component.gameObject);
                return(true);
            }

            case EquipmentIndex.SoulJar:
                return(true);

            case EquipmentIndex.Blackhole:
            {
                Vector3 position2 = transform.position;
                Ray     ray2      = new Ray
                {
                    direction = inputBank.aimDirection,
                    origin    = inputBank.aimOrigin
                };
                ProjectileManager.instance.FireProjectile(Resources.Load <GameObject>("Prefabs/Projectiles/GravSphere"), position2, Util.QuaternionSafeLookRotation(ray2.direction), gameObject, 0f, 0f, false, DamageColorIndex.Default, null, -1f);
                return(true);
            }

            case EquipmentIndex.GhostGun:
            {
                GameObject gameObject = Instantiate(Resources.Load <GameObject>("Prefabs/NetworkedObjects/GhostGun"), transform.position, Quaternion.identity);
                gameObject.GetComponent <GhostGunController>().owner = this.gameObject;
                NetworkServer.Spawn(gameObject);
                return(true);
            }

            case EquipmentIndex.CritOnUse:
                characterBody.AddTimedBuff(BuffIndex.FullCrit, 8f);
                return(true);

            case EquipmentIndex.DroneBackup:
            {
                Util.PlaySound("Play_item_use_radio", gameObject);
                int   num  = 4;
                float num2 = 25f;
                if (NetworkServer.active)
                {
                    for (int i = 0; i < num; i++)
                    {
                        Vector2 vector    = Random.insideUnitCircle.normalized * 3f;
                        Vector3 position3 = transform.position + new Vector3(vector.x, 0f, vector.y);
                        SummonMaster(Resources.Load <GameObject>("Prefabs/CharacterMasters/DroneBackupMaster"), position3).gameObject.AddComponent <MasterSuicideOnTimer>().lifeTimer = num2 + Random.Range(0f, 3f);
                    }
                    return(true);
                }
                return(true);
            }

            case EquipmentIndex.OrbitalLaser:
            {
                Vector3    position4 = transform.position;
                RaycastHit raycastHit;
                if (Physics.Raycast(new Ray
                    {
                        direction = inputBank.aimDirection,
                        origin = inputBank.aimOrigin
                    }, out raycastHit, 900f, LayerIndex.world.mask | LayerIndex.defaultLayer.mask))
                {
                    position4 = raycastHit.point;
                }
                GameObject gameObject2 = (GameObject)Instantiate(Resources.Load("Prefabs/NetworkedObjects/OrbitalLaser"), position4, Quaternion.identity);
                gameObject2.GetComponent <OrbitalLaserController>().ownerBody = characterBody;
                NetworkServer.Spawn(gameObject2);
                return(true);
            }

            case EquipmentIndex.BFG:
                bfgChargeTimer   = 2f;
                subcooldownTimer = 2.2f;
                return(true);

            case EquipmentIndex.Enigma:
            {
                EquipmentIndex equipmentIndex2 = EquipmentCatalog.enigmaEquipmentList[Random.Range(0, EquipmentCatalog.enigmaEquipmentList.Count - 1)];
                PerformEquipmentAction(equipmentIndex2);
                return(true);
            }

            case EquipmentIndex.Jetpack:
            {
                JetpackController jetpackController = JetpackController.FindJetpackController(gameObject);
                if (!jetpackController)
                {
                    GameObject gameObject3 = Instantiate(Resources.Load <GameObject>("Prefabs/NetworkedObjects/JetpackController"));
                    jetpackController = gameObject3.GetComponent <JetpackController>();
                    jetpackController.NetworktargetObject = gameObject;
                    NetworkServer.Spawn(gameObject3);
                    return(true);
                }
                jetpackController.ResetTimer();
                return(true);
            }

            case EquipmentIndex.Lightning:
            {
                HurtBox hurtBox = currentTargetHurtBox;
                if (hurtBox)
                {
                    subcooldownTimer = 0.2f;
                    OrbManager.instance.AddOrb(new LightningStrikeOrb
                        {
                            attacker         = gameObject,
                            damageColorIndex = DamageColorIndex.Item,
                            damageValue      = characterBody.damage * 30f,
                            isCrit           = Util.CheckRoll(characterBody.crit, characterBody.master),
                            procChainMask    = default(ProcChainMask),
                            procCoefficient  = 1f,
                            target           = hurtBox
                        });
                    return(true);
                }
                return(false);
            }

            case EquipmentIndex.PassiveHealing:
                if (passiveHealingFollower)
                {
                    passiveHealingFollower.AssignNewTarget(currentTargetBodyObject);
                    return(true);
                }
                return(true);

            case EquipmentIndex.BurnNearby:
                if (characterBody)
                {
                    characterBody.AddHelfireDuration(8f);
                    return(true);
                }
                return(true);

            case EquipmentIndex.SoulCorruptor:
            {
                HurtBox hurtBox2 = currentTargetHurtBox;
                if (!hurtBox2)
                {
                    return(false);
                }
                if (!hurtBox2.healthComponent || hurtBox2.healthComponent.combinedHealthFraction > 0.25f)
                {
                    return(false);
                }
                Util.TryToCreateGhost(hurtBox2.healthComponent.body, characterBody, 30);
                hurtBox2.healthComponent.Suicide(gameObject);
                return(true);
            }

            case EquipmentIndex.Scanner:
                NetworkServer.Spawn(Instantiate(Resources.Load <GameObject>("Prefabs/NetworkedObjects/ChestScanner"), characterBody.corePosition, Quaternion.identity));
                return(true);

            case EquipmentIndex.CrippleWard:
                NetworkServer.Spawn(Instantiate(Resources.Load <GameObject>("Prefabs/NetworkedObjects/CrippleWard"), characterBody.corePosition, Quaternion.identity));
                // Don't drop it for now - can't pick back up (bug)
                // inventory.SetEquipmentIndex(EquipmentIndex.None);
                return(true);
            }
            return(false);
        }
        private bool PerformEquipmentAction(EquipmentIndex equipmentIndex)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Boolean RoR2.EquipmentSlot::PerformEquipmentAction(RoR2.EquipmentIndex)' called on client");
                return(false);
            }
            switch (equipmentIndex)
            {
            case EquipmentIndex.CommandMissile:
                this.remainingMissiles += 12;
                return(true);

            case EquipmentIndex.Saw:
            {
                Vector3 position = base.transform.position;
                Ray     aimRay   = this.GetAimRay();
                bool    crit     = Util.CheckRoll(this.characterBody.crit, this.characterBody.master);
                ProjectileManager.instance.FireProjectile(Resources.Load <GameObject>("Prefabs/Projectiles/Sawmerang"), aimRay.origin, Util.QuaternionSafeLookRotation(aimRay.direction), base.gameObject, this.characterBody.damage, 0f, crit, DamageColorIndex.Default, null, -1f);
                return(true);
            }

            case EquipmentIndex.Fruit:
                if (this.healthComponent)
                {
                    Util.PlaySound("Play_item_use_fruit", base.gameObject);
                    EffectData effectData = new EffectData();
                    effectData.origin = base.transform.position;
                    effectData.SetNetworkedObjectReference(base.gameObject);
                    EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/FruitHealEffect"), effectData, true);
                    this.healthComponent.HealFraction(0.5f, default(ProcChainMask));
                    return(true);
                }
                return(true);

            case EquipmentIndex.Meteor:
            {
                MeteorStormController component = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/MeteorStorm"), this.characterBody.corePosition, Quaternion.identity).GetComponent <MeteorStormController>();
                component.owner       = base.gameObject;
                component.ownerDamage = this.characterBody.damage;
                component.isCrit      = Util.CheckRoll(this.characterBody.crit, this.characterBody.master);
                NetworkServer.Spawn(component.gameObject);
                return(true);
            }

            case EquipmentIndex.SoulJar:
                return(true);

            case EquipmentIndex.Blackhole:
            {
                Vector3 position2 = base.transform.position;
                Ray     aimRay2   = this.GetAimRay();
                ProjectileManager.instance.FireProjectile(Resources.Load <GameObject>("Prefabs/Projectiles/GravSphere"), position2, Util.QuaternionSafeLookRotation(aimRay2.direction), base.gameObject, 0f, 0f, false, DamageColorIndex.Default, null, -1f);
                return(true);
            }

            case EquipmentIndex.GhostGun:
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/GhostGun"), base.transform.position, Quaternion.identity);
                gameObject.GetComponent <GhostGunController>().owner = base.gameObject;
                NetworkServer.Spawn(gameObject);
                return(true);
            }

            case EquipmentIndex.CritOnUse:
                this.characterBody.AddTimedBuff(BuffIndex.FullCrit, 8f);
                return(true);

            case EquipmentIndex.DroneBackup:
            {
                Util.PlaySound("Play_item_use_radio", base.gameObject);
                int   sliceCount = 4;
                float num        = 25f;
                if (NetworkServer.active)
                {
                    float y = Quaternion.LookRotation(this.GetAimRay().direction).eulerAngles.y;
                    float d = 3f;
                    foreach (float num2 in new DegreeSlices(sliceCount, 0.5f))
                    {
                        Quaternion      rotation        = Quaternion.Euler(0f, y + num2, 0f);
                        Quaternion      rotation2       = Quaternion.Euler(0f, y + num2 + 180f, 0f);
                        Vector3         position3       = base.transform.position + rotation * (Vector3.forward * d);
                        CharacterMaster characterMaster = this.SummonMaster(Resources.Load <GameObject>("Prefabs/CharacterMasters/DroneBackupMaster"), position3, rotation2);
                        if (characterMaster)
                        {
                            characterMaster.gameObject.AddComponent <MasterSuicideOnTimer>().lifeTimer = num + UnityEngine.Random.Range(0f, 3f);
                        }
                    }
                }
                this.subcooldownTimer = 0.5f;
                return(true);
            }

            case EquipmentIndex.OrbitalLaser:
            {
                Vector3    position4 = base.transform.position;
                RaycastHit raycastHit;
                if (Physics.Raycast(this.GetAimRay(), out raycastHit, 900f, LayerIndex.world.mask | LayerIndex.defaultLayer.mask))
                {
                    position4 = raycastHit.point;
                }
                GameObject gameObject2 = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("Prefabs/NetworkedObjects/OrbitalLaser"), position4, Quaternion.identity);
                gameObject2.GetComponent <OrbitalLaserController>().ownerBody = this.characterBody;
                NetworkServer.Spawn(gameObject2);
                return(true);
            }

            case EquipmentIndex.BFG:
                this.bfgChargeTimer   = 2f;
                this.subcooldownTimer = 2.2f;
                return(true);

            case EquipmentIndex.Enigma:
            {
                EquipmentIndex equipmentIndex2 = EquipmentCatalog.enigmaEquipmentList[UnityEngine.Random.Range(0, EquipmentCatalog.enigmaEquipmentList.Count - 1)];
                this.PerformEquipmentAction(equipmentIndex2);
                return(true);
            }

            case EquipmentIndex.Jetpack:
            {
                JetpackController jetpackController = JetpackController.FindJetpackController(base.gameObject);
                if (!jetpackController)
                {
                    GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/JetpackController"));
                    jetpackController = gameObject3.GetComponent <JetpackController>();
                    jetpackController.NetworktargetObject = base.gameObject;
                    NetworkServer.Spawn(gameObject3);
                    return(true);
                }
                jetpackController.ResetTimer();
                return(true);
            }

            case EquipmentIndex.Lightning:
            {
                this.UpdateTargets();
                HurtBox hurtBox = this.currentTargetHurtBox;
                if (hurtBox)
                {
                    this.subcooldownTimer = 0.2f;
                    OrbManager.instance.AddOrb(new LightningStrikeOrb
                        {
                            attacker         = base.gameObject,
                            damageColorIndex = DamageColorIndex.Item,
                            damageValue      = this.characterBody.damage * 30f,
                            isCrit           = Util.CheckRoll(this.characterBody.crit, this.characterBody.master),
                            procChainMask    = default(ProcChainMask),
                            procCoefficient  = 1f,
                            target           = hurtBox
                        });
                    this.InvalidateCurrentTarget();
                    return(true);
                }
                return(false);
            }

            case EquipmentIndex.PassiveHealing:
                if (this.passiveHealingFollower)
                {
                    this.UpdateTargets();
                    this.passiveHealingFollower.AssignNewTarget(this.currentTargetBodyObject);
                    this.InvalidateCurrentTarget();
                    return(true);
                }
                return(true);

            case EquipmentIndex.BurnNearby:
                if (this.characterBody)
                {
                    this.characterBody.AddHelfireDuration(8f);
                    return(true);
                }
                return(true);

            case EquipmentIndex.SoulCorruptor:
            {
                this.UpdateTargets();
                HurtBox hurtBox2 = this.currentTargetHurtBox;
                if (!hurtBox2)
                {
                    return(false);
                }
                if (!hurtBox2.healthComponent || hurtBox2.healthComponent.combinedHealthFraction > 0.25f)
                {
                    return(false);
                }
                Util.TryToCreateGhost(hurtBox2.healthComponent.body, this.characterBody, 30);
                hurtBox2.healthComponent.Suicide(base.gameObject, null, DamageType.Generic);
                this.InvalidateCurrentTarget();
                return(true);
            }

            case EquipmentIndex.Scanner:
                NetworkServer.Spawn(UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/ChestScanner"), this.characterBody.corePosition, Quaternion.identity));
                return(true);

            case EquipmentIndex.CrippleWard:
                NetworkServer.Spawn(UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/CrippleWard"), this.characterBody.corePosition, Quaternion.identity));
                this.inventory.SetEquipmentIndex(EquipmentIndex.None);
                return(true);

            case EquipmentIndex.Gateway:
                return(this.FireGateway());

            case EquipmentIndex.Tonic:
                this.characterBody.AddTimedBuff(BuffIndex.TonicBuff, EquipmentSlot.tonicBuffDuration);
                if (!Util.CheckRoll(80f, this.characterBody.master))
                {
                    this.characterBody.pendingTonicAfflictionCount++;
                    return(true);
                }
                return(true);

            case EquipmentIndex.QuestVolatileBattery:
                return(false);

            case EquipmentIndex.Cleanse:
            {
                Vector3    corePosition = this.characterBody.corePosition;
                EffectData effectData2  = new EffectData
                {
                    origin = corePosition
                };
                effectData2.SetHurtBoxReference(this.characterBody.mainHurtBox);
                EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/CleanseEffect"), effectData2, true);
                BuffIndex buffIndex = BuffIndex.Slow50;
                BuffIndex buffCount = (BuffIndex)BuffCatalog.buffCount;
                while (buffIndex < buffCount)
                {
                    if (BuffCatalog.GetBuffDef(buffIndex).isDebuff)
                    {
                        this.characterBody.ClearTimedBuffs(buffIndex);
                    }
                    buffIndex++;
                }
                DotController.RemoveAllDots(base.gameObject);
                SetStateOnHurt component2 = base.GetComponent <SetStateOnHurt>();
                if (component2)
                {
                    component2.Cleanse();
                }
                float     num3      = 6f;
                float     num4      = num3 * num3;
                TeamIndex teamIndex = this.teamComponent.teamIndex;
                List <ProjectileController> instancesList = InstanceTracker.GetInstancesList <ProjectileController>();
                List <ProjectileController> list          = new List <ProjectileController>();
                int i     = 0;
                int count = instancesList.Count;
                while (i < count)
                {
                    ProjectileController projectileController = instancesList[i];
                    if (projectileController.teamFilter.teamIndex != teamIndex && (projectileController.transform.position - corePosition).sqrMagnitude < num4)
                    {
                        list.Add(projectileController);
                    }
                    i++;
                }
                int j      = 0;
                int count2 = list.Count;
                while (j < count2)
                {
                    ProjectileController projectileController2 = list[j];
                    if (projectileController2)
                    {
                        UnityEngine.Object.Destroy(projectileController2.gameObject);
                    }
                    j++;
                }
                return(true);
            }

            case EquipmentIndex.FireBallDash:
            {
                Ray        aimRay3     = this.GetAimRay();
                GameObject gameObject4 = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/FireballVehicle"), aimRay3.origin, Quaternion.LookRotation(aimRay3.direction));
                gameObject4.GetComponent <VehicleSeat>().AssignPassenger(base.gameObject);
                CharacterBody characterBody = this.characterBody;
                NetworkUser   networkUser;
                if (characterBody == null)
                {
                    networkUser = null;
                }
                else
                {
                    CharacterMaster master = characterBody.master;
                    if (master == null)
                    {
                        networkUser = null;
                    }
                    else
                    {
                        PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController;
                        networkUser = ((playerCharacterMasterController != null) ? playerCharacterMasterController.networkUser : null);
                    }
                }
                NetworkUser networkUser2 = networkUser;
                if (networkUser2)
                {
                    NetworkServer.SpawnWithClientAuthority(gameObject4, networkUser2.gameObject);
                }
                else
                {
                    NetworkServer.Spawn(gameObject4);
                }
                this.subcooldownTimer = 2f;
                return(true);
            }

            case EquipmentIndex.GainArmor:
                this.characterBody.AddTimedBuff(BuffIndex.ElephantArmorBoost, 5f);
                return(true);
            }
            return(false);
        }
示例#13
0
        public void TakeDamage(DamageInfo damageInfo)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.HealthComponent::TakeDamage(RoR2.DamageInfo)' called on client");
                return;
            }
            if (!alive || godMode)
            {
                return;
            }
            CharacterBody characterBody = null;

            if (damageInfo.attacker)
            {
                characterBody = damageInfo.attacker.GetComponent <CharacterBody>();
            }
            BroadcastMessage("OnIncomingDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            var master = body.master;

            GetComponent <TeamComponent>();
            if (master && master.inventory)
            {
                var itemCount = master.inventory.GetItemCount((ItemIndex)1);
                if (itemCount > 0 && Util.CheckRoll((1f - 1f / (0.15f * itemCount + 1f)) * 100f, 0f, null))
                {
                    var effectData = new EffectData
                    {
                        origin   = damageInfo.position,
                        rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : Random.onUnitSphere)
                    };
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BearProc"), effectData, true);
                    damageInfo.rejected = true;
                }
            }
            if (body.HasBuff((BuffIndex)3))
            {
                damageInfo.rejected = true;
            }
            if (body.HasBuff((BuffIndex)23) && (!characterBody || !characterBody.HasBuff((BuffIndex)22)))
            {
                EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/DamageRejected"), new EffectData
                {
                    origin = damageInfo.position
                }, true);
                damageInfo.rejected = true;
            }
            if (damageInfo.rejected)
            {
                return;
            }
            var num = damageInfo.damage;

            if (characterBody)
            {
                var master2 = characterBody.master;
                if (master2 && master2.inventory)
                {
                    if (combinedHealth >= fullCombinedHealth * 0.9f)
                    {
                        var itemCount2 = master2.inventory.GetItemCount((ItemIndex)17);
                        if (itemCount2 > 0)
                        {
                            Util.PlaySound("Play_item_proc_crowbar", gameObject);
                            num *= 1.5f + 0.3f * (itemCount2 - 1);
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactCrowbar"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                    if (body.isBoss)
                    {
                        var itemCount3 = master2.inventory.GetItemCount((ItemIndex)61);
                        if (itemCount3 > 0)
                        {
                            num *= 1.2f + 0.1f * (itemCount3 - 1);
                            damageInfo.damageColorIndex = (DamageColorIndex)5;
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactBossDamageBonus"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                }
            }
            if (damageInfo.crit)
            {
                num *= 2f;
            }
            if ((damageInfo.damageType & DamageType.WeakPointHit) != 0)
            {
                num *= 1.5f;
                damageInfo.damageColorIndex = (DamageColorIndex)5;
            }
            if ((damageInfo.damageType & DamageType.BypassArmor) == 0)
            {
                var armor = body.armor;
                var num2  = armor >= 0f ? 1f - armor / (armor + 100f) : 2f - 100f / (100f - armor);
                num = Mathf.Max(1f, num * num2);
            }
            if ((damageInfo.damageType & DamageType.BarrierBlocked) != 0)
            {
                damageInfo.force *= 0.5f;
                var component = GetComponent <IBarrier>();
                component?.BlockedDamage(damageInfo, num);
                damageInfo.procCoefficient = 0f;
                num = 0f;
            }
            if (hasOneshotProtection)
            {
                num = Mathf.Min(num, fullCombinedHealth * 0.40f);                 // Make this more aggressive; 90% -> 40%
            }
            if ((damageInfo.damageType & DamageType.SlowOnHit) != 0)
            {
                body.AddTimedBuff(0, 2f);
            }
            if ((damageInfo.damageType & DamageType.ClayGoo) != 0 && (body.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) == 0)
            {
                body.AddTimedBuff((BuffIndex)21, 2f);
            }
            if (master && master.inventory)
            {
                var itemCount4 = master.inventory.GetItemCount((ItemIndex)44);
                if (itemCount4 > 0)
                {
                    var num3 = num / fullCombinedHealth;
                    var num4 = (uint)Mathf.Max(master.money * num3 * itemCount4, damageInfo.damage * itemCount4);
                    master.money = (uint)Mathf.Max(0f, master.money - num4);
                    EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damageInfo.position, Vector3.up, true);
                }
            }
            if ((damageInfo.damageType & DamageType.NonLethal) != 0)
            {
                num = Mathf.Max(Mathf.Min(num, health - 1f), 0f);
            }
            if (shield > 0f)
            {
                var num5 = Mathf.Min(num, shield);
                var num6 = num - num5;
                Networkshield = Mathf.Max(shield - num5, 0f);
                if (Mathf.Approximately(shield, 0f))
                {
                    var scale = 1f;
                    if (body)
                    {
                        scale = body.radius;
                    }
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShieldBreakEffect"), new EffectData
                    {
                        origin = transform.position,
                        scale  = scale
                    }, true);
                }
                if (num6 > 0f)
                {
                    Networkhealth = health - num6;
                }
            }
            else
            {
                Networkhealth = health - num;
            }
            TakeDamageForce(damageInfo, false);
            SendMessage("OnTakeDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            var damageReport = new DamageReport
            {
                victim     = this,
                damageInfo = damageInfo
            };

            damageReport.damageInfo.damage = num;
            if (num > 0f)
            {
                SendDamageDealt(damageReport);
            }
            UpdateLastHitTime(damageInfo.damage, damageInfo.position, (damageInfo.damageType & (DamageType)2048) > 0);
            if (damageInfo.attacker)
            {
                damageInfo.attacker.SendMessage("OnDamageDealt", damageReport, SendMessageOptions.DontRequireReceiver);
            }
            GlobalEventManager.ServerDamageDealt(damageReport);
            if (isInFrozenState && (body.bodyFlags & (CharacterBody.BodyFlags) 16) == 0 && combinedHealthFraction < 0.3f)
            {
                Networkhealth = -1f;
                EffectManager.instance.SpawnEffect(FrozenState.executeEffectPrefab, new EffectData
                {
                    origin = body.corePosition,
                    scale  = body ? body.radius : 1f
                }, true);
            }
            if (!alive)
            {
                BroadcastMessage("OnKilled", damageInfo, SendMessageOptions.DontRequireReceiver);
                if (damageInfo.attacker)
                {
                    damageInfo.attacker.SendMessage("OnKilledOther", damageReport, SendMessageOptions.DontRequireReceiver);
                }
                GlobalEventManager.instance.OnCharacterDeath(damageReport);
                return;
            }
            if (master && master.inventory)
            {
                var itemCount5 = master.inventory.GetItemCount((ItemIndex)25);
                if (itemCount5 > 0 && Util.CheckRoll(damageInfo.damage / fullCombinedHealth * 100f, master))
                {
                    body.AddTimedBuff((BuffIndex)7, 1.5f + itemCount5 * 1.5f);
                    body.AddTimedBuff((BuffIndex)8, 1.5f + itemCount5 * 1.5f);
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ProcStealthkit"), new EffectData
                    {
                        origin   = transform.position,
                        rotation = Quaternion.identity
                    }, true);
                }
            }
        }
        public void TakeDamage(DamageInfo damageInfo)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.HealthComponent::TakeDamage(RoR2.DamageInfo)' called on client");
                return;
            }
            if (!this.alive || this.godMode)
            {
                return;
            }
            CharacterBody characterBody = null;

            if (damageInfo.attacker)
            {
                characterBody = damageInfo.attacker.GetComponent <CharacterBody>();
            }
            base.BroadcastMessage("OnIncomingDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            CharacterMaster master = this.body.master;

            base.GetComponent <TeamComponent>();
            if (master && master.inventory)
            {
                int itemCount = master.inventory.GetItemCount(ItemIndex.Bear);
                if (itemCount > 0 && Util.CheckRoll((1f - 1f / (0.15f * (float)itemCount + 1f)) * 100f, 0f, null))
                {
                    EffectData effectData = new EffectData
                    {
                        origin   = damageInfo.position,
                        rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : UnityEngine.Random.onUnitSphere)
                    };
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/BearProc"), effectData, true);
                    damageInfo.rejected = true;
                }
            }
            if (this.body.HasBuff(BuffIndex.Immune) && (!characterBody || !characterBody.HasBuff(BuffIndex.GoldEmpowered)))
            {
                EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/DamageRejected"), new EffectData
                {
                    origin = damageInfo.position
                }, true);
                damageInfo.rejected = true;
            }
            if (damageInfo.rejected)
            {
                return;
            }
            float num = damageInfo.damage;

            if (characterBody)
            {
                CharacterMaster master2 = characterBody.master;
                if (master2 && master2.inventory)
                {
                    if (this.combinedHealth >= this.fullCombinedHealth * 0.9f)
                    {
                        int itemCount2 = master2.inventory.GetItemCount(ItemIndex.Crowbar);
                        if (itemCount2 > 0)
                        {
                            Util.PlaySound("Play_item_proc_crowbar", base.gameObject);
                            num *= 1.5f + 0.3f * (float)(itemCount2 - 1);
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactCrowbar"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                    if (this.body.isBoss)
                    {
                        int itemCount3 = master2.inventory.GetItemCount(ItemIndex.BossDamageBonus);
                        if (itemCount3 > 0)
                        {
                            num *= 1.2f + 0.1f * (float)(itemCount3 - 1);
                            damageInfo.damageColorIndex = DamageColorIndex.WeakPoint;
                            EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/ImpactBossDamageBonus"), damageInfo.position, -damageInfo.force, true);
                        }
                    }
                }
            }
            if (damageInfo.crit)
            {
                num *= 2f;
            }
            if ((damageInfo.damageType & DamageType.WeakPointHit) != DamageType.Generic)
            {
                num *= 1.5f;
                damageInfo.damageColorIndex = DamageColorIndex.WeakPoint;
            }
            if ((damageInfo.damageType & DamageType.BypassArmor) == DamageType.Generic)
            {
                float armor = this.body.armor;
                float num2  = (armor >= 0f) ? (1f - armor / (armor + 100f)) : (2f - 100f / (100f - armor));
                num = Mathf.Max(1f, num * num2);
            }
            if ((damageInfo.damageType & DamageType.BarrierBlocked) != DamageType.Generic)
            {
                damageInfo.force *= 0.5f;
                IBarrier component = base.GetComponent <IBarrier>();
                if (component != null)
                {
                    component.BlockedDamage(damageInfo, num);
                }
                damageInfo.procCoefficient = 0f;
                num = 0f;
            }
            if (this.hasOneshotProtection)
            {
                num = Mathf.Min(num, this.fullCombinedHealth * 0.9f);
            }
            if ((damageInfo.damageType & DamageType.SlowOnHit) != DamageType.Generic)
            {
                this.body.AddTimedBuff(BuffIndex.Slow50, 2f);
            }
            if ((damageInfo.damageType & DamageType.ClayGoo) != DamageType.Generic && (this.body.bodyFlags & CharacterBody.BodyFlags.ImmuneToGoo) == CharacterBody.BodyFlags.None)
            {
                this.body.AddTimedBuff(BuffIndex.ClayGoo, 2f);
            }
            if (master && master.inventory)
            {
                int itemCount4 = master.inventory.GetItemCount(ItemIndex.GoldOnHit);
                if (itemCount4 > 0)
                {
                    float num3 = num / this.fullCombinedHealth;
                    uint  num4 = (uint)Mathf.Max(master.money * num3 * (float)itemCount4, damageInfo.damage * (float)itemCount4);
                    master.money = (uint)Mathf.Max(0f, master.money - num4);
                    EffectManager.instance.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), damageInfo.position, Vector3.up, true);
                }
            }
            if ((damageInfo.damageType & DamageType.NonLethal) != DamageType.Generic)
            {
                num = Mathf.Max(Mathf.Min(num, this.health - 1f), 0f);
            }
            if (this.shield > 0f)
            {
                float num5 = Mathf.Min(num, this.shield);
                float num6 = num - num5;
                this.Networkshield = Mathf.Max(this.shield - num5, 0f);
                if (this.shield == 0f)
                {
                    float scale = 1f;
                    if (this.body)
                    {
                        scale = this.body.radius;
                    }
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShieldBreakEffect"), new EffectData
                    {
                        origin = base.transform.position,
                        scale  = scale
                    }, true);
                }
                if (num6 > 0f)
                {
                    this.Networkhealth = this.health - num6;
                }
            }
            else
            {
                this.Networkhealth = this.health - num;
            }
            this.TakeDamageForce(damageInfo, false);
            base.SendMessage("OnTakeDamage", damageInfo, SendMessageOptions.DontRequireReceiver);
            DamageReport damageReport = new DamageReport
            {
                victim     = this,
                damageInfo = damageInfo
            };

            damageReport.damageInfo.damage = num;
            if (num > 0f)
            {
                HealthComponent.SendDamageDealt(damageReport);
            }
            this.UpdateLastHitTime(damageInfo.damage, damageInfo.position, (damageInfo.damageType & DamageType.Silent) > DamageType.Generic);
            if (damageInfo.attacker)
            {
                damageInfo.attacker.SendMessage("OnDamageDealt", damageReport, SendMessageOptions.DontRequireReceiver);
            }
            GlobalEventManager.ServerDamageDealt(damageReport);
            if (this.isFrozen && this.combinedHealthFraction < 0.3f)
            {
                this.Networkhealth = 0f;
                EffectManager.instance.SpawnEffect(FrozenState.cullEffectPrefab, new EffectData
                {
                    origin = this.body.corePosition,
                    scale  = (this.body ? this.body.radius : 1f)
                }, true);
            }
            if (!this.alive)
            {
                base.BroadcastMessage("OnKilled", damageInfo, SendMessageOptions.DontRequireReceiver);
                if (damageInfo.attacker)
                {
                    damageInfo.attacker.SendMessage("OnKilledOther", damageReport, SendMessageOptions.DontRequireReceiver);
                }
                GlobalEventManager.instance.OnCharacterDeath(damageReport);
                return;
            }
            if (master && master.inventory)
            {
                int itemCount5 = master.inventory.GetItemCount(ItemIndex.Phasing);
                if (itemCount5 > 0 && Util.CheckRoll(damageInfo.damage / this.fullCombinedHealth * 100f, master))
                {
                    this.body.AddTimedBuff(BuffIndex.Cloak, 1.5f + (float)itemCount5 * 1.5f);
                    this.body.AddTimedBuff(BuffIndex.CloakSpeed, 1.5f + (float)itemCount5 * 1.5f);
                    EffectManager.instance.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ProcStealthkit"), new EffectData
                    {
                        origin   = base.transform.position,
                        rotation = Quaternion.identity
                    }, true);
                }
            }
        }
        // Token: 0x06001008 RID: 4104 RVA: 0x0004FE58 File Offset: 0x0004E058
        public float Heal(float amount, ProcChainMask procChainMask, bool nonRegen = true)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Single RoR2.HealthComponent::Heal(System.Single, RoR2.ProcChainMask, System.Boolean)' called on client");
                return(0f);
            }
            if (!this.alive || amount <= 0f)
            {
                return(0f);
            }
            float           num             = this.health;
            CharacterMaster characterMaster = null;
            Inventory       inventory       = null;
            bool            flag            = false;

            if (this.body)
            {
                if (this.body.HasBuff(BuffIndex.RepairMode))
                {
                    amount *= 3f;
                }
                characterMaster = this.body.master;
                if (characterMaster)
                {
                    inventory = characterMaster.inventory;
                    if (inventory && inventory.currentEquipmentIndex == EquipmentIndex.LunarPotion && !procChainMask.HasProc(ProcType.LunarPotionActivation))
                    {
                        this.potionReserve += amount;
                        return(amount);
                    }
                    if (nonRegen && !procChainMask.HasProc(ProcType.CritHeal) && Util.CheckRoll(this.body.critHeal, characterMaster))
                    {
                        procChainMask.AddProc(ProcType.CritHeal);
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                amount *= 2f;
            }
            if (this.increaseHealingCount > 0)
            {
                amount *= 1f + (float)this.increaseHealingCount;
            }
            if (nonRegen && this.repeatHealComponent && !procChainMask.HasProc(ProcType.RepeatHeal))
            {
                this.repeatHealComponent.healthFractionToRestorePerSecond = 0.1f / (float)this.repeatHealCount;
                this.repeatHealComponent.AddReserve(amount * (float)(1 + this.repeatHealCount), this.fullHealth);
                return(0f);
            }
            this.Networkhealth = Mathf.Min(this.health + amount, this.fullHealth);
            if (nonRegen)
            {
                HealthComponent.SendHeal(base.gameObject, amount, flag);
                if (inventory && !procChainMask.HasProc(ProcType.HealNova))
                {
                    int itemCount = inventory.GetItemCount(ItemIndex.NovaOnHeal);
                    if (itemCount > 0)
                    {
                        this.devilOrbHealPool = Mathf.Min(this.devilOrbHealPool + amount * (float)itemCount, this.fullCombinedHealth);
                    }
                }
            }
            if (flag)
            {
                GlobalEventManager.instance.OnCrit(this.body, characterMaster, amount / this.fullHealth * 10f, procChainMask);
            }
            if (nonRegen)
            {
                Action <HealthComponent, float> action = HealthComponent.onCharacterHealServer;
                if (action != null)
                {
                    action(this, amount);
                }
            }
            return(this.health - num);
        }
示例#16
0
        // Token: 0x060015FB RID: 5627 RVA: 0x0005E4CC File Offset: 0x0005C6CC
        private void FireMeatballs(Vector3 impactNormal, Vector3 impactPosition, Vector3 forward, int meatballCount, float meatballAngle, float meatballForce)
        {
            float   num        = 360f / (float)meatballCount;
            Vector3 normalized = Vector3.ProjectOnPlane(forward, impactNormal).normalized;
            Vector3 point      = Vector3.RotateTowards(impactNormal, normalized, meatballAngle * 0.017453292f, float.PositiveInfinity);

            for (int i = 0; i < meatballCount; i++)
            {
                Vector3 forward2 = Quaternion.AngleAxis(num * (float)i, impactNormal) * point;
                ProjectileManager.instance.FireProjectile(this.meatballProjectile, impactPosition, Util.QuaternionSafeLookRotation(forward2), base.gameObject, this.characterBody.damage * this.meatballDamageCoefficient, meatballForce, Util.CheckRoll(this.characterBody.crit, this.characterBody.master), DamageColorIndex.Default, null, -1f);
            }
        }
示例#17
0
        // Token: 0x060017C1 RID: 6081 RVA: 0x000711A0 File Offset: 0x0006F3A0
        private void FireMeatballs(Vector3 impactNormal, Vector3 impactPosition, Vector3 forward, int meatballCount, float meatballAngle, float meatballForce)
        {
            float   num        = 360f / (float)meatballCount;
            Vector3 normalized = Vector3.ProjectOnPlane(forward, impactNormal).normalized;
            Vector3 point      = Vector3.RotateTowards(impactNormal, normalized, meatballAngle * 0.017453292f, float.PositiveInfinity);

            for (int i = 0; i < meatballCount; i++)
            {
                Vector3 forward2 = Quaternion.AngleAxis(num * (float)i, impactNormal) * point;
                ProjectileManager.instance.FireProjectile(this.meatballProjectile, impactPosition, Util.QuaternionSafeLookRotation(forward2), base.gameObject, this.characterBody.damage * this.meatballDamageCoefficient, meatballForce, Util.CheckRoll(this.characterBody.crit, this.characterBody.master), DamageColorIndex.Default, null, -1f);
            }
            BlastAttack blastAttack = new BlastAttack();

            blastAttack.baseDamage      = this.characterBody.damage * this.blastAttackDamageCoefficient;
            blastAttack.procCoefficient = this.blastAttackProcCoefficient;
            blastAttack.baseForce       = this.blastAttackForce;
            blastAttack.bonusForce      = Vector3.up * this.blastAttackBonusVerticalForce;
            blastAttack.crit            = Util.CheckRoll(this.characterBody.crit, this.characterBody.master);
            blastAttack.radius          = this.blastAttackRadius;
            blastAttack.damageType      = DamageType.IgniteOnHit;
            blastAttack.falloffModel    = BlastAttack.FalloffModel.SweetSpot;
            blastAttack.attacker        = base.gameObject;
            blastAttack.teamIndex       = TeamComponent.GetObjectTeam(blastAttack.attacker);
            blastAttack.position        = impactPosition;
            blastAttack.Fire();
            if (NetworkServer.active)
            {
                EffectManager.instance.SpawnEffect(this.blastAttackEffect, new EffectData
                {
                    origin = impactPosition,
                    scale  = this.blastAttackRadius
                }, true);
            }
        }
 // Token: 0x06001014 RID: 4116 RVA: 0x00050B28 File Offset: 0x0004ED28
 public void FixedUpdate()
 {
     if (NetworkServer.active)
     {
         if (this.body)
         {
             this.regenAccumulator += this.body.regen * Time.fixedDeltaTime;
         }
         if (this.regenAccumulator > 1f)
         {
             float num = Mathf.Floor(this.regenAccumulator);
             this.regenAccumulator -= num;
             this.Heal(num, default(ProcChainMask), false);
         }
         if (this.alive && this.regenAccumulator < -1f)
         {
             float num2 = Mathf.Ceil(this.regenAccumulator);
             this.regenAccumulator -= num2;
             this.Networkhealth     = this.health + num2;
             if (this.health <= 0f)
             {
                 this.Suicide(null);
             }
         }
         bool flag = this.shield == this.body.maxShield;
         if (this.body.outOfDanger)
         {
             this.Networkshield = this.shield + this.body.maxShield * 0.5f * Time.fixedDeltaTime;
         }
         this.Networkshield = Mathf.Min(this.shield, this.body.maxShield);
         if (this.shield == this.body.maxShield && !flag)
         {
             Util.PlaySound("Play_item_proc_personal_shield_end", base.gameObject);
         }
         if (this.devilOrbHealPool > 0f)
         {
             this.devilOrbTimer -= Time.fixedDeltaTime;
             if (this.devilOrbTimer <= 0f)
             {
                 this.devilOrbTimer += 0.1f;
                 float scale = 1f;
                 float num3  = this.fullCombinedHealth / 10f;
                 float num4  = 2.5f;
                 this.devilOrbHealPool -= num3;
                 DevilOrb devilOrb = new DevilOrb();
                 devilOrb.origin           = this.body.aimOriginTransform.position;
                 devilOrb.damageValue      = num3 * num4;
                 devilOrb.teamIndex        = TeamComponent.GetObjectTeam(base.gameObject);
                 devilOrb.attacker         = base.gameObject;
                 devilOrb.damageColorIndex = DamageColorIndex.Poison;
                 devilOrb.scale            = scale;
                 devilOrb.procChainMask.AddProc(ProcType.HealNova);
                 HurtBox hurtBox = devilOrb.PickNextTarget(devilOrb.origin, 40f);
                 if (hurtBox)
                 {
                     devilOrb.target = hurtBox;
                     devilOrb.isCrit = Util.CheckRoll(this.body.crit, this.body.master);
                     OrbManager.instance.AddOrb(devilOrb);
                 }
             }
         }
     }
     if (this.combatHealthbarTransform)
     {
         this.combatHealthTimer -= Time.fixedDeltaTime;
         if (this.combatHealthTimer <= 0f || !this.alive || this.body.HasBuff(BuffIndex.Cloak))
         {
             this.combatHealthTimer = 0f;
             UnityEngine.Object.Destroy(this.combatHealthbarTransform.gameObject);
         }
     }
     if (!this.alive && this.wasAlive)
     {
         this.wasAlive = false;
         base.BroadcastMessage("OnDeath", null, SendMessageOptions.DontRequireReceiver);
     }
 }
 // Token: 0x06000A98 RID: 2712 RVA: 0x0002E380 File Offset: 0x0002C580
 private void FixedUpdate()
 {
     this.UpdateInventory();
     if (NetworkServer.active)
     {
         this.subcooldownTimer -= Time.fixedDeltaTime;
         if (this.missileTimer > 0f)
         {
             this.missileTimer = Mathf.Max(this.missileTimer - Time.fixedDeltaTime, 0f);
         }
         if (this.missileTimer == 0f && this.remainingMissiles > 0)
         {
             this.remainingMissiles--;
             this.missileTimer = 0.125f;
             this.FireMissile();
         }
         this.UpdateGoldGat();
         if (this.bfgChargeTimer > 0f)
         {
             this.bfgChargeTimer -= Time.fixedDeltaTime;
             if (this.bfgChargeTimer < 0f)
             {
                 Vector3   position  = base.transform.position;
                 Ray       aimRay    = this.GetAimRay();
                 Transform transform = this.FindActiveEquipmentDisplay();
                 if (transform)
                 {
                     ChildLocator componentInChildren = transform.GetComponentInChildren <ChildLocator>();
                     if (componentInChildren)
                     {
                         Transform transform2 = componentInChildren.FindChild("Muzzle");
                         if (transform2)
                         {
                             aimRay.origin = transform2.position;
                         }
                     }
                 }
                 this.healthComponent.TakeDamageForce(aimRay.direction * -1500f, true, false);
                 ProjectileManager.instance.FireProjectile(Resources.Load <GameObject>("Prefabs/Projectiles/BeamSphere"), aimRay.origin, Util.QuaternionSafeLookRotation(aimRay.direction), base.gameObject, this.characterBody.damage * 2f, 0f, Util.CheckRoll(this.characterBody.crit, this.characterBody.master), DamageColorIndex.Item, null, -1f);
                 this.bfgChargeTimer = 0f;
             }
         }
         if (this.equipmentIndex == EquipmentIndex.PassiveHealing != this.passiveHealingFollower)
         {
             if (this.equipmentIndex == EquipmentIndex.PassiveHealing)
             {
                 GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/HealingFollower"), base.transform.position, Quaternion.identity);
                 this.passiveHealingFollower = gameObject.GetComponent <HealingFollowerController>();
                 this.passiveHealingFollower.NetworkownerBodyObject = base.gameObject;
                 NetworkServer.Spawn(gameObject);
             }
             else
             {
                 UnityEngine.Object.Destroy(this.passiveHealingFollower.gameObject);
                 this.passiveHealingFollower = null;
             }
         }
     }
     if (!this.inputBank.activateEquipment.justPressed)
     {
         Inventory inventory = this.inventory;
         if (((inventory != null) ? inventory.GetItemCount(ItemIndex.AutoCastEquipment) : 0) <= 0)
         {
             return;
         }
     }
     if (this.hasEffectiveAuthority)
     {
         if (NetworkServer.active)
         {
             this.ExecuteIfReady();
             return;
         }
         this.CallCmdExecuteIfReady();
     }
 }
示例#20
0
        // Token: 0x060012A6 RID: 4774 RVA: 0x0005B464 File Offset: 0x00059664
        private void FixedUpdate()
        {
            this.stopwatch += Time.fixedDeltaTime;
            float maxSpeed = this.chargeMaxVelocity;

            switch (this.orbitalLaserState)
            {
            case OrbitalLaserController.OrbitalLaserState.Charging:
                maxSpeed = this.chargeMaxVelocity;
                if (this.stopwatch >= this.chargeDuration)
                {
                    this.orbitalLaserState = OrbitalLaserController.OrbitalLaserState.Firing;
                    this.stopwatch         = 0f;
                    this.chargeEffect.SetActive(false);
                    this.fireEffect.SetActive(true);
                }
                break;

            case OrbitalLaserController.OrbitalLaserState.Firing:
                maxSpeed = this.fireMaxVelocity;
                this.bulletAttackTimer -= Time.fixedDeltaTime;
                if (this.ownerBody && this.bulletAttackTimer < 0f)
                {
                    this.bulletAttackTimer += 1f / this.fireFrequency;
                    new BulletAttack
                    {
                        owner              = this.ownerBody.gameObject,
                        origin             = base.transform.position + Vector3.up * 600f,
                        maxDistance        = 1200f,
                        aimVector          = Vector3.down,
                        minSpread          = 0f,
                        maxSpread          = 0f,
                        damage             = Mathf.Lerp(this.damageCoefficientInitial, this.damageCoefficientFinal, this.stopwatch / this.fireDuration) * this.ownerBody.damage / this.fireFrequency,
                        force              = this.force,
                        tracerEffectPrefab = this.tracerEffectPrefab,
                        muzzleName         = "",
                        hitEffectPrefab    = this.hitEffectPrefab,
                        isCrit             = Util.CheckRoll(this.ownerBody.crit, this.ownerBody.master),
                        stopperMask        = LayerIndex.world.mask,
                        damageColorIndex   = DamageColorIndex.Item,
                        procCoefficient    = this.procCoefficient / this.fireFrequency,
                        radius             = 2f
                    }.Fire();
                }
                if (this.stopwatch >= this.fireDuration || !this.ownerBody)
                {
                    this.orbitalLaserState = OrbitalLaserController.OrbitalLaserState.Decaying;
                    this.stopwatch         = 0f;
                    this.fireEffect.SetActive(false);
                }
                break;

            case OrbitalLaserController.OrbitalLaserState.Decaying:
                maxSpeed = 0f;
                if (this.stopwatch >= this.decayDuration)
                {
                    UnityEngine.Object.Destroy(base.gameObject);
                }
                break;
            }
            Vector3 target = base.transform.position;

            if (this.ownerBody)
            {
                this.ownerInputBank = this.ownerBody.GetComponent <InputBankTest>();
                RaycastHit raycastHit;
                if (Physics.Raycast(new Ray
                {
                    direction = this.ownerInputBank.aimDirection,
                    origin = this.ownerInputBank.aimOrigin
                }, out raycastHit, 900f, LayerIndex.world.mask | LayerIndex.defaultLayer.mask))
                {
                    target = raycastHit.point;
                }
                base.transform.position = Vector3.SmoothDamp(base.transform.position, target, ref this.refVelocity, this.smoothDampTime, maxSpeed);
            }
        }