private void AddDot(GameObject attackerObject, float duration, DotController.DotIndex dotIndex, float damageMultiplier)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.DotController::AddDot(UnityEngine.GameObject,System.Single,RoR2.DotController/DotIndex,System.Single)' called on client");
                return;
            }
            if (dotIndex < DotController.DotIndex.Bleed || dotIndex >= DotController.DotIndex.Count)
            {
                return;
            }
            TeamIndex     teamIndex = TeamIndex.Neutral;
            float         num       = 0f;
            TeamComponent component = attackerObject.GetComponent <TeamComponent>();

            if (component)
            {
                teamIndex = component.teamIndex;
            }
            CharacterBody component2 = attackerObject.GetComponent <CharacterBody>();

            if (component2)
            {
                num = component2.damage;
            }
            DotController.DotDef   dotDef   = DotController.dotDefs[(int)dotIndex];
            DotController.DotStack dotStack = new DotController.DotStack
            {
                dotIndex       = dotIndex,
                dotDef         = dotDef,
                attackerObject = attackerObject,
                attackerTeam   = teamIndex,
                timer          = duration,
                damage         = dotDef.damageCoefficient * num * damageMultiplier,
                damageType     = DamageType.Generic
            };
            switch (dotIndex)
            {
            case DotController.DotIndex.Helfire:
            {
                if (!component2)
                {
                    return;
                }
                HealthComponent healthComponent = component2.healthComponent;
                if (!healthComponent)
                {
                    return;
                }
                dotStack.damage = healthComponent.fullHealth * 0.01f * damageMultiplier;
                if (this.victimObject == attackerObject)
                {
                    dotStack.damageType |= (DamageType.NonLethal | DamageType.Silent);
                }
                else if (this.victimTeam == teamIndex)
                {
                    dotStack.damage *= 0.5f;
                }
                else
                {
                    dotStack.damage *= 24f;
                }
                int i     = 0;
                int count = this.dotStackList.Count;
                while (i < count)
                {
                    if (this.dotStackList[i].dotIndex == DotController.DotIndex.Helfire && this.dotStackList[i].attackerObject == attackerObject)
                    {
                        this.dotStackList[i].timer  = Mathf.Max(this.dotStackList[i].timer, duration);
                        this.dotStackList[i].damage = dotStack.damage;
                        return;
                    }
                    i++;
                }
                if (this.victimBody)
                {
                    EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/HelfireIgniteEffect"), new EffectData
                        {
                            origin = this.victimBody.corePosition
                        }, true);
                }
                break;
            }

            case DotController.DotIndex.PercentBurn:
                dotStack.damage = Mathf.Min(dotStack.damage, this.victimBody.healthComponent.fullCombinedHealth * 0.01f);
                break;

            case DotController.DotIndex.Poison:
            {
                float a = this.victimHealthComponent.fullCombinedHealth / 100f * 1f * dotDef.interval;
                dotStack.damage     = Mathf.Min(Mathf.Max(a, dotStack.damage), dotStack.damage * 50f);
                dotStack.damageType = DamageType.NonLethal;
                int j      = 0;
                int count2 = this.dotStackList.Count;
                while (j < count2)
                {
                    if (this.dotStackList[j].dotIndex == DotController.DotIndex.Poison)
                    {
                        this.dotStackList[j].timer  = Mathf.Max(this.dotStackList[j].timer, duration);
                        this.dotStackList[j].damage = dotStack.damage;
                        return;
                    }
                    j++;
                }
                bool flag = false;
                for (int k = 0; k < this.dotStackList.Count; k++)
                {
                    if (this.dotStackList[k].dotIndex == DotController.DotIndex.Poison)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag && component2 != null)
                {
                    CharacterMaster master = component2.master;
                    if (master != null)
                    {
                        PlayerStatsComponent playerStatsComponent = master.playerStatsComponent;
                        if (playerStatsComponent != null)
                        {
                            playerStatsComponent.currentStats.PushStatValue(StatDef.totalCrocoInfectionsInflicted, 1UL);
                        }
                    }
                }
                break;
            }
            }
            this.dotStackList.Add(dotStack);
            this.OnDotStackAddedServer(dotStack);
        }
