lua_Vector2.cpp 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_Vector2.h"
  4. #include "Base.h"
  5. #include "Vector2.h"
  6. namespace gameplay
  7. {
  8. void luaRegister_Vector2()
  9. {
  10. const luaL_Reg lua_members[] =
  11. {
  12. {"add", lua_Vector2_add},
  13. {"clamp", lua_Vector2_clamp},
  14. {"distance", lua_Vector2_distance},
  15. {"distanceSquared", lua_Vector2_distanceSquared},
  16. {"dot", lua_Vector2_dot},
  17. {"isOne", lua_Vector2_isOne},
  18. {"isZero", lua_Vector2_isZero},
  19. {"length", lua_Vector2_length},
  20. {"lengthSquared", lua_Vector2_lengthSquared},
  21. {"negate", lua_Vector2_negate},
  22. {"normalize", lua_Vector2_normalize},
  23. {"rotate", lua_Vector2_rotate},
  24. {"scale", lua_Vector2_scale},
  25. {"set", lua_Vector2_set},
  26. {"smooth", lua_Vector2_smooth},
  27. {"subtract", lua_Vector2_subtract},
  28. {"x", lua_Vector2_x},
  29. {"y", lua_Vector2_y},
  30. {NULL, NULL}
  31. };
  32. const luaL_Reg lua_statics[] =
  33. {
  34. {"add", lua_Vector2_static_add},
  35. {"angle", lua_Vector2_static_angle},
  36. {"clamp", lua_Vector2_static_clamp},
  37. {"dot", lua_Vector2_static_dot},
  38. {"one", lua_Vector2_static_one},
  39. {"subtract", lua_Vector2_static_subtract},
  40. {"unitX", lua_Vector2_static_unitX},
  41. {"unitY", lua_Vector2_static_unitY},
  42. {"zero", lua_Vector2_static_zero},
  43. {NULL, NULL}
  44. };
  45. std::vector<std::string> scopePath;
  46. gameplay::ScriptUtil::registerClass("Vector2", lua_members, lua_Vector2__init, lua_Vector2__gc, lua_statics, scopePath);
  47. }
  48. static Vector2* getInstance(lua_State* state)
  49. {
  50. void* userdata = luaL_checkudata(state, 1, "Vector2");
  51. luaL_argcheck(state, userdata != NULL, 1, "'Vector2' expected.");
  52. return (Vector2*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  53. }
  54. int lua_Vector2__gc(lua_State* state)
  55. {
  56. // Get the number of parameters.
  57. int paramCount = lua_gettop(state);
  58. // Attempt to match the parameters to a valid binding.
  59. switch (paramCount)
  60. {
  61. case 1:
  62. {
  63. if ((lua_type(state, 1) == LUA_TUSERDATA))
  64. {
  65. void* userdata = luaL_checkudata(state, 1, "Vector2");
  66. luaL_argcheck(state, userdata != NULL, 1, "'Vector2' expected.");
  67. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
  68. if (object->owns)
  69. {
  70. Vector2* instance = (Vector2*)object->instance;
  71. SAFE_DELETE(instance);
  72. }
  73. return 0;
  74. }
  75. lua_pushstring(state, "lua_Vector2__gc - Failed to match the given parameters to a valid function signature.");
  76. lua_error(state);
  77. break;
  78. }
  79. default:
  80. {
  81. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  82. lua_error(state);
  83. break;
  84. }
  85. }
  86. return 0;
  87. }
  88. int lua_Vector2__init(lua_State* state)
  89. {
  90. // Get the number of parameters.
  91. int paramCount = lua_gettop(state);
  92. // Attempt to match the parameters to a valid binding.
  93. switch (paramCount)
  94. {
  95. case 0:
  96. {
  97. void* returnPtr = (void*)new Vector2();
  98. if (returnPtr)
  99. {
  100. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  101. object->instance = returnPtr;
  102. object->owns = true;
  103. luaL_getmetatable(state, "Vector2");
  104. lua_setmetatable(state, -2);
  105. }
  106. else
  107. {
  108. lua_pushnil(state);
  109. }
  110. return 1;
  111. break;
  112. }
  113. case 1:
  114. {
  115. do
  116. {
  117. if ((lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TLIGHTUSERDATA))
  118. {
  119. // Get parameter 1 off the stack.
  120. gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(1);
  121. void* returnPtr = (void*)new Vector2(param1);
  122. if (returnPtr)
  123. {
  124. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  125. object->instance = returnPtr;
  126. object->owns = true;
  127. luaL_getmetatable(state, "Vector2");
  128. lua_setmetatable(state, -2);
  129. }
  130. else
  131. {
  132. lua_pushnil(state);
  133. }
  134. return 1;
  135. }
  136. } while (0);
  137. do
  138. {
  139. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL))
  140. {
  141. // Get parameter 1 off the stack.
  142. bool param1Valid;
  143. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  144. if (!param1Valid)
  145. break;
  146. void* returnPtr = (void*)new Vector2(*param1);
  147. if (returnPtr)
  148. {
  149. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  150. object->instance = returnPtr;
  151. object->owns = true;
  152. luaL_getmetatable(state, "Vector2");
  153. lua_setmetatable(state, -2);
  154. }
  155. else
  156. {
  157. lua_pushnil(state);
  158. }
  159. return 1;
  160. }
  161. } while (0);
  162. lua_pushstring(state, "lua_Vector2__init - Failed to match the given parameters to a valid function signature.");
  163. lua_error(state);
  164. break;
  165. }
  166. case 2:
  167. {
  168. do
  169. {
  170. if (lua_type(state, 1) == LUA_TNUMBER &&
  171. lua_type(state, 2) == LUA_TNUMBER)
  172. {
  173. // Get parameter 1 off the stack.
  174. float param1 = (float)luaL_checknumber(state, 1);
  175. // Get parameter 2 off the stack.
  176. float param2 = (float)luaL_checknumber(state, 2);
  177. void* returnPtr = (void*)new Vector2(param1, param2);
  178. if (returnPtr)
  179. {
  180. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  181. object->instance = returnPtr;
  182. object->owns = true;
  183. luaL_getmetatable(state, "Vector2");
  184. lua_setmetatable(state, -2);
  185. }
  186. else
  187. {
  188. lua_pushnil(state);
  189. }
  190. return 1;
  191. }
  192. } while (0);
  193. do
  194. {
  195. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  196. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  197. {
  198. // Get parameter 1 off the stack.
  199. bool param1Valid;
  200. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  201. if (!param1Valid)
  202. break;
  203. // Get parameter 2 off the stack.
  204. bool param2Valid;
  205. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  206. if (!param2Valid)
  207. break;
  208. void* returnPtr = (void*)new Vector2(*param1, *param2);
  209. if (returnPtr)
  210. {
  211. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  212. object->instance = returnPtr;
  213. object->owns = true;
  214. luaL_getmetatable(state, "Vector2");
  215. lua_setmetatable(state, -2);
  216. }
  217. else
  218. {
  219. lua_pushnil(state);
  220. }
  221. return 1;
  222. }
  223. } while (0);
  224. lua_pushstring(state, "lua_Vector2__init - Failed to match the given parameters to a valid function signature.");
  225. lua_error(state);
  226. break;
  227. }
  228. default:
  229. {
  230. lua_pushstring(state, "Invalid number of parameters (expected 0, 1 or 2).");
  231. lua_error(state);
  232. break;
  233. }
  234. }
  235. return 0;
  236. }
  237. int lua_Vector2_add(lua_State* state)
  238. {
  239. // Get the number of parameters.
  240. int paramCount = lua_gettop(state);
  241. // Attempt to match the parameters to a valid binding.
  242. switch (paramCount)
  243. {
  244. case 2:
  245. {
  246. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  247. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  248. {
  249. // Get parameter 1 off the stack.
  250. bool param1Valid;
  251. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  252. if (!param1Valid)
  253. {
  254. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  255. lua_error(state);
  256. }
  257. Vector2* instance = getInstance(state);
  258. instance->add(*param1);
  259. return 0;
  260. }
  261. lua_pushstring(state, "lua_Vector2_add - Failed to match the given parameters to a valid function signature.");
  262. lua_error(state);
  263. break;
  264. }
  265. default:
  266. {
  267. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  268. lua_error(state);
  269. break;
  270. }
  271. }
  272. return 0;
  273. }
  274. int lua_Vector2_clamp(lua_State* state)
  275. {
  276. // Get the number of parameters.
  277. int paramCount = lua_gettop(state);
  278. // Attempt to match the parameters to a valid binding.
  279. switch (paramCount)
  280. {
  281. case 3:
  282. {
  283. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  284. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  285. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  286. {
  287. // Get parameter 1 off the stack.
  288. bool param1Valid;
  289. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  290. if (!param1Valid)
  291. {
  292. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  293. lua_error(state);
  294. }
  295. // Get parameter 2 off the stack.
  296. bool param2Valid;
  297. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", true, &param2Valid);
  298. if (!param2Valid)
  299. {
  300. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  301. lua_error(state);
  302. }
  303. Vector2* instance = getInstance(state);
  304. instance->clamp(*param1, *param2);
  305. return 0;
  306. }
  307. lua_pushstring(state, "lua_Vector2_clamp - Failed to match the given parameters to a valid function signature.");
  308. lua_error(state);
  309. break;
  310. }
  311. default:
  312. {
  313. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  314. lua_error(state);
  315. break;
  316. }
  317. }
  318. return 0;
  319. }
  320. int lua_Vector2_distance(lua_State* state)
  321. {
  322. // Get the number of parameters.
  323. int paramCount = lua_gettop(state);
  324. // Attempt to match the parameters to a valid binding.
  325. switch (paramCount)
  326. {
  327. case 2:
  328. {
  329. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  330. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  331. {
  332. // Get parameter 1 off the stack.
  333. bool param1Valid;
  334. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  335. if (!param1Valid)
  336. {
  337. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  338. lua_error(state);
  339. }
  340. Vector2* instance = getInstance(state);
  341. float result = instance->distance(*param1);
  342. // Push the return value onto the stack.
  343. lua_pushnumber(state, result);
  344. return 1;
  345. }
  346. lua_pushstring(state, "lua_Vector2_distance - Failed to match the given parameters to a valid function signature.");
  347. lua_error(state);
  348. break;
  349. }
  350. default:
  351. {
  352. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  353. lua_error(state);
  354. break;
  355. }
  356. }
  357. return 0;
  358. }
  359. int lua_Vector2_distanceSquared(lua_State* state)
  360. {
  361. // Get the number of parameters.
  362. int paramCount = lua_gettop(state);
  363. // Attempt to match the parameters to a valid binding.
  364. switch (paramCount)
  365. {
  366. case 2:
  367. {
  368. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  369. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  370. {
  371. // Get parameter 1 off the stack.
  372. bool param1Valid;
  373. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  374. if (!param1Valid)
  375. {
  376. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  377. lua_error(state);
  378. }
  379. Vector2* instance = getInstance(state);
  380. float result = instance->distanceSquared(*param1);
  381. // Push the return value onto the stack.
  382. lua_pushnumber(state, result);
  383. return 1;
  384. }
  385. lua_pushstring(state, "lua_Vector2_distanceSquared - Failed to match the given parameters to a valid function signature.");
  386. lua_error(state);
  387. break;
  388. }
  389. default:
  390. {
  391. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  392. lua_error(state);
  393. break;
  394. }
  395. }
  396. return 0;
  397. }
  398. int lua_Vector2_dot(lua_State* state)
  399. {
  400. // Get the number of parameters.
  401. int paramCount = lua_gettop(state);
  402. // Attempt to match the parameters to a valid binding.
  403. switch (paramCount)
  404. {
  405. case 2:
  406. {
  407. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  408. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  409. {
  410. // Get parameter 1 off the stack.
  411. bool param1Valid;
  412. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  413. if (!param1Valid)
  414. {
  415. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  416. lua_error(state);
  417. }
  418. Vector2* instance = getInstance(state);
  419. float result = instance->dot(*param1);
  420. // Push the return value onto the stack.
  421. lua_pushnumber(state, result);
  422. return 1;
  423. }
  424. lua_pushstring(state, "lua_Vector2_dot - Failed to match the given parameters to a valid function signature.");
  425. lua_error(state);
  426. break;
  427. }
  428. default:
  429. {
  430. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  431. lua_error(state);
  432. break;
  433. }
  434. }
  435. return 0;
  436. }
  437. int lua_Vector2_isOne(lua_State* state)
  438. {
  439. // Get the number of parameters.
  440. int paramCount = lua_gettop(state);
  441. // Attempt to match the parameters to a valid binding.
  442. switch (paramCount)
  443. {
  444. case 1:
  445. {
  446. if ((lua_type(state, 1) == LUA_TUSERDATA))
  447. {
  448. Vector2* instance = getInstance(state);
  449. bool result = instance->isOne();
  450. // Push the return value onto the stack.
  451. lua_pushboolean(state, result);
  452. return 1;
  453. }
  454. lua_pushstring(state, "lua_Vector2_isOne - Failed to match the given parameters to a valid function signature.");
  455. lua_error(state);
  456. break;
  457. }
  458. default:
  459. {
  460. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  461. lua_error(state);
  462. break;
  463. }
  464. }
  465. return 0;
  466. }
  467. int lua_Vector2_isZero(lua_State* state)
  468. {
  469. // Get the number of parameters.
  470. int paramCount = lua_gettop(state);
  471. // Attempt to match the parameters to a valid binding.
  472. switch (paramCount)
  473. {
  474. case 1:
  475. {
  476. if ((lua_type(state, 1) == LUA_TUSERDATA))
  477. {
  478. Vector2* instance = getInstance(state);
  479. bool result = instance->isZero();
  480. // Push the return value onto the stack.
  481. lua_pushboolean(state, result);
  482. return 1;
  483. }
  484. lua_pushstring(state, "lua_Vector2_isZero - Failed to match the given parameters to a valid function signature.");
  485. lua_error(state);
  486. break;
  487. }
  488. default:
  489. {
  490. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  491. lua_error(state);
  492. break;
  493. }
  494. }
  495. return 0;
  496. }
  497. int lua_Vector2_length(lua_State* state)
  498. {
  499. // Get the number of parameters.
  500. int paramCount = lua_gettop(state);
  501. // Attempt to match the parameters to a valid binding.
  502. switch (paramCount)
  503. {
  504. case 1:
  505. {
  506. if ((lua_type(state, 1) == LUA_TUSERDATA))
  507. {
  508. Vector2* instance = getInstance(state);
  509. float result = instance->length();
  510. // Push the return value onto the stack.
  511. lua_pushnumber(state, result);
  512. return 1;
  513. }
  514. lua_pushstring(state, "lua_Vector2_length - Failed to match the given parameters to a valid function signature.");
  515. lua_error(state);
  516. break;
  517. }
  518. default:
  519. {
  520. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  521. lua_error(state);
  522. break;
  523. }
  524. }
  525. return 0;
  526. }
  527. int lua_Vector2_lengthSquared(lua_State* state)
  528. {
  529. // Get the number of parameters.
  530. int paramCount = lua_gettop(state);
  531. // Attempt to match the parameters to a valid binding.
  532. switch (paramCount)
  533. {
  534. case 1:
  535. {
  536. if ((lua_type(state, 1) == LUA_TUSERDATA))
  537. {
  538. Vector2* instance = getInstance(state);
  539. float result = instance->lengthSquared();
  540. // Push the return value onto the stack.
  541. lua_pushnumber(state, result);
  542. return 1;
  543. }
  544. lua_pushstring(state, "lua_Vector2_lengthSquared - Failed to match the given parameters to a valid function signature.");
  545. lua_error(state);
  546. break;
  547. }
  548. default:
  549. {
  550. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  551. lua_error(state);
  552. break;
  553. }
  554. }
  555. return 0;
  556. }
  557. int lua_Vector2_negate(lua_State* state)
  558. {
  559. // Get the number of parameters.
  560. int paramCount = lua_gettop(state);
  561. // Attempt to match the parameters to a valid binding.
  562. switch (paramCount)
  563. {
  564. case 1:
  565. {
  566. if ((lua_type(state, 1) == LUA_TUSERDATA))
  567. {
  568. Vector2* instance = getInstance(state);
  569. instance->negate();
  570. return 0;
  571. }
  572. lua_pushstring(state, "lua_Vector2_negate - Failed to match the given parameters to a valid function signature.");
  573. lua_error(state);
  574. break;
  575. }
  576. default:
  577. {
  578. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  579. lua_error(state);
  580. break;
  581. }
  582. }
  583. return 0;
  584. }
  585. int lua_Vector2_normalize(lua_State* state)
  586. {
  587. // Get the number of parameters.
  588. int paramCount = lua_gettop(state);
  589. // Attempt to match the parameters to a valid binding.
  590. switch (paramCount)
  591. {
  592. case 1:
  593. {
  594. do
  595. {
  596. if ((lua_type(state, 1) == LUA_TUSERDATA))
  597. {
  598. Vector2* instance = getInstance(state);
  599. void* returnPtr = (void*)&(instance->normalize());
  600. if (returnPtr)
  601. {
  602. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  603. object->instance = returnPtr;
  604. object->owns = false;
  605. luaL_getmetatable(state, "Vector2");
  606. lua_setmetatable(state, -2);
  607. }
  608. else
  609. {
  610. lua_pushnil(state);
  611. }
  612. return 1;
  613. }
  614. } while (0);
  615. lua_pushstring(state, "lua_Vector2_normalize - Failed to match the given parameters to a valid function signature.");
  616. lua_error(state);
  617. break;
  618. }
  619. case 2:
  620. {
  621. do
  622. {
  623. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  624. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  625. {
  626. // Get parameter 1 off the stack.
  627. bool param1Valid;
  628. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", false, &param1Valid);
  629. if (!param1Valid)
  630. break;
  631. Vector2* instance = getInstance(state);
  632. instance->normalize(param1);
  633. return 0;
  634. }
  635. } while (0);
  636. lua_pushstring(state, "lua_Vector2_normalize - Failed to match the given parameters to a valid function signature.");
  637. lua_error(state);
  638. break;
  639. }
  640. default:
  641. {
  642. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  643. lua_error(state);
  644. break;
  645. }
  646. }
  647. return 0;
  648. }
  649. int lua_Vector2_rotate(lua_State* state)
  650. {
  651. // Get the number of parameters.
  652. int paramCount = lua_gettop(state);
  653. // Attempt to match the parameters to a valid binding.
  654. switch (paramCount)
  655. {
  656. case 3:
  657. {
  658. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  659. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  660. lua_type(state, 3) == LUA_TNUMBER)
  661. {
  662. // Get parameter 1 off the stack.
  663. bool param1Valid;
  664. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  665. if (!param1Valid)
  666. {
  667. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  668. lua_error(state);
  669. }
  670. // Get parameter 2 off the stack.
  671. float param2 = (float)luaL_checknumber(state, 3);
  672. Vector2* instance = getInstance(state);
  673. instance->rotate(*param1, param2);
  674. return 0;
  675. }
  676. lua_pushstring(state, "lua_Vector2_rotate - Failed to match the given parameters to a valid function signature.");
  677. lua_error(state);
  678. break;
  679. }
  680. default:
  681. {
  682. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  683. lua_error(state);
  684. break;
  685. }
  686. }
  687. return 0;
  688. }
  689. int lua_Vector2_scale(lua_State* state)
  690. {
  691. // Get the number of parameters.
  692. int paramCount = lua_gettop(state);
  693. // Attempt to match the parameters to a valid binding.
  694. switch (paramCount)
  695. {
  696. case 2:
  697. {
  698. do
  699. {
  700. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  701. lua_type(state, 2) == LUA_TNUMBER)
  702. {
  703. // Get parameter 1 off the stack.
  704. float param1 = (float)luaL_checknumber(state, 2);
  705. Vector2* instance = getInstance(state);
  706. instance->scale(param1);
  707. return 0;
  708. }
  709. } while (0);
  710. do
  711. {
  712. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  713. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  714. {
  715. // Get parameter 1 off the stack.
  716. bool param1Valid;
  717. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  718. if (!param1Valid)
  719. break;
  720. Vector2* instance = getInstance(state);
  721. instance->scale(*param1);
  722. return 0;
  723. }
  724. } while (0);
  725. lua_pushstring(state, "lua_Vector2_scale - Failed to match the given parameters to a valid function signature.");
  726. lua_error(state);
  727. break;
  728. }
  729. default:
  730. {
  731. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  732. lua_error(state);
  733. break;
  734. }
  735. }
  736. return 0;
  737. }
  738. int lua_Vector2_set(lua_State* state)
  739. {
  740. // Get the number of parameters.
  741. int paramCount = lua_gettop(state);
  742. // Attempt to match the parameters to a valid binding.
  743. switch (paramCount)
  744. {
  745. case 2:
  746. {
  747. do
  748. {
  749. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  750. (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA))
  751. {
  752. // Get parameter 1 off the stack.
  753. gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
  754. Vector2* instance = getInstance(state);
  755. instance->set(param1);
  756. return 0;
  757. }
  758. } while (0);
  759. do
  760. {
  761. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  762. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  763. {
  764. // Get parameter 1 off the stack.
  765. bool param1Valid;
  766. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  767. if (!param1Valid)
  768. break;
  769. Vector2* instance = getInstance(state);
  770. instance->set(*param1);
  771. return 0;
  772. }
  773. } while (0);
  774. lua_pushstring(state, "lua_Vector2_set - Failed to match the given parameters to a valid function signature.");
  775. lua_error(state);
  776. break;
  777. }
  778. case 3:
  779. {
  780. do
  781. {
  782. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  783. lua_type(state, 2) == LUA_TNUMBER &&
  784. lua_type(state, 3) == LUA_TNUMBER)
  785. {
  786. // Get parameter 1 off the stack.
  787. float param1 = (float)luaL_checknumber(state, 2);
  788. // Get parameter 2 off the stack.
  789. float param2 = (float)luaL_checknumber(state, 3);
  790. Vector2* instance = getInstance(state);
  791. instance->set(param1, param2);
  792. return 0;
  793. }
  794. } while (0);
  795. do
  796. {
  797. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  798. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  799. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL))
  800. {
  801. // Get parameter 1 off the stack.
  802. bool param1Valid;
  803. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  804. if (!param1Valid)
  805. break;
  806. // Get parameter 2 off the stack.
  807. bool param2Valid;
  808. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", true, &param2Valid);
  809. if (!param2Valid)
  810. break;
  811. Vector2* instance = getInstance(state);
  812. instance->set(*param1, *param2);
  813. return 0;
  814. }
  815. } while (0);
  816. lua_pushstring(state, "lua_Vector2_set - Failed to match the given parameters to a valid function signature.");
  817. lua_error(state);
  818. break;
  819. }
  820. default:
  821. {
  822. lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
  823. lua_error(state);
  824. break;
  825. }
  826. }
  827. return 0;
  828. }
  829. int lua_Vector2_smooth(lua_State* state)
  830. {
  831. // Get the number of parameters.
  832. int paramCount = lua_gettop(state);
  833. // Attempt to match the parameters to a valid binding.
  834. switch (paramCount)
  835. {
  836. case 4:
  837. {
  838. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  839. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  840. lua_type(state, 3) == LUA_TNUMBER &&
  841. lua_type(state, 4) == LUA_TNUMBER)
  842. {
  843. // Get parameter 1 off the stack.
  844. bool param1Valid;
  845. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  846. if (!param1Valid)
  847. {
  848. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  849. lua_error(state);
  850. }
  851. // Get parameter 2 off the stack.
  852. float param2 = (float)luaL_checknumber(state, 3);
  853. // Get parameter 3 off the stack.
  854. float param3 = (float)luaL_checknumber(state, 4);
  855. Vector2* instance = getInstance(state);
  856. instance->smooth(*param1, param2, param3);
  857. return 0;
  858. }
  859. lua_pushstring(state, "lua_Vector2_smooth - Failed to match the given parameters to a valid function signature.");
  860. lua_error(state);
  861. break;
  862. }
  863. default:
  864. {
  865. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  866. lua_error(state);
  867. break;
  868. }
  869. }
  870. return 0;
  871. }
  872. int lua_Vector2_static_add(lua_State* state)
  873. {
  874. // Get the number of parameters.
  875. int paramCount = lua_gettop(state);
  876. // Attempt to match the parameters to a valid binding.
  877. switch (paramCount)
  878. {
  879. case 3:
  880. {
  881. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  882. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  883. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  884. {
  885. // Get parameter 1 off the stack.
  886. bool param1Valid;
  887. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  888. if (!param1Valid)
  889. {
  890. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  891. lua_error(state);
  892. }
  893. // Get parameter 2 off the stack.
  894. bool param2Valid;
  895. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  896. if (!param2Valid)
  897. {
  898. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  899. lua_error(state);
  900. }
  901. // Get parameter 3 off the stack.
  902. bool param3Valid;
  903. gameplay::ScriptUtil::LuaArray<Vector2> param3 = gameplay::ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false, &param3Valid);
  904. if (!param3Valid)
  905. {
  906. lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'.");
  907. lua_error(state);
  908. }
  909. Vector2::add(*param1, *param2, param3);
  910. return 0;
  911. }
  912. lua_pushstring(state, "lua_Vector2_static_add - Failed to match the given parameters to a valid function signature.");
  913. lua_error(state);
  914. break;
  915. }
  916. default:
  917. {
  918. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  919. lua_error(state);
  920. break;
  921. }
  922. }
  923. return 0;
  924. }
  925. int lua_Vector2_static_angle(lua_State* state)
  926. {
  927. // Get the number of parameters.
  928. int paramCount = lua_gettop(state);
  929. // Attempt to match the parameters to a valid binding.
  930. switch (paramCount)
  931. {
  932. case 2:
  933. {
  934. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  935. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  936. {
  937. // Get parameter 1 off the stack.
  938. bool param1Valid;
  939. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  940. if (!param1Valid)
  941. {
  942. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  943. lua_error(state);
  944. }
  945. // Get parameter 2 off the stack.
  946. bool param2Valid;
  947. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  948. if (!param2Valid)
  949. {
  950. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  951. lua_error(state);
  952. }
  953. float result = Vector2::angle(*param1, *param2);
  954. // Push the return value onto the stack.
  955. lua_pushnumber(state, result);
  956. return 1;
  957. }
  958. lua_pushstring(state, "lua_Vector2_static_angle - Failed to match the given parameters to a valid function signature.");
  959. lua_error(state);
  960. break;
  961. }
  962. default:
  963. {
  964. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  965. lua_error(state);
  966. break;
  967. }
  968. }
  969. return 0;
  970. }
  971. int lua_Vector2_static_clamp(lua_State* state)
  972. {
  973. // Get the number of parameters.
  974. int paramCount = lua_gettop(state);
  975. // Attempt to match the parameters to a valid binding.
  976. switch (paramCount)
  977. {
  978. case 4:
  979. {
  980. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  981. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  982. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
  983. (lua_type(state, 4) == LUA_TUSERDATA || lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TNIL))
  984. {
  985. // Get parameter 1 off the stack.
  986. bool param1Valid;
  987. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  988. if (!param1Valid)
  989. {
  990. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  991. lua_error(state);
  992. }
  993. // Get parameter 2 off the stack.
  994. bool param2Valid;
  995. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  996. if (!param2Valid)
  997. {
  998. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  999. lua_error(state);
  1000. }
  1001. // Get parameter 3 off the stack.
  1002. bool param3Valid;
  1003. gameplay::ScriptUtil::LuaArray<Vector2> param3 = gameplay::ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", true, &param3Valid);
  1004. if (!param3Valid)
  1005. {
  1006. lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'.");
  1007. lua_error(state);
  1008. }
  1009. // Get parameter 4 off the stack.
  1010. bool param4Valid;
  1011. gameplay::ScriptUtil::LuaArray<Vector2> param4 = gameplay::ScriptUtil::getObjectPointer<Vector2>(4, "Vector2", false, &param4Valid);
  1012. if (!param4Valid)
  1013. {
  1014. lua_pushstring(state, "Failed to convert parameter 4 to type 'Vector2'.");
  1015. lua_error(state);
  1016. }
  1017. Vector2::clamp(*param1, *param2, *param3, param4);
  1018. return 0;
  1019. }
  1020. lua_pushstring(state, "lua_Vector2_static_clamp - Failed to match the given parameters to a valid function signature.");
  1021. lua_error(state);
  1022. break;
  1023. }
  1024. default:
  1025. {
  1026. lua_pushstring(state, "Invalid number of parameters (expected 4).");
  1027. lua_error(state);
  1028. break;
  1029. }
  1030. }
  1031. return 0;
  1032. }
  1033. int lua_Vector2_static_dot(lua_State* state)
  1034. {
  1035. // Get the number of parameters.
  1036. int paramCount = lua_gettop(state);
  1037. // Attempt to match the parameters to a valid binding.
  1038. switch (paramCount)
  1039. {
  1040. case 2:
  1041. {
  1042. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1043. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1044. {
  1045. // Get parameter 1 off the stack.
  1046. bool param1Valid;
  1047. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  1048. if (!param1Valid)
  1049. {
  1050. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  1051. lua_error(state);
  1052. }
  1053. // Get parameter 2 off the stack.
  1054. bool param2Valid;
  1055. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  1056. if (!param2Valid)
  1057. {
  1058. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  1059. lua_error(state);
  1060. }
  1061. float result = Vector2::dot(*param1, *param2);
  1062. // Push the return value onto the stack.
  1063. lua_pushnumber(state, result);
  1064. return 1;
  1065. }
  1066. lua_pushstring(state, "lua_Vector2_static_dot - Failed to match the given parameters to a valid function signature.");
  1067. lua_error(state);
  1068. break;
  1069. }
  1070. default:
  1071. {
  1072. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1073. lua_error(state);
  1074. break;
  1075. }
  1076. }
  1077. return 0;
  1078. }
  1079. int lua_Vector2_static_one(lua_State* state)
  1080. {
  1081. // Get the number of parameters.
  1082. int paramCount = lua_gettop(state);
  1083. // Attempt to match the parameters to a valid binding.
  1084. switch (paramCount)
  1085. {
  1086. case 0:
  1087. {
  1088. void* returnPtr = (void*)&(Vector2::one());
  1089. if (returnPtr)
  1090. {
  1091. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1092. object->instance = returnPtr;
  1093. object->owns = false;
  1094. luaL_getmetatable(state, "Vector2");
  1095. lua_setmetatable(state, -2);
  1096. }
  1097. else
  1098. {
  1099. lua_pushnil(state);
  1100. }
  1101. return 1;
  1102. break;
  1103. }
  1104. default:
  1105. {
  1106. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1107. lua_error(state);
  1108. break;
  1109. }
  1110. }
  1111. return 0;
  1112. }
  1113. int lua_Vector2_static_subtract(lua_State* state)
  1114. {
  1115. // Get the number of parameters.
  1116. int paramCount = lua_gettop(state);
  1117. // Attempt to match the parameters to a valid binding.
  1118. switch (paramCount)
  1119. {
  1120. case 3:
  1121. {
  1122. if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
  1123. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
  1124. (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
  1125. {
  1126. // Get parameter 1 off the stack.
  1127. bool param1Valid;
  1128. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(1, "Vector2", true, &param1Valid);
  1129. if (!param1Valid)
  1130. {
  1131. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  1132. lua_error(state);
  1133. }
  1134. // Get parameter 2 off the stack.
  1135. bool param2Valid;
  1136. gameplay::ScriptUtil::LuaArray<Vector2> param2 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param2Valid);
  1137. if (!param2Valid)
  1138. {
  1139. lua_pushstring(state, "Failed to convert parameter 2 to type 'Vector2'.");
  1140. lua_error(state);
  1141. }
  1142. // Get parameter 3 off the stack.
  1143. bool param3Valid;
  1144. gameplay::ScriptUtil::LuaArray<Vector2> param3 = gameplay::ScriptUtil::getObjectPointer<Vector2>(3, "Vector2", false, &param3Valid);
  1145. if (!param3Valid)
  1146. {
  1147. lua_pushstring(state, "Failed to convert parameter 3 to type 'Vector2'.");
  1148. lua_error(state);
  1149. }
  1150. Vector2::subtract(*param1, *param2, param3);
  1151. return 0;
  1152. }
  1153. lua_pushstring(state, "lua_Vector2_static_subtract - Failed to match the given parameters to a valid function signature.");
  1154. lua_error(state);
  1155. break;
  1156. }
  1157. default:
  1158. {
  1159. lua_pushstring(state, "Invalid number of parameters (expected 3).");
  1160. lua_error(state);
  1161. break;
  1162. }
  1163. }
  1164. return 0;
  1165. }
  1166. int lua_Vector2_static_unitX(lua_State* state)
  1167. {
  1168. // Get the number of parameters.
  1169. int paramCount = lua_gettop(state);
  1170. // Attempt to match the parameters to a valid binding.
  1171. switch (paramCount)
  1172. {
  1173. case 0:
  1174. {
  1175. void* returnPtr = (void*)&(Vector2::unitX());
  1176. if (returnPtr)
  1177. {
  1178. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1179. object->instance = returnPtr;
  1180. object->owns = false;
  1181. luaL_getmetatable(state, "Vector2");
  1182. lua_setmetatable(state, -2);
  1183. }
  1184. else
  1185. {
  1186. lua_pushnil(state);
  1187. }
  1188. return 1;
  1189. break;
  1190. }
  1191. default:
  1192. {
  1193. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1194. lua_error(state);
  1195. break;
  1196. }
  1197. }
  1198. return 0;
  1199. }
  1200. int lua_Vector2_static_unitY(lua_State* state)
  1201. {
  1202. // Get the number of parameters.
  1203. int paramCount = lua_gettop(state);
  1204. // Attempt to match the parameters to a valid binding.
  1205. switch (paramCount)
  1206. {
  1207. case 0:
  1208. {
  1209. void* returnPtr = (void*)&(Vector2::unitY());
  1210. if (returnPtr)
  1211. {
  1212. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1213. object->instance = returnPtr;
  1214. object->owns = false;
  1215. luaL_getmetatable(state, "Vector2");
  1216. lua_setmetatable(state, -2);
  1217. }
  1218. else
  1219. {
  1220. lua_pushnil(state);
  1221. }
  1222. return 1;
  1223. break;
  1224. }
  1225. default:
  1226. {
  1227. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1228. lua_error(state);
  1229. break;
  1230. }
  1231. }
  1232. return 0;
  1233. }
  1234. int lua_Vector2_static_zero(lua_State* state)
  1235. {
  1236. // Get the number of parameters.
  1237. int paramCount = lua_gettop(state);
  1238. // Attempt to match the parameters to a valid binding.
  1239. switch (paramCount)
  1240. {
  1241. case 0:
  1242. {
  1243. void* returnPtr = (void*)&(Vector2::zero());
  1244. if (returnPtr)
  1245. {
  1246. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  1247. object->instance = returnPtr;
  1248. object->owns = false;
  1249. luaL_getmetatable(state, "Vector2");
  1250. lua_setmetatable(state, -2);
  1251. }
  1252. else
  1253. {
  1254. lua_pushnil(state);
  1255. }
  1256. return 1;
  1257. break;
  1258. }
  1259. default:
  1260. {
  1261. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  1262. lua_error(state);
  1263. break;
  1264. }
  1265. }
  1266. return 0;
  1267. }
  1268. int lua_Vector2_subtract(lua_State* state)
  1269. {
  1270. // Get the number of parameters.
  1271. int paramCount = lua_gettop(state);
  1272. // Attempt to match the parameters to a valid binding.
  1273. switch (paramCount)
  1274. {
  1275. case 2:
  1276. {
  1277. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  1278. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
  1279. {
  1280. // Get parameter 1 off the stack.
  1281. bool param1Valid;
  1282. gameplay::ScriptUtil::LuaArray<Vector2> param1 = gameplay::ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true, &param1Valid);
  1283. if (!param1Valid)
  1284. {
  1285. lua_pushstring(state, "Failed to convert parameter 1 to type 'Vector2'.");
  1286. lua_error(state);
  1287. }
  1288. Vector2* instance = getInstance(state);
  1289. instance->subtract(*param1);
  1290. return 0;
  1291. }
  1292. lua_pushstring(state, "lua_Vector2_subtract - Failed to match the given parameters to a valid function signature.");
  1293. lua_error(state);
  1294. break;
  1295. }
  1296. default:
  1297. {
  1298. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  1299. lua_error(state);
  1300. break;
  1301. }
  1302. }
  1303. return 0;
  1304. }
  1305. int lua_Vector2_x(lua_State* state)
  1306. {
  1307. // Validate the number of parameters.
  1308. if (lua_gettop(state) > 2)
  1309. {
  1310. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  1311. lua_error(state);
  1312. }
  1313. Vector2* instance = getInstance(state);
  1314. if (lua_gettop(state) == 2)
  1315. {
  1316. // Get parameter 2 off the stack.
  1317. float param2 = (float)luaL_checknumber(state, 2);
  1318. instance->x = param2;
  1319. return 0;
  1320. }
  1321. else
  1322. {
  1323. float result = instance->x;
  1324. // Push the return value onto the stack.
  1325. lua_pushnumber(state, result);
  1326. return 1;
  1327. }
  1328. }
  1329. int lua_Vector2_y(lua_State* state)
  1330. {
  1331. // Validate the number of parameters.
  1332. if (lua_gettop(state) > 2)
  1333. {
  1334. lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
  1335. lua_error(state);
  1336. }
  1337. Vector2* instance = getInstance(state);
  1338. if (lua_gettop(state) == 2)
  1339. {
  1340. // Get parameter 2 off the stack.
  1341. float param2 = (float)luaL_checknumber(state, 2);
  1342. instance->y = param2;
  1343. return 0;
  1344. }
  1345. else
  1346. {
  1347. float result = instance->y;
  1348. // Push the return value onto the stack.
  1349. lua_pushnumber(state, result);
  1350. return 1;
  1351. }
  1352. }
  1353. }