Example #1
0
 public static TEx <T> Sub <T>(TEx <T> x, TEx <T> y) => x.Sub(y);
Example #2
0
 public static TEx <T> Mul <T>(tfloat x, TEx <T> y) => x.Mul(y);
Example #3
0
 private static TExV2 Box(TEx <Vector2> ex)
 {
     return(new TExV2(ex));
 }
Example #4
0
 public static TEx <T> Add <T>(TEx <T> x, TEx <T> y) => x.Add(y);
Example #5
0
 /// <summary>
 /// Lerp between two functions. The controller is not clamped.
 /// </summary>
 /// <param name="zeroBound">Lower bound for lerp controller</param>
 /// <param name="oneBound">Upper bound for lerp controller</param>
 /// <param name="controller">Lerp controller</param>
 /// <param name="f1">First function</param>
 /// <param name="f2">Second function</param>
 /// <returns></returns>
 public static TEx <T> LerpU <T>(efloat zeroBound, efloat oneBound, efloat controller, TEx <T> f1, TEx <T> f2) =>
 EEx.Resolve(zeroBound, oneBound, controller, (z, o, c) => {
     var rc = VFloat();
     return(Ex.Block(new[] { rc },
                     rc.Is(c.Sub(z).Div(o.Sub(z))),
                     rc.Mul(f2).Add(rc.Complement().Mul(f1))
                     ));
 });
Example #6
0
 /// <summary>
 /// Lerp between three functions.
 /// Between zeroBound and oneBound, lerp from the first to the second.
 /// Between zeroBound2 and oneBound2, lerp from the second to the third.
 /// </summary>
 public static TEx <T> Lerp3 <T>(efloat zeroBound, efloat oneBound,
                                 efloat zeroBound2, efloat oneBound2, efloat controller, TEx <T> f1, TEx <T> f2, TEx <T> f3) =>
 EEx.Resolve(zeroBound, oneBound, zeroBound2, oneBound2, controller, (z1, o1, z2, o2, c) =>
             Ex.Condition(c.LT(z2), Lerp(z1, o1, c, f1, f2), Lerp(z2, o2, c, f2, f3)));
Example #7
0
 /// <summary>
 /// Lerp between two functions with 0-1 as the bounds for the controller.
 /// </summary>
 public static TEx <T> Lerp01 <T>(efloat controller, TEx <T> f1, TEx <T> f2) => Lerp(E0, E1, controller, f1, f2);
Example #8
0
 /// <summary>
 /// Lerp between two functions with smoothing applied to the controller.
 /// </summary>
 public static TEx <T> LerpSmooth <T>([LookupMethod] Func <tfloat, tfloat> smoother,
                                      efloat zeroBound, efloat oneBound, efloat controller, TEx <T> f1, TEx <T> f2)
 => EEx.Resolve(zeroBound, oneBound, controller, (z, o, c) => {
     var rc = VFloat();
     return(Ex.Block(new[] { rc },
                     rc.Is(smoother(Clamp(z, o, c).Sub(z).Div(o.Sub(z)))),
                     rc.Mul(f2).Add(rc.Complement().Mul(f1))
                     ));
 });
Example #9
0
 /// <summary>
 /// Lerp between two functions.
 /// Between zeroBound and oneBound, lerp from the first to the second.
 /// Between oneBound2 and zeroBound2, lerp from the second back to the first.
 /// </summary>
 /// <param name="zeroBound">Lower bound for lerp controller</param>
 /// <param name="oneBound">Upper bound for lerp controller</param>
 /// <param name="oneBound2">Upper bound for lerp controller</param>
 /// <param name="zeroBound2">Lower bound for lerp controller</param>
 /// <param name="controller">Lerp controller</param>
 /// <param name="f1">First function (when controller leq zeroBound, return this)</param>
 /// <param name="f2">Second function (when controller geq oneBound, return this)</param>
 /// <returns></returns>
 public static TEx <T> LerpBack <T>(tfloat zeroBound, tfloat oneBound, tfloat oneBound2,
                                    tfloat zeroBound2, tfloat controller, TEx <T> f1, TEx <T> f2) =>
 Lerp3(zeroBound, oneBound, oneBound2, zeroBound2, controller, f1, f2, f1);
Example #10
0
 /// <summary>
 /// Lerp between a value for easy difficulty and lunatic difficulty.
 /// </summary>
 public static TEx <T> LerpD <T>(TEx <T> f1, TEx <T> f2) => Lerp(FixedDifficulty.Easy.Counter(),
                                                                 FixedDifficulty.Lunatic.Counter(), ExMDifficulty.Dc(), f1, f2);
Example #11
0
 /// <summary>
 /// Lerp between three functions.
 /// Between zeroBound and oneBound, lerp from the first to the second.
 /// Between oneBound and twoBound, lerp from the second to the third.
 /// </summary>
 public static TEx <T> Lerp3c <T>(tfloat zeroBound, efloat oneBound, tfloat twoBound,
                                  tfloat controller, TEx <T> f1, TEx <T> f2, TEx <T> f3) => EEx.Resolve(oneBound,
                                                                                                        ob => Lerp3(zeroBound, ob, ob, twoBound, controller, f1, f2, f3));
Example #12
0
 /// <summary>
 /// If the switcher is 1, return the result, otherwise the default value.
 /// </summary>
 public static TEx <T> If1 <T>(tfloat switcher, TEx <T> result) =>
 Ex.Condition(Ex.Equal(switcher, E1), result, Ex.Default(typeof(T)));
Example #13
0
 /// <summary>
 /// If the predicate is true, return the true branch, otherwise the false branch.
 /// </summary>
 public static TEx <T> If <T>(tbool pred, TEx <T> iftrue, TEx <T> iffalse) => Ex.Condition(pred, iftrue, iffalse);
Example #14
0
 /// <summary>
 /// Return true if the location is more than BY units (square expansion) outside of the playing field.
 /// </summary>
 public static TEx <bool> OffScreenBy(TEx <float> f, TEx <Vector2> loc) => Not(OnScreenBy(f, loc));
Example #15
0
 /// <summary>
 /// Return true if the location not within the playing field.
 /// </summary>
 public static TEx <bool> OffScreen(TEx <Vector2> loc) => Not(OnScreen(loc));