Beispiel #2
0
        // Token: 0x06000426 RID: 1062 RVA: 0x00010B54 File Offset: 0x0000ED54
        public bool DefaultHitCallback(ref BulletAttack.BulletHit hitInfo)
        {
            bool result = false;

            if (hitInfo.collider)
            {
                result = ((1 << hitInfo.collider.gameObject.layer & this.stopperMask) == 0);
            }
            if (this.hitEffectPrefab)
            {
                EffectManager.SimpleImpactEffect(this.hitEffectPrefab, hitInfo.point, this.HitEffectNormal ? hitInfo.surfaceNormal : (-hitInfo.direction), true);
            }
            if (hitInfo.collider)
            {
                SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(hitInfo.collider, hitInfo.point);
                if (objectSurfaceDef && objectSurfaceDef.impactEffectPrefab)
                {
                    EffectData effectData = new EffectData
                    {
                        origin          = hitInfo.point,
                        rotation        = Quaternion.LookRotation(hitInfo.surfaceNormal),
                        color           = objectSurfaceDef.approximateColor,
                        surfaceDefIndex = objectSurfaceDef.surfaceDefIndex
                    };
                    EffectManager.SpawnEffect(objectSurfaceDef.impactEffectPrefab, effectData, true);
                }
            }
            if (this.isCrit)
            {
                EffectManager.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/Critspark"), hitInfo.point, this.HitEffectNormal ? hitInfo.surfaceNormal : (-hitInfo.direction), true);
            }
            GameObject entityObject = hitInfo.entityObject;

            if (entityObject)
            {
                float num = 1f;
                switch (this.falloffModel)
                {
                case BulletAttack.FalloffModel.None:
                    num = 1f;
                    break;

                case BulletAttack.FalloffModel.DefaultBullet:
                    num = 0.5f + Mathf.Clamp01(Mathf.InverseLerp(60f, 25f, hitInfo.distance)) * 0.5f;
                    break;

                case BulletAttack.FalloffModel.Buckshot:
                    num = 0.25f + Mathf.Clamp01(Mathf.InverseLerp(25f, 7f, hitInfo.distance)) * 0.75f;
                    break;
                }
                DamageInfo damageInfo = new DamageInfo();
                damageInfo.damage           = this.damage * num;
                damageInfo.crit             = this.isCrit;
                damageInfo.attacker         = this.owner;
                damageInfo.inflictor        = this.weapon;
                damageInfo.position         = hitInfo.point;
                damageInfo.force            = hitInfo.direction * (this.force * num);
                damageInfo.procChainMask    = this.procChainMask;
                damageInfo.procCoefficient  = this.procCoefficient;
                damageInfo.damageType       = this.damageType;
                damageInfo.damageColorIndex = this.damageColorIndex;
                damageInfo.ModifyDamageInfo(hitInfo.damageModifier);
                TeamIndex teamIndex = TeamIndex.Neutral;
                if (this.owner)
                {
                    TeamComponent component = this.owner.GetComponent <TeamComponent>();
                    if (component)
                    {
                        teamIndex = component.teamIndex;
                    }
                }
                TeamIndex     teamIndex2 = TeamIndex.Neutral;
                TeamComponent component2 = hitInfo.entityObject.GetComponent <TeamComponent>();
                if (component2)
                {
                    teamIndex2 = component2.teamIndex;
                }
                bool            flag            = teamIndex == teamIndex2;
                HealthComponent healthComponent = null;
                if (!flag)
                {
                    healthComponent = entityObject.GetComponent <HealthComponent>();
                }
                if (NetworkServer.active)
                {
                    if (healthComponent)
                    {
                        healthComponent.TakeDamage(damageInfo);
                        GlobalEventManager.instance.OnHitEnemy(damageInfo, hitInfo.entityObject);
                    }
                    GlobalEventManager.instance.OnHitAll(damageInfo, hitInfo.entityObject);
                }
                else if (ClientScene.ready)
                {
                    BulletAttack.messageWriter.StartMessage(53);
                    BulletAttack.messageWriter.Write(entityObject);
                    BulletAttack.messageWriter.Write(damageInfo);
                    BulletAttack.messageWriter.Write(healthComponent != null);
                    BulletAttack.messageWriter.FinishMessage();
                    ClientScene.readyConnection.SendWriter(BulletAttack.messageWriter, QosChannelIndex.defaultReliable.intVal);
                }
            }
            return(result);
        }
        // Token: 0x060017D7 RID: 6103 RVA: 0x00067824 File Offset: 0x00065A24
        private void ProcessHits(List <OverlapAttack.OverlapInfo> hitList)
        {
            if (hitList.Count == 0)
            {
                return;
            }
            Vector3 vector = Vector3.zero;
            float   d      = 1f / (float)hitList.Count;

            for (int i = 0; i < hitList.Count; i++)
            {
                OverlapAttack.OverlapInfo overlapInfo = hitList[i];
                if (this.hitEffectPrefab)
                {
                    Vector3 forward = -hitList[i].pushDirection;
                    EffectManager.SpawnEffect(this.hitEffectPrefab, new EffectData
                    {
                        origin   = overlapInfo.hitPosition,
                        rotation = Util.QuaternionSafeLookRotation(forward),
                        networkSoundEventIndex = this.impactSound
                    }, true);
                }
                vector += overlapInfo.hitPosition * d;
                SurfaceDefProvider component = hitList[i].hurtBox.GetComponent <SurfaceDefProvider>();
                if (component && component.surfaceDef)
                {
                    SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(hitList[i].hurtBox.collider, hitList[i].hitPosition);
                    if (objectSurfaceDef)
                    {
                        if (objectSurfaceDef.impactEffectPrefab)
                        {
                            EffectManager.SpawnEffect(objectSurfaceDef.impactEffectPrefab, new EffectData
                            {
                                origin   = overlapInfo.hitPosition,
                                rotation = ((overlapInfo.pushDirection == Vector3.zero) ? Quaternion.identity : Util.QuaternionSafeLookRotation(overlapInfo.pushDirection)),
                                color    = objectSurfaceDef.approximateColor,
                                scale    = 2f
                            }, true);
                        }
                        if (objectSurfaceDef.impactSoundString != null && objectSurfaceDef.impactSoundString.Length != 0)
                        {
                            Util.PlaySound(objectSurfaceDef.impactSoundString, hitList[i].hurtBox.gameObject);
                        }
                    }
                }
            }
            this.lastFireAverageHitPosition = vector;
            if (NetworkServer.active)
            {
                OverlapAttack.PerformDamage(this.attacker, this.inflictor, this.damage, this.isCrit, this.procChainMask, this.procCoefficient, this.damageColorIndex, this.damageType, this.forceVector, this.pushAwayForce, hitList);
                return;
            }
            OverlapAttack.outgoingMessage.attacker         = this.attacker;
            OverlapAttack.outgoingMessage.inflictor        = this.inflictor;
            OverlapAttack.outgoingMessage.damage           = this.damage;
            OverlapAttack.outgoingMessage.isCrit           = this.isCrit;
            OverlapAttack.outgoingMessage.procChainMask    = this.procChainMask;
            OverlapAttack.outgoingMessage.procCoefficient  = this.procCoefficient;
            OverlapAttack.outgoingMessage.damageColorIndex = this.damageColorIndex;
            OverlapAttack.outgoingMessage.damageType       = this.damageType;
            OverlapAttack.outgoingMessage.forceVector      = this.forceVector;
            OverlapAttack.outgoingMessage.pushAwayForce    = this.pushAwayForce;
            Util.CopyList <OverlapAttack.OverlapInfo>(hitList, OverlapAttack.outgoingMessage.overlapInfoList);
            GameNetworkManager.singleton.client.connection.SendByChannel(71, OverlapAttack.outgoingMessage, QosChannelIndex.defaultReliable.intVal);
        }
        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);
        }
Beispiel #5
0
        // Token: 0x0600042F RID: 1071 RVA: 0x000113A0 File Offset: 0x0000F5A0
        private void FireSingle(Vector3 normal, int muzzleIndex)
        {
            float   num    = this.maxDistance;
            Vector3 vector = this.origin + normal * this.maxDistance;
            List <BulletAttack.BulletHit> list = new List <BulletAttack.BulletHit>();
            bool flag  = this.radius == 0f || this.smartCollision;
            bool flag2 = this.radius != 0f;
            HashSet <GameObject> hashSet = null;

            if (this.smartCollision)
            {
                hashSet = new HashSet <GameObject>();
            }
            if (flag)
            {
                RaycastHit[] array = Physics.RaycastAll(this.origin, normal, num, this.hitMask, this.queryTriggerInteraction);
                for (int i = 0; i < array.Length; i++)
                {
                    BulletAttack.BulletHit bulletHit = default(BulletAttack.BulletHit);
                    this.InitBulletHitFromRaycastHit(ref bulletHit, this.origin, normal, ref array[i]);
                    list.Add(bulletHit);
                    if (this.smartCollision)
                    {
                        hashSet.Add(bulletHit.entityObject);
                    }
                    if (bulletHit.distance < num)
                    {
                        num = bulletHit.distance;
                    }
                }
            }
            if (flag2)
            {
                LayerMask mask = this.hitMask;
                if (this.smartCollision)
                {
                    mask &= ~LayerIndex.world.mask;
                }
                RaycastHit[] array2 = Physics.SphereCastAll(this.origin, this.radius, normal, num, mask, this.queryTriggerInteraction);
                for (int j = 0; j < array2.Length; j++)
                {
                    BulletAttack.BulletHit bulletHit2 = default(BulletAttack.BulletHit);
                    this.InitBulletHitFromRaycastHit(ref bulletHit2, this.origin, normal, ref array2[j]);
                    if (!this.smartCollision || !hashSet.Contains(bulletHit2.entityObject))
                    {
                        list.Add(bulletHit2);
                    }
                }
            }
            this.ProcessHitList(list, ref vector, new List <GameObject>());
            if (this.tracerEffectPrefab)
            {
                EffectData effectData = new EffectData
                {
                    origin = vector,
                    start  = this.origin
                };
                effectData.SetChildLocatorTransformReference(this.weapon, muzzleIndex);
                EffectManager.SpawnEffect(this.tracerEffectPrefab, effectData, true);
            }
        }
