Пример #1
0
        public void HandleEffectOverride(MonoEffectOverride effectOverride)
        {
            if (!string.IsNullOrEmpty(this.MaterialOverrideKey) && effectOverride.materialOverrides.ContainsKey(this.MaterialOverrideKey))
            {
                if (this._staticTrail.TrailData.TrailMaterials[0].name.EndsWith("(Instance)"))
                {
                    if (Application.isEditor)
                    {
                        UnityEngine.Object.DestroyImmediate(this._staticTrail.TrailData.TrailMaterials[0]);
                    }
                    else
                    {
                        UnityEngine.Object.Destroy(this._staticTrail.TrailData.TrailMaterials[0]);
                    }
                }
                this._staticTrail.TrailData.TrailMaterials[0] = new Material(effectOverride.materialOverrides[this.MaterialOverrideKey]);
                Material material1 = this._staticTrail.TrailData.TrailMaterials[0];
                material1.name = material1.name + "(Instance)";
                string tag = effectOverride.materialOverrides[this.MaterialOverrideKey].GetTag("Distortion", false);
                this._staticTrail.TrailData.TrailMaterials[0].SetOverrideTag("Distortion", tag);
                this._staticTrail.ResetAnimation(this.appearDuration, this.appearCurve, this.vanishDuration, this.vanishCurve);
            }
            if (!string.IsNullOrEmpty(this.EffectOverlayKey) && effectOverride.effectOverlays.ContainsKey(this.EffectOverlayKey))
            {
                List <MonoEffect> list;
                Singleton <EffectManager> .Instance.TriggerEntityEffectPatternRaw(effectOverride.effectOverlays[this.EffectOverlayKey], base.AniAnchorTransform.position, base.AniAnchorTransform.forward, base.AniAnchorTransform.localScale, base._effect.owner, out list);

                for (int i = 0; i < list.Count; i++)
                {
                    list[i].transform.SetParent(base.AniAnchorTransform, true);
                }
            }
        }
Пример #2
0
        public void SetupOverride(BaseMonoEntity owner)
        {
            MonoEffectOverride component = owner.GetComponent <MonoEffectOverride>();

            if (component != null)
            {
                MonoEffectPluginTrailSmooth smooth = base.GetComponent <MonoEffectPluginTrailSmooth>();
                if (smooth != null)
                {
                    smooth.HandleEffectOverride(component);
                }
                else
                {
                    MonoEffectPluginTrailStatic @static = base.GetComponent <MonoEffectPluginTrailStatic>();
                    if (@static != null)
                    {
                        @static.HandleEffectOverride(component);
                    }
                }
                MonoEffectPluginOverrideHandler handler = base.GetComponent <MonoEffectPluginOverrideHandler>();
                if (handler != null)
                {
                    handler.HandleEffectOverride(component);
                }
            }
        }
Пример #3
0
        private void ApplyStageEffectSetting(ConfigStageEffectSetting setting)
        {
            BaseMonoAvatar localAvatar = Singleton <AvatarManager> .Instance.GetLocalAvatar();

            this.AddEntityEffectPredicates(localAvatar, setting.LocalAvatarEffectPredicates);
            this._localAvatarPredicates = setting.LocalAvatarEffectPredicates;
            if (setting.AvatarColorOverrides.Length > 0)
            {
                List <BaseMonoAvatar> allPlayerAvatars = Singleton <AvatarManager> .Instance.GetAllPlayerAvatars();

                for (int i = 0; i < allPlayerAvatars.Count; i++)
                {
                    BaseMonoAvatar     avatar2   = allPlayerAvatars[i];
                    MonoEffectOverride component = avatar2.GetComponent <MonoEffectOverride>();
                    if (component == null)
                    {
                        component = avatar2.gameObject.AddComponent <MonoEffectOverride>();
                    }
                    for (int j = 0; j < setting.AvatarColorOverrides.Length; j++)
                    {
                        ColorOverrideEntry entry = setting.AvatarColorOverrides[j];
                        component.colorOverrides.Add(entry.colorOverrideKey, entry.color);
                    }
                }
            }
        }
Пример #4
0
        public void AddEffectOverride(string effectOverrideKey, string effectPattern)
        {
            MonoEffectOverride component = base.GetComponent <MonoEffectOverride>();

            if (component == null)
            {
                component = base.gameObject.AddComponent <MonoEffectOverride>();
            }
            component.effectOverrides.Add(effectOverrideKey, effectPattern);
        }
