示例#1
0
 private void onLevelLoaded(int level)
 {
     EffectManager.pool = new GameObjectPoolDictionary();
     if (Dedicator.isDedicated)
     {
         return;
     }
     Asset[] array = Assets.find(EAssetType.EFFECT);
     for (int i = 0; i < array.Length; i++)
     {
         EffectAsset effectAsset = array[i] as EffectAsset;
         if (effectAsset != null && !(effectAsset.effect == null) && effectAsset.preload != 0)
         {
             EffectManager.pool.Instantiate(effectAsset.effect, Level.effects, effectAsset.id.ToString(), (int)effectAsset.preload);
             if (effectAsset.splatter > 0 && effectAsset.splatterPreload > 0)
             {
                 for (int j = 0; j < effectAsset.splatters.Length; j++)
                 {
                     EffectManager.pool.Instantiate(effectAsset.splatters[j], Level.effects, "Splatter", (int)effectAsset.splatterPreload);
                 }
             }
         }
     }
 }
示例#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);
        }
示例#3
0
 public override void refreshDisplay()
 {
     base.refreshDisplay();
     this.hasWeapon   = false;
     this.attachments = null;
     this.sound       = null;
     this.destroyEffects();
     if (this.spotGameObject != null)
     {
         this.spotGameObject.SetActive(false);
     }
     if (this.displayAsset == null || this.displayAsset.type != EItemType.GUN || ((ItemGunAsset)this.displayAsset).action == EAction.String || ((ItemGunAsset)this.displayAsset).action == EAction.Rocket)
     {
         return;
     }
     this.hasWeapon   = true;
     this.attachments = this.displayModel.gameObject.GetComponent <Attachments>();
     this.interact    = (this.displayItem.state[12] == 1);
     if (!Dedicator.isDedicated)
     {
         this.sound              = this.displayModel.gameObject.AddComponent <AudioSource>();
         this.sound.clip         = null;
         this.sound.spatialBlend = 1f;
         this.sound.rolloffMode  = 1;
         this.sound.volume       = 1f;
         this.sound.minDistance  = 8f;
         this.sound.maxDistance  = 256f;
         this.sound.playOnAwake  = false;
     }
     if (this.attachments.ejectHook != null && ((ItemGunAsset)this.displayAsset).action != EAction.String && ((ItemGunAsset)this.displayAsset).action != EAction.Rocket)
     {
         EffectAsset effectAsset = null;
         if (((ItemGunAsset)this.displayAsset).action == EAction.Pump || ((ItemGunAsset)this.displayAsset).action == EAction.Break)
         {
             effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, 33);
         }
         else if (((ItemGunAsset)this.displayAsset).action != EAction.Rail)
         {
             effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, 1);
         }
         if (effectAsset != null)
         {
             Transform transform = EffectManager.Instantiate(effectAsset.effect).transform;
             transform.name          = "Emitter";
             transform.parent        = this.attachments.ejectHook;
             transform.localPosition = Vector3.zero;
             transform.localRotation = Quaternion.identity;
             this.shellEmitter       = transform.GetComponent <ParticleSystem>();
         }
     }
     if (this.attachments.barrelHook != null)
     {
         EffectAsset effectAsset2 = (EffectAsset)Assets.find(EAssetType.EFFECT, ((ItemGunAsset)this.displayAsset).muzzle);
         if (effectAsset2 != null)
         {
             Transform transform2 = EffectManager.Instantiate(effectAsset2.effect).transform;
             transform2.name          = "Emitter";
             transform2.parent        = this.attachments.barrelHook;
             transform2.localPosition = Vector3.zero;
             transform2.localRotation = Quaternion.identity;
             this.muzzleEmitter       = transform2.GetComponent <ParticleSystem>();
         }
     }
     if (this.muzzleEmitter != null)
     {
         if (this.attachments.barrelModel != null)
         {
             this.muzzleEmitter.transform.localPosition = Vector3.up * 0.25f;
         }
         else
         {
             this.muzzleEmitter.transform.localPosition = Vector3.zero;
         }
     }
     if (this.attachments.magazineAsset != null)
     {
         EffectAsset effectAsset3 = (EffectAsset)Assets.find(EAssetType.EFFECT, this.attachments.magazineAsset.tracer);
         if (effectAsset3 != null)
         {
             Transform transform3 = EffectManager.Instantiate(effectAsset3.effect).transform;
             transform3.name          = "Tracer";
             transform3.parent        = Level.effects;
             transform3.localPosition = Vector3.zero;
             transform3.localRotation = Quaternion.identity;
             this.tracerEmitter       = transform3.GetComponent <ParticleSystem>();
         }
     }
     if (!Dedicator.isDedicated)
     {
         if (this.attachments.tacticalAsset != null && (this.attachments.tacticalAsset.isLight || this.attachments.tacticalAsset.isLaser) && this.attachments.lightHook != null)
         {
             this.attachments.lightHook.gameObject.SetActive(this.interact);
         }
         if (this.spotGameObject != null)
         {
             this.spotGameObject.SetActive(this.attachments.tacticalAsset != null && this.attachments.tacticalAsset.isLight && this.interact);
         }
     }
     this.fireTime  = (float)(((ItemGunAsset)this.displayAsset).firerate - ((this.attachments.tacticalAsset == null) ? 0 : this.attachments.tacticalAsset.firerate));
     this.fireTime /= 50f;
     this.fireTime *= 3.33f;
 }