Esempio n. 1
0
 public void AssignNewTarget(GameObject target)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.HealingFollowerController::AssignNewTarget(UnityEngine.GameObject)' called on client");
         return;
     }
     this.NetworktargetBodyObject     = (target ? target : this.ownerBodyObject);
     this.cachedTargetBodyObject      = this.targetBodyObject;
     this.cachedTargetHealthComponent = (this.cachedTargetBodyObject ? this.cachedTargetBodyObject.GetComponent <HealthComponent>() : null);
     this.OnTargetChanged();
     if (this.targetBodyObject.GetComponent <CharacterBody>())
     {
         EffectManager.SimpleImpactEffect(this.burstHealEffect, this.GetTargetPosition(), Vector3.up, true);
     }
     if (NetworkServer.active)
     {
         this.DoHeal(this.fractionHealthBurst);
     }
 }
Esempio n. 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: 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
            });
        }
        // 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);
            }
        }