| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- module scripts.lua.collision;
- import bindbc.lua;
- import raylib;
- import variables;
- import graphics.effects;
- import std.conv;
- import system.debugwriteln;
- import system.config;
- import std.string;
- import std.algorithm;
- import system.init;
- import graphics.playback;
- import std.file;
- import graphics.collision;
- import audio.sfx;
- extern (C) nothrow int luaL_placeCollision(lua_State *L) {
- try {
- if (cast(int)luaL_checkinteger(L, 1) >= collisions.length) {
- collisions.length = collisions.length + cast(int)luaL_checkinteger(L, 1) + 1;
- }
- placeOBB(
- cast(int)luaL_checkinteger(L, 1),
- Vector3(
- luaL_checknumber(L, 2),
- luaL_checknumber(L, 3),
- luaL_checknumber(L, 4)
- ),
- Vector3(
- luaL_checknumber(L, 5),
- luaL_checknumber(L, 6),
- luaL_checknumber(L, 7)
- ),
- Vector3(
- luaL_checknumber(L, 8),
- luaL_checknumber(L, 9),
- luaL_checknumber(L, 10)
- ),
- );
- } catch (Exception e) {
- debugWriteln("Error placing obb: ", e.msg);
- }
- return 0;
- }
- extern (C) nothrow int luaL_moveCollision(lua_State *L) {
- if (collisions.length < cast(int)luaL_checkinteger(L, 1)) {
- collisions.length += 2;
- }
- collisions[cast(int)luaL_checkinteger(L, 1)].center = Vector3(
- luaL_checknumber(L, 2),
- luaL_checknumber(L, 3),
- luaL_checknumber(L, 4)
- );
- return 0;
- }
- extern (C) nothrow int luaL_removeAllCollisions(lua_State *L) {
- collisions.length = 2;
- return 0;
- }
- extern (C) nothrow int luaL_setPlayerCollisionIndex(lua_State *L) {
- playerCollisionIndex = cast(int)luaL_checkinteger(L, 1);
- return 0;
- }
- extern (C) nothrow int luaL_drawCollisionWires(lua_State *L) {
- try {
- for (int i = 0; i < collisions.length; i++) {
- drawWireframe(collisions[i], Colors.RED);
- }
- } catch (Exception e) {
-
- }
- return 0;
- }
- extern (C) nothrow int luaL_checkCollision(lua_State *L) {
- try {
- for (int i = 0; i < collisions.length; i++) {
- debugWriteln("collision index check: ", i);
- bool collided = checkCollisionOBBvsOBB(collisions[playerCollisionIndex], collisions[i]);
- if (collided == true) {
- lua_pushboolean(L, true);
- }
- else lua_pushboolean(L, false);
- }
- } catch (Exception e) {
- }
- return 1;
- }
- extern (C) nothrow int luaL_checkCollisionIndex(lua_State *L) {
- try {
- bool collided = checkCollisionOBBvsOBB(collisions[cast(int)luaL_checkinteger(L, 1)], collisions[cast(int)luaL_checkinteger(L, 2)]);
- if (collided == true) {
- lua_pushboolean(L, true);
- }
- else lua_pushboolean(L, false);
- } catch (Exception e) {
- }
- return 1;
- }
|