Beispiel #1
0
        static void TestSettersAndGetters()
        {
            Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > > testBody = makeTestBody();
            Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > > updatedBody;

            //get position
            GetField0.get getPos = new GetField0.get();
            getPos.__arg0 = testBody;
            getPos.Run();
            Tuple <float, float> p = getPos.__res.Value;

            //get velocity
            GetField3.get getVel = new GetField3.get();
            getVel.__arg0 = testBody;
            getVel.Run();
            Tuple <float, float> v = getVel.__res.Value;

            //get acceleration
            GetField5.get getAcc = new GetField5.get();
            getAcc.__arg0 = testBody;
            getAcc.Run();
            Tuple <float, float> a = getAcc.__res.Value;

            //set position
            __opComma <float, float> newPos = new __opComma <float, float>();

            newPos.__arg0 = 5f;
            newPos.__arg1 = 2.5f;
            SetField0.set setPos = new SetField0.set();
            setPos.__arg0 = testBody;
            setPos.__arg1 = newPos;
            setPos.Run();
            updatedBody = setPos.__res.Value;

            //set velocity
            __opComma <float, float> newVel = new __opComma <float, float>();

            newVel.__arg0 = 2f;
            newVel.__arg1 = 20f;
            SetField2.set setVel = new SetField2.set();
            setVel.__arg0 = updatedBody;
            setVel.__arg1 = newVel;
            setVel.Run();
            updatedBody = setVel.__res.Value;

            //set velocity
            __opComma <float, float> newAcc = new __opComma <float, float>();

            newAcc.__arg0 = 0.1f;
            newAcc.__arg1 = 10f;
            SetField5.set setAcc = new SetField5.set();
            setAcc.__arg0 = updatedBody;
            setAcc.__arg1 = newAcc;
            setAcc.Run();
            updatedBody = setAcc.__res.Value;
        }
        public void Run()
        {
            int __ruleIndex = 0;

            __res          = new __MetaCnvResult <Tuple <float, float> >();
            __res.Value    = default(Tuple <float, float>);
            __res.HasValue = false;

            switch (__ruleIndex)
            {
            case 0:
            {
                Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > > rec = default(Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > >);
                float dt = default(float);
                Tuple <float, float> field  = default(Tuple <float, float>);
                Tuple <float, float> field1 = default(Tuple <float, float>);
                rec = __arg0;
                dt  = __arg1;
                GetField3.get __tmp0 = new GetField3.get();
                __tmp0.__arg0 = rec;
                __tmp0.Run();
                if (!(__tmp0.__res.HasValue))
                {
                    goto default;
                }
                __MetaCnvResult <Tuple <float, float> > __tmp1 = __tmp0.__res;
                field = __tmp1.Value;
                ElementUpdater1.update __tmp2 = new ElementUpdater1.update();
                __tmp2.__arg0 = field;
                __tmp2.__arg1 = dt;
                __tmp2.Run();
                if (!(__tmp2.__res.HasValue))
                {
                    goto default;
                }
                __MetaCnvResult <Tuple <float, float> > __tmp3 = __tmp2.__res;
                field1         = __tmp3.Value;
                __res.HasValue = true;
                __res.Value    = field1;
                break;
            }

            default:
                break;
            }
        }
        public void Run()
        {
            int __ruleIndex = 0;

            __res          = new __MetaCnvResult <Tuple <float, float> >();
            __res.Value    = default(Tuple <float, float>);
            __res.HasValue = false;

            switch (__ruleIndex)
            {
            case 0:
            {
                Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > > body = default(Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Tuple <Tuple <float, float>, Unit> > >);
                float dt  = default(float);
                float xv  = default(float);
                float xv1 = default(float);
                float yv  = default(float);
                float yv1 = default(float);
                float xa  = default(float);
                float ya  = default(float);
                body = __arg0;
                dt   = __arg1;
                GetField3.get __tmp0 = new GetField3.get();
                __tmp0.__arg0 = body;
                __tmp0.Run();
                if (!(__tmp0.__res.HasValue))
                {
                    goto default;
                }
                __MetaCnvResult <Tuple <float, float> > __tmp1 = __tmp0.__res;
                Tuple <float, float> __tmp2 = __tmp1.Value;
                if (!(__tmp2 is __opComma <float, float>))
                {
                    goto default;
                }
                __opComma <float, float> __tmp3 = (__opComma <float, float>)__tmp2;
                xv = __tmp3.__arg0;
                yv = __tmp3.__arg1;
                GetField5.get __tmp4 = new GetField5.get();
                __tmp4.__arg0 = body;
                __tmp4.Run();
                if (!(__tmp4.__res.HasValue))
                {
                    goto default;
                }
                __MetaCnvResult <Tuple <float, float> > __tmp5 = __tmp4.__res;
                Tuple <float, float> __tmp6 = __tmp5.Value;
                if (!(__tmp6 is __opComma <float, float>))
                {
                    goto default;
                }
                __opComma <float, float> __tmp7 = (__opComma <float, float>)__tmp6;
                xa  = __tmp7.__arg0;
                ya  = __tmp7.__arg1;
                xv1 = xv + xa * dt;
                yv1 = yv + ya * dt;
                __opComma <float, float> __tmp8 = new __opComma <float, float>();
                __tmp8.__arg0  = xv1;
                __tmp8.__arg1  = yv1;
                __res.HasValue = true;
                __res.Value    = __tmp8;
                break;
            }

            default:
                break;
            }
        }