public bool AddToList(OutlineTarget target) { bool result = false; OutlineTargetListKey key = new OutlineTargetListKey(target); if (!ContainsKey(key)) { this[key] = new HashSet <OutlineTarget>(); } result = this[key].Add(target); if (result) { modeCounter[(int)key.Mode]++; if (!thicknessCounter.ContainsKey(key.Thickness)) { thicknessCounter.Add(key.Thickness, 1); } else { thicknessCounter[key.Thickness]++; } OutlinePostEffect.Add().enabled = true; } if (OnAdd != null) { OnAdd.Invoke(target); } return(result); }
public bool RemoveFromList(OutlineTarget target, bool oldMode = false, bool oldThickness = false) { bool result = false; OutlineTargetListKey key = new OutlineTargetListKey(target, oldMode, oldThickness); HashSet <OutlineTarget> targetSet = null; if (ContainsKey(key)) { targetSet = this[key]; } if (targetSet != null) { if (targetSet.Contains(target)) { result = targetSet.Remove(target); if (targetSet.Count == 0) { Remove(key); } } } if (result) { int modeInt = (int)key.Mode; modeCounter[modeInt]--; if (thicknessCounter.ContainsKey(key.Thickness)) { thicknessCounter[key.Thickness]--; if (thicknessCounter[key.Thickness] == 0) { thicknessCounter.Remove(key.Thickness); } } if (OnRemove != null) { OnRemove.Invoke(target); } if (OutlineTarget.ActiveCounter == 0) { if (OutlinePostEffect.Instance) { OutlinePostEffect.Instance.enabled = false; } } } return(result); }