Пример #5
0
        public void TriggerEntityEffectPatternRaw(string patternName, Vector3 initPos, Vector3 initDir, Vector3 initScale, BaseMonoEntity entity, out List <MonoEffect> effects)
        {
            MonoEffectOverride component = entity.GetComponent <MonoEffectOverride>();

            if ((component != null) && component.effectOverrides.ContainsKey(patternName))
            {
                patternName = component.effectOverrides[patternName];
            }
            EffectPattern effectPattern = EffectData.GetEffectPattern(patternName);

            effects = new List <MonoEffect>();
            if (effectPattern.randomOneFromSubs)
            {
                int[] list = new int[effectPattern.subEffects.Length];
                for (int i = 0; i < list.Length; i++)
                {
                    list[i] = i;
                }
                list.Shuffle <int>();
                for (int j = 0; j < list.Length; j++)
                {
                    if (((component == null) || string.IsNullOrEmpty(effectPattern.subEffects[j].predicate)) || component.effectPredicates.Contains(effectPattern.subEffects[j].predicate))
                    {
                        BaseMonoEffect effect = this.CreateEffectInstanceBySubEffectConfig(effectPattern.subEffects[j], initPos, initDir, initScale, entity);
                        if ((effect != null) && (effect is MonoEffect))
                        {
                            effects.Add((MonoEffect)effect);
                            break;
                        }
                    }
                }
            }
            else if (effectPattern.subEffects.Length == 1)
            {
                BaseMonoEffect effect2 = this.CreateEffectInstanceBySubEffectConfig(effectPattern.subEffects[0], initPos, initDir, initScale, entity);
                if ((effect2 != null) && (effect2 is MonoEffect))
                {
                    effects.Add((MonoEffect)effect2);
                }
            }
            else
            {
                for (int k = 0; k < effectPattern.subEffects.Length; k++)
                {
                    if (((component == null) || string.IsNullOrEmpty(effectPattern.subEffects[k].predicate)) || component.effectPredicates.Contains(effectPattern.subEffects[k].predicate))
                    {
                        BaseMonoEffect effect3 = this.CreateEffectInstanceBySubEffectConfig(effectPattern.subEffects[k], initPos, initDir, initScale, entity);
                        if ((effect3 != null) && (effect3 is MonoEffect))
                        {
                            effects.Add((MonoEffect)effect3);
                        }
                    }
                }
            }
        }
Пример #6
0
        public void HandleEffectOverride(MonoEffectOverride effectOverride)
        {
            if (!string.IsNullOrEmpty(this.MaterialOverrideKey) && effectOverride.materialOverrides.ContainsKey(this.MaterialOverrideKey))
            {
                this._smoothTrail.TrailData.TrailMaterials[0] = effectOverride.materialOverrides[this.MaterialOverrideKey];
            }
            if (!string.IsNullOrEmpty(this.EffectOverlayKey) && effectOverride.effectOverlays.ContainsKey(this.EffectOverlayKey))
            {
                List <MonoEffect> list;
                Singleton <EffectManager> .Instance.TriggerEntityEffectPatternRaw(effectOverride.effectOverlays[this.EffectOverlayKey], base.AniAnchorTransform.position, base.AniAnchorTransform.forward, base.AniAnchorTransform.localScale, base._effect.owner, out list);

                for (int i = 0; i < list.Count; i++)
                {
                    list[i].transform.SetParent(base.AniAnchorTransform, true);
                }
            }
        }
Пример #7
0
        private void UnApplyStageEffectSettings(ConfigStageEffectSetting setting)
        {
            BaseMonoAvatar localAvatar = Singleton <AvatarManager> .Instance.GetLocalAvatar();

            this.RemoveEntityEffectPredicates(localAvatar, setting.LocalAvatarEffectPredicates);
            this._localAvatarPredicates = Miscs.EMPTY_STRINGS;
            List <BaseMonoAvatar> allPlayerAvatars = Singleton <AvatarManager> .Instance.GetAllPlayerAvatars();

            for (int i = 0; i < allPlayerAvatars.Count; i++)
            {
                MonoEffectOverride component = allPlayerAvatars[i].GetComponent <MonoEffectOverride>();
                if (component != null)
                {
                    for (int j = 0; j < setting.AvatarColorOverrides.Length; j++)
                    {
                        ColorOverrideEntry entry = setting.AvatarColorOverrides[j];
                        component.colorOverrides.Remove(entry.colorOverrideKey);
                    }
                }
            }
        }
