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); } } } } }
private void RemoveAllRemoveableEffects() { for (int i = 0; i < this._effectLs.Count; i++) { BaseMonoEffect effect = this._effectLs[i]; if (effect.IsToBeRemove()) { this.RemoveEffectByRuntimeID(effect.GetRuntimeID(), i); i--; } } }
public BaseMonoEffect CreateEffectInstance(string effectPath, bool isLocal, Vector3 initPos, Vector3 faceDir, Vector3 initScale) { BaseMonoEffect item = null; GameObject obj2; if (this.mute) { return(null); } this._effectPrefabCache.TryGetValue(effectPath, out obj2); if (obj2 == null) { obj2 = Miscs.LoadResource <GameObject>(EffectData.GetPrefabResPath(effectPath), BundleType.RESOURCE_FILE); this._effectPrefabCache.Add(effectPath, obj2); } bool isFromEffectPool = false; GameObject obj3 = null; if (this._effectPool != null) { GameObject obj4 = this._effectPool.Spawn(obj2); if (obj4 != null) { obj3 = obj4; } } isFromEffectPool = obj3 != null; if (!isFromEffectPool) { obj3 = UnityEngine.Object.Instantiate <GameObject>(obj2); obj3.transform.parent = this.GetEffectRootOutsidePool(); obj3.name = obj2.name; } item = obj3.GetComponent <BaseMonoEffect>(); item.Init(effectPath, Singleton <RuntimeIDManager> .Instance.GetNextNonSyncedRuntimeID(5), initPos, faceDir, initScale, isFromEffectPool); item.Setup(); if (item == null) { throw new Exception("Invalid Type or State!"); } this._effectLs.Add(item); this._effectDict.Add(item.GetRuntimeID(), item); return(item); }
private bool RemoveEffectByRuntimeID(uint runtimeID, int lsIx) { BaseMonoEffect effect = this._effectDict[runtimeID]; if (effect != null) { if ((this._effectPool != null) && effect.isFromEffectPool) { this._effectPool.Despawn(effect.gameObject); } else { UnityEngine.Object.Destroy(effect.gameObject); } } bool flag = this._effectDict.Remove(runtimeID); this._effectLs.RemoveAt(lsIx); return(flag); }