Ejemplo n.º 1
0
        public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out Core.Math.Color4 val)
        {
            val = new Core.Math.Color4();
            int top = LuaAPI.lua_gettop(L);

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

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

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

            if (Utils.LoadField(L, idx, "a"))
            {
                translator.Get(L, top + 1, out val.a);
            }
            LuaAPI.lua_pop(L, 1);
        }
Ejemplo n.º 2
0
        public static void GetEx(this ObjectTranslator t, RealStatePtr L, int index, out Core.Math.Color4 val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

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

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!PackUnpack.UnPack(buff, 0, out val))
                {
                    throw new Exception("unpack fail for Core.Math.Color4");
                }
            }
            else if (type == LuaTypes.LUA_TTABLE)
            {
                PackUnpack.UnPack(t, L, index, out val);
            }
            else
            {
                val = (Core.Math.Color4)t.objectCasters.GetCaster(typeof(Core.Math.Color4))(L, index, null);
            }
        }
Ejemplo n.º 3
0
        public static bool Pack(IntPtr buff, int offset, Core.Math.Color4 field)
        {
            if (!LuaAPI.xlua_pack_float4(buff, offset, field.r, field.g, field.b, field.a))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        public static bool UnPack(IntPtr buff, int offset, out Core.Math.Color4 field)
        {
            field = default(Core.Math.Color4);

            float r = default(float);
            float g = default(float);
            float b = default(float);
            float a = default(float);

            if (!LuaAPI.xlua_unpack_float4(buff, offset, out r, out g, out b, out a))
            {
                return(false);
            }
            field.r = r;
            field.g = g;
            field.b = b;
            field.a = a;


            return(true);
        }
Ejemplo n.º 5
0
        public static void UpdateCoreMathColor4(this ObjectTranslator t, RealStatePtr L, int index, Core.Math.Color4 val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != CoreMathColor4_TypeID)
                {
                    throw new Exception("invalid userdata for Core.Math.Color4");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!PackUnpack.Pack(buff, 0, val))
                {
                    throw new Exception("pack fail for Core.Math.Color4 ,value=" + val);
                }
            }
            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
Ejemplo n.º 6
0
        public static void PushCoreMathColor4(this ObjectTranslator t, RealStatePtr L, Core.Math.Color4 val)
        {
            if (CoreMathColor4_TypeID == -1)
            {
                bool is_first;
                CoreMathColor4_TypeID = t.getTypeId(L, typeof(Core.Math.Color4), out is_first);
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 16, CoreMathColor4_TypeID);

            if (!PackUnpack.Pack(buff, 0, val))
            {
                throw new Exception("pack fail fail for Core.Math.Color4 ,value=" + val);
            }
        }