Merge branch 'coop' of github.com:sm64ex-coop-dev/sm64ex-coop into coop

This commit is contained in:
MysterD 2023-04-25 20:27:44 -07:00
commit bafd74dca6
10 changed files with 73 additions and 9 deletions

View file

@ -8594,6 +8594,13 @@ function obj_count_objects_with_behavior_id(behaviorId)
-- ...
end
--- @param o Object
--- @param index integer
--- @return Object
function obj_get_collided_object(o, index)
-- ...
end
--- @param objList ObjectList
--- @return Object
function obj_get_first(objList)

View file

@ -116,6 +116,27 @@
<br />
## [obj_get_collided_object](#obj_get_collided_object)
### Lua Example
`local ObjectValue = obj_get_collided_object(o, index)`
### Parameters
| Field | Type |
| ----- | ---- |
| o | [Object](structs.md#Object) |
| index | `integer` |
### Returns
[Object](structs.md#Object)
### C Prototype
`struct Object *obj_get_collided_object(struct Object *o, s16 index);`
[:arrow_up_small:](#)
<br />
## [obj_get_first](#obj_get_first)
### Lua Example

View file

@ -1601,6 +1601,7 @@
- [obj_check_hitbox_overlap](functions-5.md#obj_check_hitbox_overlap)
- [obj_check_overlap_with_hitbox_params](functions-5.md#obj_check_overlap_with_hitbox_params)
- [obj_count_objects_with_behavior_id](functions-5.md#obj_count_objects_with_behavior_id)
- [obj_get_collided_object](functions-5.md#obj_get_collided_object)
- [obj_get_first](functions-5.md#obj_get_first)
- [obj_get_first_with_behavior_id](functions-5.md#obj_get_first_with_behavior_id)
- [obj_get_first_with_behavior_id_and_field_f32](functions-5.md#obj_get_first_with_behavior_id_and_field_f32)

View file

@ -425,8 +425,13 @@ void render_game(void) {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
if (gDjuiRenderBehindHud && !gDjuiPanelPauseCreated) {
djui_render();
if (!gDjuiDisabled && gDjuiRenderBehindHud) {
djui_reset_hud_params();
create_dl_ortho_matrix();
djui_gfx_displaylist_begin();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
djui_gfx_displaylist_end();
}
render_hud();

View file

@ -260,10 +260,8 @@ void end_master_display_list(void) {
draw_profiler();
}
if (!gDjuiRenderBehindHud || gDjuiPanelPauseCreated) {
extern void djui_render(void);
djui_render();
}
extern void djui_render(void);
djui_render();
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);

View file

@ -91,7 +91,7 @@ void djui_lua_error(char* text) {
sDjuiLuaErrorTimeout = 30 * 5;
}
static void djui_reset_hud_params(void) {
void djui_reset_hud_params(void) {
djui_hud_set_resolution(RESOLUTION_DJUI);
djui_hud_set_font(FONT_NORMAL);
djui_hud_set_rotation(0, 0, 0);
@ -108,8 +108,10 @@ void djui_render(void) {
create_dl_ortho_matrix();
djui_gfx_displaylist_begin();
djui_reset_hud_params();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
if (!gDjuiRenderBehindHud) {
djui_reset_hud_params();
smlua_call_event_hooks_with_reset_func(HOOK_ON_HUD_RENDER, djui_reset_hud_params);
}
djui_panel_update();
djui_popup_update();

View file

@ -43,3 +43,4 @@ void djui_init(void);
void djui_connect_menu_open(void);
void djui_lua_error(char* text);
void djui_render(void);
void djui_reset_hud_params(void);

View file

@ -27912,6 +27912,25 @@ int smlua_func_obj_count_objects_with_behavior_id(lua_State* L) {
return 1;
}
int smlua_func_obj_get_collided_object(lua_State* L) {
if (L == NULL) { return 0; }
int top = lua_gettop(L);
if (top != 2) {
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "obj_get_collided_object", 2, top);
return 0;
}
struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_get_collided_object"); return 0; }
s16 index = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "obj_get_collided_object"); return 0; }
smlua_push_object(L, LOT_OBJECT, obj_get_collided_object(o, index));
return 1;
}
int smlua_func_obj_get_first(lua_State* L) {
if (L == NULL) { return 0; }
@ -30798,6 +30817,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "obj_check_hitbox_overlap", smlua_func_obj_check_hitbox_overlap);
smlua_bind_function(L, "obj_check_overlap_with_hitbox_params", smlua_func_obj_check_overlap_with_hitbox_params);
smlua_bind_function(L, "obj_count_objects_with_behavior_id", smlua_func_obj_count_objects_with_behavior_id);
smlua_bind_function(L, "obj_get_collided_object", smlua_func_obj_get_collided_object);
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_f32", smlua_func_obj_get_first_with_behavior_id_and_field_f32);

View file

@ -244,6 +244,13 @@ struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o
return NULL;
}
struct Object *obj_get_collided_object(struct Object *o, s16 index) {
if (o && o->numCollidedObjs != 0 && o->numCollidedObjs > index) {
return o->collidedObjs[index];
}
return NULL;
}
struct SpawnParticlesInfo* obj_get_temp_spawn_particles_info(enum ModelExtendedId modelId) {
static struct SpawnParticlesInfo sTmpSpi = { 0 };
memset(&sTmpSpi, 0, sizeof(struct SpawnParticlesInfo));

View file

@ -32,6 +32,8 @@ struct Object *obj_get_nearest_object_with_behavior_id(struct Object *o, enum Be
s32 obj_count_objects_with_behavior_id(enum BehaviorId behaviorId);
struct Object *obj_get_collided_object(struct Object *o, s16 index);
// misc obj helpers
struct SpawnParticlesInfo* obj_get_temp_spawn_particles_info(enum ModelExtendedId modelId);