Exemplo n.º 1
0
 public TExSB(Expression ex) : base(ex)
 {
     bpi       = TExPI.Box(Ex.Field(ex, "bpi"));
     scale     = Ex.Field(ex, "scale");
     direction = new TExV2(Ex.Field(ex, "direction"));
     velocity  = new TExMov(Ex.Field(ex, "movement"));
 }
Exemplo n.º 2
0
        public static BlockExpression LaserRotateLerp(Ex target, Ex source, TExArgCtx bpi, Ex rate)
        {
            var         r1        = rate.Mul(ExC(ETime.FRAME_TIME));
            TExV2       v         = TExV2.Variable();
            TEx <float> ang       = ExUtils.VFloat();
            var         dirKey    = bpi.Ctx.NameWithSuffix("_LaserRotateLerpDirKey");
            var         sideKey   = bpi.Ctx.NameWithSuffix("_LaserRotateLerpSideKey");
            var         inter_ang = HighPass(ExC(0.01f), RadDiff(target, v));

            return(Ex.Block(new ParameterExpression[] { v, ang },
                            Ex.Condition(
                                bpi.FCtxHas <Vector2>(dirKey).And(bpi.t.GT0()),
                                Ex.Block(
                                    v.Is(bpi.FCtxGet <Vector2>(dirKey)),
                                    ang.Is(Ex.Condition(bpi.FCtxGet <float>(sideKey).LT0(),
                                                        RadToNeg(inter_ang),
                                                        RadToPos(inter_ang)
                                                        )),
                                    bpi.FCtxSet <Vector2>(dirKey, RotateRad(Limit(r1, ang), v))
                                    ),
                                Ex.Block(
                                    v.Is(source),
                                    ang.Is(RadDiff(target, v)),
                                    bpi.FCtxSet <float>(sideKey, Sign(ang)),
                                    bpi.FCtxSet <Vector2>(dirKey, RotateRad(Limit(r1, ang), v))
                                    )
                                )
                            ));
        }
Exemplo n.º 3
0
        public static BlockExpression RotateLerp(Ex target, Ex source, TExArgCtx bpi, bool isRate, bool isTrue, Ex rate)
        {
            if (isRate)
            {
                rate = rate.Mul(M.degRad);
            }
            if (isTrue)
            {
                rate = rate.Mul(ETime.FRAME_TIME);
            }
            TExV2       v   = TExV2.Variable();
            TEx <float> ang = ExUtils.VFloat();

            Expression[] exprs = new Expression[3];
            exprs[1] = ang.Is(RadDiff(target, v));
            if (isTrue)
            {
                var key = bpi.Ctx.NameWithSuffix("_RotateLerpKey");
                exprs[0] = v.Is(
                    Ex.Condition(FiringCtx.Contains <Vector2>(bpi, key),
                                 FiringCtx.GetValue <Vector2>(bpi, key),
                                 FiringCtx.SetValue <Vector2>(bpi, key, source)
                                 ));
                exprs[2] =
                    FiringCtx.SetValue <Vector2>(bpi, key, RotateRad(isRate ? (Ex)Limit(rate, ang) : ang.Mul(rate), v));
            }
            else
            {
                exprs[0] = v.Is(source);
                exprs[2] = RotateRad(isRate ?
                                     (Ex)Limit(bpi.t.Mul(rate), ang) :
                                     ang.Mul(Min(bpi.t.Mul(rate), E1)), v);
            }
            return(Ex.Block(new ParameterExpression[] { v, ang }, exprs));
        }
Exemplo n.º 4
0
 private Arg(string name, Type texType, TEx expr, bool hasTypePriority)
 {
     this.name            = name;
     this.texType         = texType;
     this.expr            = expr;
     this.hasTypePriority = hasTypePriority;
 }
Exemplo n.º 5
0
 protected TExSB(ExMode m, string?name) : base(m, name)
 {
     bpi       = TExPI.Box(Ex.Field(ex, "bpi"));
     scale     = Ex.Field(ex, "scale");
     direction = new TExV2(Ex.Field(ex, "direction"));
     velocity  = new TExMov(Ex.Field(ex, "movement"));
 }
Exemplo n.º 6
0
 public static Ex dLookupSinDeg(TEx <double> angleDeg) => Ex.Field(dLookupCosSinDeg(angleDeg), "y");
Exemplo n.º 7
0
 public static Ex dLookupCosSinDeg(TEx <double> angleDeg) => dLookupByIndex(dGetDegIndex(angleDeg));
Exemplo n.º 8
0
 public static Ex dLookupSinRad(TEx <double> angleRad) => Ex.Field(dLookupCosSinRad(angleRad), "y");
Exemplo n.º 9
0
 public static Ex Add <T>(this TEx <T> tex, float other) => ((Ex)tex).Add(other);
Exemplo n.º 10
0
 public static Arg Make(string name, TEx expr, bool hasTypePriority) =>
 new Arg(name, expr.GetType(), expr, hasTypePriority);
Exemplo n.º 11
0
 public static Ex Flatten(this TEx ex) => FlattenVisitor.Flatten(ex);
Exemplo n.º 12
0
 public static Ex Field <T>(this TEx <T> tex, string field) => Ex.PropertyOrField(tex, field);
Exemplo n.º 13
0
 public static Ex GT0 <T>(this TEx <T> tex) => ((Ex)tex).GT0();
Exemplo n.º 14
0
 public static Ex GT <T>(this TEx <T> tex, Ex than) => ((Ex)tex).GT(than);
Exemplo n.º 15
0
 public static Ex Div <T>(this TEx <T> tex, Ex other) => ((Ex)tex).Div(other);
Exemplo n.º 16
0
 public static Ex Sub <T>(this TEx <T> tex, Ex other) => ((Ex)tex).Sub(other);
Exemplo n.º 17
0
 public static Ex Mul <T>(this TEx <T> tex, float other) => ((Ex)tex).Mul(other);
Exemplo n.º 18
0
        public TExArgCtx Append(string name, TEx ex, bool hasPriority = true)
        {
            var newArgs = args.Append(Arg.Make(name, ex, hasPriority)).ToArray();

            return(new TExArgCtx(this, newArgs));
        }
Exemplo n.º 19
0
 private static Ex dGetRadIndex(TEx <double> angleRad) => Ex.And(angleRad.Mul(ExC(radRatio)).As <int>(), ExC(LookupMask));
Exemplo n.º 20
0
 public static bool TryAsConst <T>(this TEx <T> tex, out T val) => ((Ex)tex).TryAsConst(out val);
Exemplo n.º 21
0
            //t = typeof(float) or similar
            public static Arg Make <T>(string name, bool hasTypePriority, bool isRef = false)
            {
                var expr = TEx.MakeParameter <T>(isRef, name);

                return(Make(name, expr, hasTypePriority));
            }
Exemplo n.º 22
0
 public static Ex dLookupCosSinRad(TEx <double> angleRad) => dLookupByIndex(dGetRadIndex(angleRad));
Exemplo n.º 23
0
 private static Ex dGetDegIndex(TEx <double> angleDeg) => Ex.And(angleDeg.Mul(ExC(degRatio)).As <int>(), ExC(LookupMask));
Exemplo n.º 24
0
 public static Ex Is <T>(this TEx <T> tex, Ex other) => ((Ex)tex).Is(other);