Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
 public static ExTP LSaveNearestEnemy() => b => {
     var key    = b.Ctx.NameWithSuffix("_LSaveNearestEnemyKey");
     var eid_in = ExUtils.V <int?>();
     var eid    = ExUtils.V <int>();
     var loc    = new TExV2();
     return(Ex.Block(new[] { eid_in, eid, loc },
                     eid_in.Is(Ex.Condition(FiringCtx.Contains <int>(b, key),
                                            FiringCtx.GetValue <int>(b, key).As <int?>(),
                                            Ex.Constant(null).As <int?>())
                               ),
                     Ex.IfThenElse(Enemy.findNearestSave.Of(b.loc, eid_in, eid, loc),
                                   FiringCtx.SetValue <int>(b, key, eid),
                                   loc.Is(Ex.Constant(new Vector2(0f, 50f)))
                                   ),
                     loc
                     ));
 };
Ejemplo n.º 3
0
 public Expression FCtxGet <T>(string key) => FiringCtx.GetValue <T>(this, key);