Пример #8
0
        public void HandleEffectOverride(MonoEffectOverride effectOverride)
        {
            for (int i = 0; i < this.rendererOverrides.Length; i++)
            {
                Material material;
                RendererMaterialOverride @override = this.rendererOverrides[i];
                if (effectOverride.materialOverrides.TryGetValue(@override.materialOverrideKey, out material))
                {
                    if (@override.renderer is ParticleSystemRenderer)
                    {
                        GraphicsUtils.CreateAndAssignInstancedMaterial(@override.renderer, material);
                    }
                    else
                    {
                        @override.renderer.sharedMaterial = material;
                    }
                }
                else if (@override.renderer is ParticleSystemRenderer)
                {
                    if (GraphicsUtils.IsInstancedMaterial(@override.renderer.sharedMaterial))
                    {
                        GraphicsUtils.CreateAndAssignInstancedMaterial(@override.renderer, @override.originalMaterial);
                    }
                    else
                    {
                        @override.renderer.sharedMaterial = @override.originalMaterial;
                    }
                }
                else
                {
                    @override.renderer.sharedMaterial = @override.originalMaterial;
                }
            }
            for (int j = 0; j < this.effectOverlays.Length; j++)
            {
                string str;
                if (effectOverride.effectOverlays.TryGetValue(this.effectOverlays[j], out str))
                {
                    Singleton <EffectManager> .Instance.TriggerEntityEffectPattern(str, base.transform.position, base.transform.forward, base.transform.localScale, base._effect.owner);
                }
            }
            MaterialPropertyBlock dest = new MaterialPropertyBlock();

            for (int k = 0; k < this.rendererColorOverrides.Length; k++)
            {
                Color color;
                RendererColorOverride override2 = this.rendererColorOverrides[k];
                if (effectOverride.colorOverrides.TryGetValue(override2.colorOverrideKey, out color))
                {
                    if (override2.renderer is ParticleSystemRenderer)
                    {
                        if (!GraphicsUtils.IsInstancedMaterial(override2.renderer.sharedMaterial))
                        {
                            GraphicsUtils.CreateAndAssignInstancedMaterial(override2.renderer, override2.renderer.sharedMaterial);
                        }
                        override2.renderer.sharedMaterial.SetColor(override2.colorPropertyKey, color);
                    }
                    else
                    {
                        dest.Clear();
                        override2.renderer.GetPropertyBlock(dest);
                        dest.SetColor(override2.colorPropertyKey, effectOverride.colorOverrides[override2.colorOverrideKey]);
                        override2.renderer.SetPropertyBlock(dest);
                    }
                }
            }
            for (int m = 0; m < this.rendererFloatOverrides.Length; m++)
            {
                float num5;
                RendererFloatOverride override3 = this.rendererFloatOverrides[m];
                if (effectOverride.floatOverrides.TryGetValue(override3.floatOverrideKey, out num5))
                {
                    if (override3.renderer is ParticleSystemRenderer)
                    {
                        if (!GraphicsUtils.IsInstancedMaterial(override3.renderer.sharedMaterial))
                        {
                            GraphicsUtils.CreateAndAssignInstancedMaterial(override3.renderer, override3.renderer.sharedMaterial);
                        }
                        override3.renderer.sharedMaterial.SetFloat(override3.floatPropertyKey, num5);
                    }
                    else
                    {
                        dest.Clear();
                        override3.renderer.GetPropertyBlock(dest);
                        dest.SetFloat(override3.floatPropertyKey, effectOverride.floatOverrides[override3.floatOverrideKey]);
                        override3.renderer.SetPropertyBlock(dest);
                    }
                }
            }
            for (int n = 0; n < this.particleSystemStartColorOverrides.Length; n++)
            {
                ParticleSystemStartColorOverride override4 = this.particleSystemStartColorOverrides[n];
                if (override4.type == ParticleSystemStartColorOverride.StartColorType.ConstColor1)
                {
                    Color color2;
                    if (effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey1, out color2))
                    {
                        override4.particleSystem.startColor = color2;
                    }
                }
                else
                {
                    Color color3;
                    Color color4;
                    if (((override4.type == ParticleSystemStartColorOverride.StartColorType.RandomBetweenColor12) && effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey1, out color3)) && effectOverride.colorOverrides.TryGetValue(override4.colorOverrideKey2, out color4))
                    {
                        override4.particleSystem.startColor = Color.Lerp(color3, color4, UnityEngine.Random.value);
                    }
                }
            }
        }