Beispiel #1
0
        // Token: 0x060033E8 RID: 13288 RVA: 0x00152238 File Offset: 0x00150638
        public static RaycastInfo raycast(Ray ray, float range, int mask)
        {
            RaycastHit hit;

            PhysicsUtility.raycast(ray, out hit, range, mask, QueryTriggerInteraction.UseGlobal);
            RaycastInfo raycastInfo = new RaycastInfo(hit);

            raycastInfo.direction = ray.direction;
            if (hit.transform != null)
            {
                if (hit.transform.CompareTag("Enemy"))
                {
                    raycastInfo.player = DamageTool.getPlayer(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Zombie"))
                {
                    raycastInfo.zombie = DamageTool.getZombie(raycastInfo.transform);
                }
                if (hit.transform.CompareTag("Animal"))
                {
                    raycastInfo.animal = DamageTool.getAnimal(raycastInfo.transform);
                }
                raycastInfo.limb = DamageTool.getLimb(raycastInfo.transform);
                if (hit.transform.CompareTag("Vehicle"))
                {
                    raycastInfo.vehicle = DamageTool.getVehicle(raycastInfo.transform);
                }
                if (raycastInfo.zombie != null && raycastInfo.zombie.isRadioactive)
                {
                    raycastInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                }
                else
                {
                    raycastInfo.material = DamageTool.getMaterial(hit.point, hit.transform, hit.collider);
                }
            }
            return(raycastInfo);
        }
Beispiel #2
0
        // Token: 0x0600280E RID: 10254 RVA: 0x000F2934 File Offset: 0x000F0D34
        public static Transform effect(ushort id, Vector3 point, Vector3 normal)
        {
            EffectAsset effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, id);

            if (effectAsset == null)
            {
                return(null);
            }
            if (effectAsset.splatterTemperature != EPlayerTemperature.NONE)
            {
                Transform transform = new GameObject().transform;
                transform.name       = "Temperature";
                transform.parent     = Level.effects;
                transform.position   = point + Vector3.down * -2f;
                transform.localScale = Vector3.one * 6f;
                transform.gameObject.SetActive(false);
                transform.gameObject.AddComponent <TemperatureTrigger>().temperature = effectAsset.splatterTemperature;
                transform.gameObject.SetActive(true);
                UnityEngine.Object.Destroy(transform.gameObject, effectAsset.splatterLifetime - effectAsset.splatterLifetimeSpread);
            }
            if (Dedicator.isDedicated)
            {
                if (!effectAsset.spawnOnDedicatedServer)
                {
                    return(null);
                }
            }
            else if (GraphicsSettings.effectQuality == EGraphicQuality.OFF && !effectAsset.splatterLiquid)
            {
                return(null);
            }
            Quaternion quaternion = Quaternion.LookRotation(normal);

            if (effectAsset.randomizeRotation)
            {
                quaternion *= Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360));
            }
            Transform transform2 = EffectManager.pool.Instantiate(effectAsset.effect, point, quaternion).transform;

            transform2.name   = id.ToString();
            transform2.parent = Level.effects;
            if (effectAsset.splatter > 0 && (!effectAsset.gore || OptionsSettings.gore))
            {
                for (int i = 0; i < (int)(effectAsset.splatter * ((effectAsset.splatterLiquid || !(Player.player != null) || Player.player.skills.boost != EPlayerBoost.SPLATTERIFIC) ? 1 : 8)); i++)
                {
                    RaycastHit raycastHit;
                    if (effectAsset.splatterLiquid)
                    {
                        float f        = UnityEngine.Random.Range(0f, 6.28318548f);
                        float num      = UnityEngine.Random.Range(1f, 6f);
                        Ray   ray      = new Ray(point + new Vector3(Mathf.Cos(f) * num, 0f, Mathf.Sin(f) * num), Vector3.down);
                        int   splatter = RayMasks.SPLATTER;
                        LandscapeHoleUtility.raycastIgnoreLandscapeIfNecessary(ray, 8f, ref splatter);
                        Physics.Raycast(ray, out raycastHit, 8f, splatter);
                    }
                    else
                    {
                        Ray ray2      = new Ray(point, -2f * normal + new Vector3(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f)));
                        int splatter2 = RayMasks.SPLATTER;
                        LandscapeHoleUtility.raycastIgnoreLandscapeIfNecessary(ray2, 8f, ref splatter2);
                        Physics.Raycast(ray2, out raycastHit, 8f, splatter2);
                    }
                    if (raycastHit.transform != null)
                    {
                        EPhysicsMaterial material = DamageTool.getMaterial(raycastHit.point, raycastHit.transform, raycastHit.collider);
                        if (!PhysicsTool.isMaterialDynamic(material))
                        {
                            float     num2       = UnityEngine.Random.Range(1f, 2f);
                            Transform transform3 = EffectManager.pool.Instantiate(effectAsset.splatters[UnityEngine.Random.Range(0, effectAsset.splatters.Length)], raycastHit.point + raycastHit.normal * UnityEngine.Random.Range(0.04f, 0.06f), Quaternion.LookRotation(raycastHit.normal) * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360))).transform;
                            transform3.name       = "Splatter";
                            transform3.parent     = Level.effects;
                            transform3.localScale = new Vector3(num2, num2, num2);
                            transform3.gameObject.SetActive(true);
                            if (effectAsset.splatterLifetime > 1.401298E-45f)
                            {
                                EffectManager.pool.Destroy(transform3.gameObject, effectAsset.splatterLifetime + UnityEngine.Random.Range(-effectAsset.splatterLifetimeSpread, effectAsset.splatterLifetimeSpread));
                            }
                            else
                            {
                                EffectManager.pool.Destroy(transform3.gameObject, GraphicsSettings.effect);
                            }
                        }
                    }
                }
            }
            if (effectAsset.gore)
            {
                transform2.GetComponent <ParticleSystem>().emission.enabled = OptionsSettings.gore;
            }
            if (!effectAsset.isStatic && transform2.GetComponent <AudioSource>() != null)
            {
                transform2.GetComponent <AudioSource>().pitch = UnityEngine.Random.Range(0.9f, 1.1f);
            }
            if (effectAsset.lifetime > 1.401298E-45f)
            {
                EffectManager.pool.Destroy(transform2.gameObject, effectAsset.lifetime + UnityEngine.Random.Range(-effectAsset.lifetimeSpread, effectAsset.lifetimeSpread));
            }
            else
            {
                float        num3      = 0f;
                MeshRenderer component = transform2.GetComponent <MeshRenderer>();
                if (component == null)
                {
                    ParticleSystem component2 = transform2.GetComponent <ParticleSystem>();
                    if (component2 != null)
                    {
                        if (component2.main.loop)
                        {
                            num3 = component2.main.startLifetime.constantMax;
                        }
                        else
                        {
                            num3 = component2.main.duration + component2.main.startLifetime.constantMax;
                        }
                    }
                    AudioSource component3 = transform2.GetComponent <AudioSource>();
                    if (component3 != null && component3.clip != null && component3.clip.length > num3)
                    {
                        num3 = component3.clip.length;
                    }
                }
                if (num3 < 1.401298E-45f)
                {
                    num3 = GraphicsSettings.effect;
                }
                EffectManager.pool.Destroy(transform2.gameObject, num3);
            }
            if (effectAsset.blast > 0 && GraphicsSettings.blast && GraphicsSettings.renderMode == ERenderMode.DEFERRED)
            {
                EffectManager.effect(effectAsset.blast, point, new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f), 1f, UnityEngine.Random.Range(-0.1f, 0.1f)));
            }
            return(transform2);
        }
