/// <summary> /// Creates a Nlerper. This removes any existing nlerpers and rotaters attached to the lthing. /// </summary> /// <param name="owner">What lthing was we affecting?</param> /// <param name="duration">How long are we going to nlerp?</param> /// <param name="orientDest">Destination orientation when it is finished.</param> /// <returns>The new nlerper</returns> public Nlerper CreateNlerper(LThing owner, float duration, Quaternion orientDest) { RemoveNlerper(owner); RemoveRotater(owner); Nlerper newNlerper = new Nlerper(owner, duration, orientDest); Nlerpers.TryAdd(owner, newNlerper); return newNlerper; }
/// <summary> /// Removes a nlerper but checks that the given nlerper is still in our dictionary. /// </summary> public void Remove(Nlerper nlerper) { if (Nlerpers.Values.Contains(nlerper)) { RemoveNlerper(nlerper.Owner); } }
/// <summary> /// Cleans up a nlerper when it's finished /// </summary> void Nlerper_Finished(Nlerper nlerper, LThing thing) { if (Nlerpers.Values.Contains(nlerper)) { Nlerper existing; Nlerpers.TryRemove(thing, out existing); } }
/// <summary> /// When a nlerper is finished doing its job, we want the kart to start drifting. /// This method listens for when the nlerpers finish, and if it's a nlerper we're interested in, do something with it! /// </summary> /// <param name="nlerper">keep in mind this nlerper has already been removed from LThingHelperManager</param> void NlerperFinished(Nlerper nlerper, LThing thing) { Kart kart = thing as Kart; if (kart != null) { // first see if it's a nlerper used to start off the drifting int index = startNlerpers.IndexOf(nlerper); if (index != -1) { // okay so that means we need to start actually drifting now! //kart.ForEachWheel(w => w.Friction = w.FrictionSlip); kart.StartActuallyDrifting(); // remove it startNlerpers.RemoveAt(index); } // nope else { // so now see if it's a nlerper used to finish the drifting index = stopNlerpers.IndexOf(nlerper); if (index != -1) { // now we need to finish up //kart.ForEachWheel(w => w.Friction = w.FrictionSlip); kart.FinishDrifting(); // remove it stopNlerpers.RemoveAt(index); } } } }