/// <summary> /// Cleans up a skidder when it's finished /// </summary> void Skidder_Finished(Skidder skidder, Kart kart) { if (Skidders.Values.Contains(skidder)) { Skidder existing; Skidders.TryRemove(kart, out existing); } }
/// <summary> /// Create a Skidder. This removes any existing skidders attached to the kart. /// </summary> /// <param name="owner">What kart are we affecting?</param> /// <param name="duration">How long the skid effect lasts</param> /// <returns>The new Skidder</returns> public Skidder CreateSkidder(Kart owner, float duration = 0.5f) { RemoveSkidder(owner); Skidder newSkidder = new Skidder(owner, duration); Skidders.TryAdd(owner, newSkidder); return newSkidder; }
/// <summary> /// Removes a skidder but checks that the given skidder is still in our dictionary. /// </summary> public void Remove(Skidder skidder) { if (Skidders.Values.Contains(skidder)) { RemoveSkidder(skidder.Owner); } }