public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out Core.Math.Vec4 val) { val = new Core.Math.Vec4(); 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); if (Utils.LoadField(L, idx, "z")) { translator.Get(L, top + 1, out val.z); } LuaAPI.lua_pop(L, 1); if (Utils.LoadField(L, idx, "w")) { translator.Get(L, top + 1, out val.w); } LuaAPI.lua_pop(L, 1); }
public static void GetEx(this ObjectTranslator t, RealStatePtr L, int index, out Core.Math.Vec4 val) { LuaTypes type = LuaAPI.lua_type(L, index); if (type == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != CoreMathVec4_TypeID) { throw new Exception("invalid userdata for Core.Math.Vec4"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!PackUnpack.UnPack(buff, 0, out val)) { throw new Exception("unpack fail for Core.Math.Vec4"); } } else if (type == LuaTypes.LUA_TTABLE) { PackUnpack.UnPack(t, L, index, out val); } else { val = (Core.Math.Vec4)t.objectCasters.GetCaster(typeof(Core.Math.Vec4))(L, index, null); } }
public static bool Pack(IntPtr buff, int offset, Core.Math.Vec4 field) { if (!LuaAPI.xlua_pack_float4(buff, offset, field.x, field.y, field.z, field.w)) { return(false); } return(true); }
public static void PushCoreMathVec4(this ObjectTranslator t, RealStatePtr L, Core.Math.Vec4 val) { if (CoreMathVec4_TypeID == -1) { bool is_first; CoreMathVec4_TypeID = t.getTypeId(L, typeof(Core.Math.Vec4), out is_first); } IntPtr buff = LuaAPI.xlua_pushstruct(L, 16, CoreMathVec4_TypeID); if (!PackUnpack.Pack(buff, 0, val)) { throw new Exception("pack fail fail for Core.Math.Vec4 ,value=" + val); } }
public static bool UnPack(IntPtr buff, int offset, out Core.Math.Vec4 field) { field = default(Core.Math.Vec4); float x = default(float); float y = default(float); float z = default(float); float w = default(float); if (!LuaAPI.xlua_unpack_float4(buff, offset, out x, out y, out z, out w)) { return(false); } field.x = x; field.y = y; field.z = z; field.w = w; return(true); }
public static void UpdateCoreMathVec4(this ObjectTranslator t, RealStatePtr L, int index, Core.Math.Vec4 val) { if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA) { if (LuaAPI.xlua_gettypeid(L, index) != CoreMathVec4_TypeID) { throw new Exception("invalid userdata for Core.Math.Vec4"); } IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!PackUnpack.Pack(buff, 0, val)) { throw new Exception("pack fail for Core.Math.Vec4 ,value=" + val); } } else { throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index)); } }