Beispiel #6
0
 // Token: 0x0600055D RID: 1373 RVA: 0x00015BE3 File Offset: 0x00013DE3
 public static void SpawnEffect(GameObject effectPrefab, EffectData effectData, bool transmit)
 {
     EffectManager.SpawnEffect(EffectCatalog.FindEffectIndexFromPrefab(effectPrefab), effectData, transmit);
 }
        // Token: 0x06000B07 RID: 2823 RVA: 0x00030EAC File Offset: 0x0002F0AC
        public void Footstep(string childName, GameObject footstepEffect)
        {
            if (!this.body)
            {
                return;
            }
            Transform transform = this.childLocator.FindChild(childName);

            if (transform)
            {
                Color      color      = Color.gray;
                RaycastHit raycastHit = default(RaycastHit);
                Vector3    position   = transform.position;
                position.y += 1.5f;
                Debug.DrawRay(position, Vector3.down);
                if (Physics.Raycast(new Ray(position, Vector3.down), out raycastHit, 4f, LayerIndex.world.mask | LayerIndex.water.mask, QueryTriggerInteraction.Collide))
                {
                    if (this.bodyInventory && this.bodyInventory.GetItemCount(ItemIndex.Hoof) > 0 && childName == "FootR")
                    {
                        Util.PlaySound("Play_item_proc_hoof", this.body.gameObject);
                    }
                    if (footstepEffect)
                    {
                        EffectManager.SimpleImpactEffect(footstepEffect, raycastHit.point, raycastHit.normal, false);
                    }
                    SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(raycastHit.collider, raycastHit.point);
                    bool       flag             = false;
                    if (objectSurfaceDef)
                    {
                        color = objectSurfaceDef.approximateColor;
                        if (objectSurfaceDef.footstepEffectPrefab)
                        {
                            EffectManager.SpawnEffect(objectSurfaceDef.footstepEffectPrefab, new EffectData
                            {
                                origin = raycastHit.point,
                                scale  = this.body.radius
                            }, false);
                            flag = true;
                        }
                        if (!string.IsNullOrEmpty(objectSurfaceDef.materialSwitchString))
                        {
                            AkSoundEngine.SetSwitch("material", objectSurfaceDef.materialSwitchString, this.body.gameObject);
                        }
                    }
                    else
                    {
                        Debug.LogFormat("{0} is missing surface def", new object[]
                        {
                            raycastHit.collider.gameObject
                        });
                    }
                    if (this.footstepDustInstanceTransform && !flag)
                    {
                        this.footstepDustInstanceTransform.position             = raycastHit.point;
                        this.footstepDustInstanceParticleSystem.main.startColor = color;
                        this.footstepDustInstanceParticleSystem.Play();
                        if (this.footstepDustInstanceShakeEmitter)
                        {
                            this.footstepDustInstanceShakeEmitter.StartShake();
                        }
                    }
                }
                Util.PlaySound((!string.IsNullOrEmpty(this.sprintFootstepOverrideString) && this.body.isSprinting) ? this.sprintFootstepOverrideString : this.baseFootstepString, this.body.gameObject);
                return;
            }
            Debug.LogWarningFormat("Object {0} lacks ChildLocator entry \"{1}\" to handle Footstep event!", new object[]
            {
                base.gameObject.name,
                childName
            });
        }