Beispiel #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (Provider.isServer)
     {
         if (other.isTrigger)
         {
             return;
         }
         if (other.CompareTag("Debris"))
         {
             return;
         }
         float num = Mathf.Clamp(this.vehicle.speed * this.vehicle.asset.bumperMultiplier, 0f, 10f);
         if (num < 3f)
         {
             return;
         }
         if (other.transform.parent.CompareTag("Vehicle"))
         {
             return;
         }
         if (other.transform.CompareTag("Player"))
         {
             if (Provider.isPvP && this.vehicle.isDriven)
             {
                 Player player = DamageTool.getPlayer(other.transform);
                 if (player != null && player.movement.getVehicle() == null && !this.vehicle.passengers[0].player.player.quests.isMemberOfSameGroupAs(player))
                 {
                     EPlayerKill eplayerKill;
                     DamageTool.damage(player, EDeathCause.ROADKILL, ELimb.SPINE, this.vehicle.passengers[0].player.playerID.steamID, base.transform.forward, Bumper.DAMAGE_PLAYER, num, out eplayerKill);
                     EffectManager.sendEffect(5, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward);
                     this.vehicle.askDamage(2, true);
                 }
             }
         }
         else if (other.transform.CompareTag("Agent"))
         {
             Zombie zombie = DamageTool.getZombie(other.transform);
             if (zombie != null)
             {
                 EPlayerKill eplayerKill2;
                 uint        num2;
                 DamageTool.damage(zombie, base.transform.forward, Bumper.DAMAGE_ZOMBIE, num, out eplayerKill2, out num2);
                 EffectManager.sendEffect((!zombie.isRadioactive) ? 5 : 95, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward);
                 this.vehicle.askDamage(2, true);
             }
             else
             {
                 Animal animal = DamageTool.getAnimal(other.transform);
                 if (animal != null)
                 {
                     EPlayerKill eplayerKill3;
                     uint        num3;
                     DamageTool.damage(animal, base.transform.forward, Bumper.DAMAGE_ANIMAL, num, out eplayerKill3, out num3);
                     EffectManager.sendEffect(5, EffectManager.SMALL, other.transform.position + other.transform.up, -base.transform.forward);
                     this.vehicle.askDamage(2, true);
                 }
             }
         }
         else
         {
             if (!other.transform.CompareTag("Barricade"))
             {
                 if (!other.transform.CompareTag("Structure"))
                 {
                     if (other.transform.CompareTag("Resource"))
                     {
                         DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true);
                         EPlayerKill eplayerKill4;
                         uint        num4;
                         ResourceManager.damage(other.transform, base.transform.forward, Bumper.DAMAGE_RESOURCE, num, 1f, out eplayerKill4, out num4);
                         this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true);
                     }
                     else
                     {
                         InteractableObjectRubble componentInParent = other.transform.GetComponentInParent <InteractableObjectRubble>();
                         if (componentInParent != null)
                         {
                             EPlayerKill eplayerKill5;
                             uint        num5;
                             DamageTool.damage(componentInParent.transform, base.transform.forward, componentInParent.getSection(other.transform), Bumper.DAMAGE_OBJECT, num, out eplayerKill5, out num5);
                             if (Time.realtimeSinceStartup - this.lastDamageImpact > 0.2f)
                             {
                                 this.lastDamageImpact = Time.realtimeSinceStartup;
                                 DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true);
                                 this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true);
                             }
                         }
                         else if (Time.realtimeSinceStartup - this.lastDamageImpact > 0.2f)
                         {
                             ObjectAsset asset = LevelObjects.getAsset(other.transform);
                             if (asset != null && !asset.isSoft)
                             {
                                 this.lastDamageImpact = Time.realtimeSinceStartup;
                                 DamageTool.impact(base.transform.position + base.transform.forward * ((BoxCollider)base.transform.GetComponent <Collider>()).size.z / 2f, -base.transform.forward, DamageTool.getMaterial(base.transform.position, other.transform, other.GetComponent <Collider>()), true);
                                 this.vehicle.askDamage((ushort)(Bumper.DAMAGE_VEHICLE * num), true);
                             }
                         }
                     }
                 }
             }
             if (!this.vehicle.isDead && !other.transform.CompareTag("Border") && ((this.vehicle.asset.engine == EEngine.PLANE && this.vehicle.speed > 20f) || (this.vehicle.asset.engine == EEngine.HELICOPTER && this.vehicle.speed > 10f)))
             {
                 this.vehicle.askDamage(20000, false);
             }
         }
     }
 }