private static void HandleSendJumpInputActive(NetworkMessage netMsg)
        {
            netMsg.ReadMessage <JetpackController.SetJetpackJumpStateMessage>(JetpackController.stateMessageBuffer);
            GameObject jetpackControllerObject = JetpackController.stateMessageBuffer.jetpackControllerObject;

            if (jetpackControllerObject == null)
            {
                return;
            }
            JetpackController component = jetpackControllerObject.GetComponent <JetpackController>();

            if (component == null)
            {
                return;
            }
            component.SetJumpInputActive(JetpackController.stateMessageBuffer.state);
        }
Exemple #2
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);
        }