Beispiel #8
0
 private static void HandleEffectClient(NetworkMessage netMsg)
 {
     EffectManager.HandleEffectClientInternal(netMsg);
 }
Beispiel #9
0
 private static void HandleEffectServer(NetworkMessage netMsg)
 {
     EffectManager.HandleEffectServerInternal(netMsg);
 }
Beispiel #10
0
 // Token: 0x06000561 RID: 1377 RVA: 0x00015DE9 File Offset: 0x00013FE9
 private static void HandleEffectServerInternal(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <EffectManager.EffectMessage>(EffectManager.incomingEffectMessage);
     EffectManager.TransmitEffect(EffectManager.incomingEffectMessage.effectIndex, EffectManager.incomingEffectMessage.effectData, netMsg.conn);
 }
        // Token: 0x0600070C RID: 1804 RVA: 0x0001DEC8 File Offset: 0x0001C0C8
        public void OnProjectileImpact(ProjectileImpactInfo impactInfo)
        {
            if (!this.alive)
            {
                return;
            }
            Collider collider = impactInfo.collider;

            if (collider)
            {
                DamageInfo damageInfo = new DamageInfo();
                if (this.projectileDamage)
                {
                    damageInfo.damage           = this.projectileDamage.damage;
                    damageInfo.crit             = this.projectileDamage.crit;
                    damageInfo.attacker         = (this.projectileController.owner ? this.projectileController.owner.gameObject : null);
                    damageInfo.inflictor        = base.gameObject;
                    damageInfo.position         = impactInfo.estimatedPointOfImpact;
                    damageInfo.force            = this.projectileDamage.force * this.transform.forward;
                    damageInfo.procChainMask    = this.projectileController.procChainMask;
                    damageInfo.procCoefficient  = this.projectileController.procCoefficient;
                    damageInfo.damageColorIndex = this.projectileDamage.damageColorIndex;
                }
                HurtBox component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent)
                    {
                        Transform transform = healthComponent.gameObject.transform;
                        if (healthComponent.gameObject == this.projectileController.owner)
                        {
                            return;
                        }
                        if ((!this.pastTargetList.Contains(transform) || (this.canBounceToSameTarget && transform != this.lastTarget)) && (transform == this.currentTarget || this.canHitNonTarget || !this.currentTarget))
                        {
                            this.pastTargetList.Add(transform);
                            if (this.currentTarget)
                            {
                                this.lastTarget = this.currentTarget;
                            }
                            else
                            {
                                this.lastTarget = transform;
                            }
                            this.currentTarget = this.FindTarget();
                            this.bounceCount++;
                            healthComponent.TakeDamage(damageInfo);
                            GlobalEventManager.instance.OnHitAll(damageInfo, collider.gameObject);
                            GlobalEventManager.instance.OnHitEnemy(damageInfo, component.healthComponent.gameObject);
                            if (this.projectileDamage)
                            {
                                this.projectileDamage.damage *= this.damageMultiplier;
                            }
                            if (this.impactEffect)
                            {
                                EffectManager.SimpleImpactEffect(this.impactEffect, this.transform.position, -this.transform.forward, !this.projectileController.isPrediction);
                            }
                            if (this.bounceCount >= this.maxBounceCount)
                            {
                                this.alive = false;
                            }
                        }
                    }
                }
                else if (this.destroyOnWorldIfNoTarget && this.currentTarget == null)
                {
                    damageInfo.position = this.transform.position;
                    GlobalEventManager.instance.OnHitAll(damageInfo, collider.gameObject);
                    if (this.impactEffect)
                    {
                        EffectManager.SimpleImpactEffect(this.impactEffect, this.transform.position, -this.transform.forward, !this.projectileController.isPrediction);
                    }
                    this.alive = false;
                }
            }
            if (!this.alive)
            {
                UnityEngine.Object.Destroy(base.gameObject);
            }
        }
        // Token: 0x06000934 RID: 2356 RVA: 0x00027E88 File Offset: 0x00026088
        private bool AttemptSpawnOnTarget(GameObject spawnTarget)
        {
            if (this.currentMonsterCard == null)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.Log("Current monster card is null, pick new one.");
                }
                this.PrepareNewMonsterWave(this.monsterCards.Evaluate(this.rng.nextNormalizedFloat));
            }
            if (!spawnTarget)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn target {0} is invalid.", new object[]
                    {
                        spawnTarget
                    });
                }
                return(false);
            }
            if (this.spawnCountInCurrentWave >= this.maximumNumberToSpawnBeforeSkipping)
            {
                this.spawnCountInCurrentWave = 0;
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn count has hit the max ({0}/{1}). Aborting spawn.", new object[]
                    {
                        this.spawnCountInCurrentWave,
                        this.maximumNumberToSpawnBeforeSkipping
                    });
                }
                return(false);
            }
            int cost = this.currentMonsterCard.cost;
            int num  = this.currentMonsterCard.cost;
            int num2 = this.currentMonsterCard.cost;

            CombatDirector.EliteTierDef eliteTierDef = this.currentActiveEliteTier;
            EliteIndex eliteIndex = this.currentActiveEliteIndex;

            num2 = (int)((float)num * this.currentActiveEliteTier.costMultiplier);
            if ((float)num2 <= this.monsterCredit)
            {
                num          = num2;
                eliteTierDef = this.currentActiveEliteTier;
                eliteIndex   = this.currentActiveEliteIndex;
            }
            else
            {
                eliteTierDef = CombatDirector.eliteTiers[0];
                eliteIndex   = EliteIndex.None;
            }
            if (!this.currentMonsterCard.CardIsValid())
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn card {0} is invalid, aborting spawn.", new object[]
                    {
                        this.currentMonsterCard.spawnCard
                    });
                }
                return(false);
            }
            if (this.monsterCredit < (float)num)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn card {0} is too expensive, aborting spawn.", new object[]
                    {
                        this.currentMonsterCard.spawnCard
                    });
                }
                return(false);
            }
            if (this.skipSpawnIfTooCheap && (float)(num2 * this.maximumNumberToSpawnBeforeSkipping) < this.monsterCredit)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Card {0} seems too cheap ({1}/{2}). Comparing against most expensive possible ({3})", new object[]
                    {
                        this.currentMonsterCard.spawnCard,
                        num * this.maximumNumberToSpawnBeforeSkipping,
                        this.monsterCredit,
                        this.mostExpensiveMonsterCostInDeck
                    });
                }
                if (this.mostExpensiveMonsterCostInDeck > num)
                {
                    if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                    {
                        Debug.LogFormat("Spawn card {0} is too cheap, aborting spawn.", new object[]
                        {
                            this.currentMonsterCard.spawnCard
                        });
                    }
                    return(false);
                }
            }
            SpawnCard             spawnCard             = this.currentMonsterCard.spawnCard;
            DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
            {
                placementMode   = DirectorPlacementRule.PlacementMode.Approximate,
                spawnOnTarget   = spawnTarget.transform,
                preventOverhead = this.currentMonsterCard.preventOverhead
            };

            DirectorCore.GetMonsterSpawnDistance(this.currentMonsterCard.spawnDistance, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
            directorPlacementRule.minDistance *= this.spawnDistanceMultiplier;
            directorPlacementRule.maxDistance *= this.spawnDistanceMultiplier;
            DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(spawnCard, directorPlacementRule, this.rng);

            directorSpawnRequest.ignoreTeamMemberLimit = true;
            directorSpawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Monster);
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);

            if (!gameObject)
            {
                Debug.LogFormat("Spawn card {0} failed to spawn. Aborting cost procedures.", new object[]
                {
                    spawnCard
                });
                return(false);
            }
            this.monsterCredit -= (float)num;
            this.spawnCountInCurrentWave++;
            CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();
            GameObject      bodyObject = component.GetBodyObject();

            if (this.combatSquad)
            {
                this.combatSquad.AddMember(component);
            }
            float          num3 = eliteTierDef.healthBoostCoefficient;
            float          damageBoostCoefficient = eliteTierDef.damageBoostCoefficient;
            EliteDef       eliteDef       = EliteCatalog.GetEliteDef(eliteIndex);
            EquipmentIndex equipmentIndex = (eliteDef != null) ? eliteDef.eliteEquipmentIndex : EquipmentIndex.None;

            if (equipmentIndex != EquipmentIndex.None)
            {
                component.inventory.SetEquipmentIndex(equipmentIndex);
            }
            if (this.combatSquad)
            {
                int livingPlayerCount = Run.instance.livingPlayerCount;
                num3 *= Mathf.Pow((float)livingPlayerCount, 1f);
            }
            component.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((num3 - 1f) * 10f));
            component.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((damageBoostCoefficient - 1f) * 10f));
            DeathRewards component2 = bodyObject.GetComponent <DeathRewards>();

            if (component2)
            {
                component2.expReward  = (uint)((float)num * this.expRewardCoefficient * Run.instance.compensatedDifficultyCoefficient);
                component2.goldReward = (uint)((float)num * this.expRewardCoefficient * 2f * Run.instance.compensatedDifficultyCoefficient);
            }
            if (this.spawnEffectPrefab && NetworkServer.active)
            {
                Vector3       origin     = gameObject.transform.position;
                CharacterBody component3 = bodyObject.GetComponent <CharacterBody>();
                if (component3)
                {
                    origin = component3.corePosition;
                }
                EffectManager.SpawnEffect(this.spawnEffectPrefab, new EffectData
                {
                    origin = origin
                }, true);
            }
            CombatDirector.OnSpawnedServer onSpawnedServer = this.onSpawnedServer;
            if (onSpawnedServer != null)
            {
                onSpawnedServer.Invoke(gameObject);
            }
            return(true);
        }