/// <summary> /// Flag a Tweener that implements IAutoKillableTweener to be auto killed if another tween targeting the same object is played. /// Until the Tweener is either killed, or finished, it will be eligible for being automatically /// killed if another Tweener starts playing that tweens the same target object. Note that other tweener /// must implement IAutoKillableTweener as well (though doesn't have to be flagged to AutoKill). /// </summary> /// <param name="tween"></param> public static void AutoKill(Tweener tween) { if (tween == null) { throw new System.ArgumentNullException("tween"); } if (tween.Id == null) { throw new System.ArgumentException("Can only register a Tweener with a valid 'Id' for autokill."); } if (GameLoopEntry.ApplicationClosing) { return; } if (!tween.IsPlaying) { throw new System.ArgumentException("Can only register a playing Tweener for autokill."); } if (_instance == null) { _instance = Singleton.CreateSpecialInstance <SPTween>(SPECIAL_NAME, SingletonLifeCycleRule.LivesForever); } var token = new TokenPairing(tween.Id, tween.AutoKillToken); Tweener old; if (_autoKillDict.TryGetValue(token, out old) && old != tween) { old.Kill(); } _autoKillDict[token] = tween; }
private void AddReference_Imp(Tweener tween) { if (_locked) { if (_runningTweens.Contains(tween) || _toAdd.Contains(tween)) { return; } _toAdd.Add(tween); } else { if (_runningTweens.Contains(tween)) { return; } _runningTweens.Add(tween); if (tween.Id != null) { var token = new TokenPairing(tween.Id, tween.AutoKillToken); Tweener old; if (_autoKillDict.TryGetValue(token, out old) && old != tween) { old.Kill(); } } } }
private void RemoveReference_Imp(Tweener tween) { if (_locked) { if (!_runningTweens.Contains(tween)) { return; } if (_toRemove.Contains(tween)) { return; } _toRemove.Add(tween); } else { _runningTweens.Remove(tween); if (tween.Id != null && tween.IsComplete) { var token = new TokenPairing(tween.Id, tween.AutoKillToken); Tweener auto; if (_autoKillDict.TryGetValue(token, out auto) && auto == tween) { _autoKillDict.Remove(token); } } } }
/// <summary> /// Flag a Tweener that implements IAutoKillableTweener to be auto killed if another tween targeting the same object is played. /// Until the Tweener is either killed, or finished, it will be eligible for being automatically /// killed if another Tweener starts playing that tweens the same target object. Note that other tweener /// must implement IAutoKillableTweener as well (though doesn't have to be flagged to AutoKill). /// </summary> /// <param name="tween"></param> public static void AutoKill(Tweener tween) { if (tween == null) { throw new System.ArgumentNullException("tween"); } if (tween.Id == null) { throw new System.ArgumentException("Can only register a Tweener with a valid 'Id' for autokill."); } if (GameLoop.ApplicationClosing) { return; } if (!tween.IsPlaying) { throw new System.ArgumentException("Can only register a playing Tweener for autokill."); } if (_instance == null) { SPTween.Init(); } var token = new TokenPairing(tween.Id, tween.AutoKillToken); Tweener old; if (_autoKillDict.TryGetValue(token, out old) && old != tween) { old.Kill(); } _autoKillDict[token] = tween; }
private void AddReference_Imp(Tweener tween) { if (_locked) { if (_runningTweens.Contains(tween) || _toAdd.Contains(tween)) { return; } _toAdd.Add(tween); } else { if (_runningTweens.Contains(tween)) { return; } _runningTweens.Add(tween); tween.Scrub(0f); //scrub to initialize values, this way if update doesn't happen for an entire frame, we get that init value if (tween.Id != null) { var token = new TokenPairing(tween.Id, tween.AutoKillToken); Tweener old; if (_autoKillDict.TryGetValue(token, out old) && old != tween) { old.Kill(); } } } }
public static void KillAll(object id, object token) { var tk = new TokenPairing(id, token); Tweener old; if (_autoKillDict.TryGetValue(tk, out old)) { old.Kill(); _autoKillDict.Remove(tk); } }
public static bool IsActiveAutoKill(object id, object autoKillToken) { var token = new TokenPairing(id, autoKillToken); return(_autoKillDict.ContainsKey(token)); }