private bool IsOurEffect(TESEffectShader effect) { if (effect == null) { return(false); } uint fid = effect.FormId; int c = this._shaderIds.Count; for (int i = 0; i < c; i++) { if (this._shaderIds[i] == fid) { return(true); } } return(false); }
private void update() { HashSet <uint> glowing = new HashSet <uint>(); var plist = ProcessLists.Instance; if (plist == null) { return; } var plr = PlayerCharacter.Instance; if (plr == null) { return; } var pos = plr.Position; #if DEBUG_MSG int did_update = 0; #endif plist.MagicEffectsLock.Lock(); try { foreach (var effectPtr in plist.MagicEffects) { #if DEBUG_MSG did_update++; #endif var effectInstance = effectPtr.Value as ShaderReferenceEffect; if (effectInstance == null || effectInstance.Finished || !this.IsOurEffect(effectInstance.EffectData)) { continue; } uint objHandle = effectInstance.TargetObjRefHandle; using (var objHolder = new ObjectRefHolder(objHandle)) { var obj = objHolder.Object; if (this.ShouldGlow(obj, pos) == null) { effectInstance.Finished = true; #if DEBUG_MSG NetScriptFramework.Main.WriteDebugMessage("Removing glow from " + (obj != null ? obj.ToString() : "null")); #endif } else if (obj != null) { glowing.Add(obj.FormId); } } } } finally { plist.MagicEffectsLock.Unlock(); } #if DEBUG_MSG //NetScriptFramework.Main.WriteDebugMessage("Iterated and updated " + did_update + " effects in ProcessLists"); #endif var tes = TES.Instance; if (tes == null) { return; } var cells = tes.GetLoadedCells(); foreach (var cell in cells) { cell.CellLock.Lock(); try { foreach (var objPtr in cell.References) { var obj = objPtr.Value; TESEffectShader shader = this.ShouldGlow(obj, pos); if (shader != null && glowing.Add(obj.FormId)) { #if DEBUG_MSG NetScriptFramework.Main.WriteDebugMessage("Adding glow to " + obj.ToString()); #endif obj.PlayEffect(shader, -1.0f); } } } finally { cell.CellLock.Unlock(); } } }