Exemple #1
0
        public static void GetEx(this ObjectTranslator t, RealStatePtr L, int index, out Core.Math.Vec2 val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != CoreMathVec2_TypeID)
                {
                    throw new Exception("invalid userdata for Core.Math.Vec2");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!PackUnpack.UnPack(buff, 0, out val))
                {
                    throw new Exception("unpack fail for Core.Math.Vec2");
                }
            }
            else if (type == LuaTypes.LUA_TTABLE)
            {
                PackUnpack.UnPack(t, L, index, out val);
            }
            else
            {
                val = (Core.Math.Vec2)t.objectCasters.GetCaster(typeof(Core.Math.Vec2))(L, index, null);
            }
        }
Exemple #2
0
        public static bool Pack(IntPtr buff, int offset, Core.Math.Vec2 field)
        {
            if (!LuaAPI.xlua_pack_float2(buff, offset, field.x, field.y))
            {
                return(false);
            }

            return(true);
        }
Exemple #3
0
        public static void PushCoreMathVec2(this ObjectTranslator t, RealStatePtr L, Core.Math.Vec2 val)
        {
            if (CoreMathVec2_TypeID == -1)
            {
                bool is_first;
                CoreMathVec2_TypeID = t.getTypeId(L, typeof(Core.Math.Vec2), out is_first);
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 8, CoreMathVec2_TypeID);

            if (!PackUnpack.Pack(buff, 0, val))
            {
                throw new Exception("pack fail fail for Core.Math.Vec2 ,value=" + val);
            }
        }
Exemple #4
0
        public static bool UnPack(IntPtr buff, int offset, out Core.Math.Vec2 field)
        {
            field = default(Core.Math.Vec2);

            float x = default(float);
            float y = default(float);

            if (!LuaAPI.xlua_unpack_float2(buff, offset, out x, out y))
            {
                return(false);
            }
            field.x = x;
            field.y = y;


            return(true);
        }
Exemple #5
0
        public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out Core.Math.Vec2 val)
        {
            val = new Core.Math.Vec2();
            int top = LuaAPI.lua_gettop(L);

            if (Utils.LoadField(L, idx, "x"))
            {
                translator.Get(L, top + 1, out val.x);
            }
            LuaAPI.lua_pop(L, 1);

            if (Utils.LoadField(L, idx, "y"))
            {
                translator.Get(L, top + 1, out val.y);
            }
            LuaAPI.lua_pop(L, 1);
        }
        static int _m_PointToNormalized_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    Core.Math.Rect rectangle; translator.Get(L, 1, out rectangle);
                    Core.Math.Vec2 point; translator.Get(L, 2, out point);

                    Core.Math.Vec2 __cl_gen_ret = Core.Math.Rect.PointToNormalized(rectangle, point);
                    translator.PushCoreMathVec2(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
Exemple #7
0
        public static void UpdateCoreMathVec2(this ObjectTranslator t, RealStatePtr L, int index, Core.Math.Vec2 val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != CoreMathVec2_TypeID)
                {
                    throw new Exception("invalid userdata for Core.Math.Vec2");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!PackUnpack.Pack(buff, 0, val))
                {
                    throw new Exception("pack fail for Core.Math.Vec2 ,value=" + val);
                }
            }
            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }