Added even more events

This commit is contained in:
KiritoDv 2024-12-29 01:35:27 -06:00 committed by Lywx
parent 0ca0252d61
commit c4c324fdc6
5 changed files with 166 additions and 72 deletions

View File

@ -2824,28 +2824,38 @@ void Actor_Update(Actor* this) {
}
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_ACTOR, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
if (this->obj.id != OBJ_ACTOR_ZO_RADARBUOY) {
Actor_Move(this);
}
}
break;
}
case OBJ_ACTIVE:
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_ACTOR, this) {
Actor_Move(this);
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
this->info.action(&this->obj);
}
}
break;
}
case OBJ_DYING:
case OBJ_DYING: {
CALL_CANCELLABLE_EVENT(ObjectDestroyEvent, OBJECT_TYPE_ACTOR, this) {
Actor_Move(this);
if (this->obj.status != OBJ_FREE) {
Object_Dying(this->index, this->obj.id);
}
break;
}
break;
}
}
}
void Boss_Update(Boss* this) {
@ -2872,27 +2882,36 @@ void Boss_Update(Boss* this) {
}
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_BOSS, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
Boss_Move(this);
}
break;
}
case OBJ_ACTIVE:
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_BOSS, this) {
Boss_Move(this);
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
this->info.action(&this->obj);
}
}
break;
}
case OBJ_DYING:
case OBJ_DYING: {
CALL_CANCELLABLE_EVENT(ObjectDestroyEvent, OBJECT_TYPE_BOSS, this) {
Boss_Move(this);
if (this->obj.status != OBJ_FREE) {
Object_Dying(this->index, this->obj.id);
}
}
break;
}
}
}
void Scenery_Update(Scenery* this) {
if (this->timer_4C != 0) {
@ -2900,42 +2919,56 @@ void Scenery_Update(Scenery* this) {
}
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_SCENERY, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
Scenery_Move(this);
}
break;
}
case OBJ_ACTIVE:
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_SCENERY, this) {
Scenery_Move(this);
if (this->info.action != NULL) {
this->info.action(&this->obj);
}
}
break;
}
}
}
void Sprite_Update(Sprite* this) {
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_SPRITE, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
Sprite_Move(this);
}
break;
case OBJ_ACTIVE:
}
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_SPRITE, this) {
Sprite_Move(this);
if (this->info.action != NULL) {
this->info.action(&this->obj);
}
}
break;
}
case OBJ_DYING:
case OBJ_DYING: {
CALL_CANCELLABLE_EVENT(ObjectDestroyEvent, OBJECT_TYPE_SPRITE, this) {
Sprite_Move(this);
Object_Dying(this->index, this->obj.id);
}
break;
}
}
}
void Item_Update(Item* this) {
if (this->timer_48 != 0) {
@ -2946,20 +2979,26 @@ void Item_Update(Item* this) {
}
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_ITEM, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
Item_Move(this);
}
break;
}
case OBJ_ACTIVE:
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_ITEM, this) {
Item_Move(this);
if (this->info.action != NULL) {
this->info.action(&this->obj);
}
}
break;
}
}
}
void Effect_Update(Effect* this) {
if (this->timer_50 != 0) {
@ -2967,18 +3006,25 @@ void Effect_Update(Effect* this) {
}
switch (this->obj.status) {
case OBJ_INIT:
case OBJ_INIT: {
CALL_CANCELLABLE_EVENT(ObjectInitEvent, OBJECT_TYPE_EFFECT, this) {
this->obj.status = OBJ_ACTIVE;
Object_Init(this->index, this->obj.id);
Effect_Move(this);
}
/* fallthrough */
case OBJ_ACTIVE:
}
case OBJ_ACTIVE: {
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_EFFECT, this) {
Effect_Move(this);
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
this->info.action(&this->obj);
}
}
break;
}
}
}
void TexturedLine_Update(TexturedLine* this) {
Vec3f sp44;

View File

@ -1,4 +1,5 @@
#pragma once
#include "list/EngineEvent.h"
#include "list/ActorEvent.h"
#include "list/ItemEvent.h"

View File

@ -0,0 +1,34 @@
#pragma once
#include "gfx.h"
#include "sf64object.h"
#include "port/hooks/impl/EventSystem.h"
typedef enum {
OBJECT_TYPE_ACTOR,
OBJECT_TYPE_BOSS,
OBJECT_TYPE_SCENERY,
OBJECT_TYPE_SPRITE,
OBJECT_TYPE_ITEM,
OBJECT_TYPE_EFFECT,
} ObjectEventType;
DEFINE_EVENT(ObjectInitEvent,
ObjectEventType type;
void* object;
);
DEFINE_EVENT(ObjectUpdateEvent,
ObjectEventType type;
void* object;
);
DEFINE_EVENT(ObjectDrawEvent,
ObjectEventType type;
void* object;
);
DEFINE_EVENT(ObjectDestroyEvent,
ObjectEventType type;
void* object;
);

View File

@ -158,7 +158,15 @@ void OnGameUpdatePost(IEvent* event) {
}
void PortEnhancements_Init() {
PortEnhancements_Register();
// Register event listeners
REGISTER_LISTENER(DisplayPreUpdateEvent, OnDisplayUpdatePre, EVENT_PRIORITY_NORMAL);
REGISTER_LISTENER(GamePostUpdateEvent, OnGameUpdatePost, EVENT_PRIORITY_NORMAL);
}
void PortEnhancements_Register() {
// Register engine events
REGISTER_EVENT(DisplayPreUpdateEvent);
REGISTER_EVENT(DisplayPostUpdateEvent);
@ -177,10 +185,14 @@ void PortEnhancements_Init() {
REGISTER_EVENT(DrawGlobalHUDPreEvent);
REGISTER_EVENT(DrawGlobalHUDPostEvent);
// Register item events
REGISTER_EVENT(ItemDropEvent);
REGISTER_LISTENER(DisplayPreUpdateEvent, OnDisplayUpdatePre, EVENT_PRIORITY_NORMAL);
REGISTER_LISTENER(GamePostUpdateEvent, OnGameUpdatePost, EVENT_PRIORITY_NORMAL);
// Register actor events
REGISTER_EVENT(ObjectInitEvent);
REGISTER_EVENT(ObjectUpdateEvent);
REGISTER_EVENT(ObjectDrawEvent);
REGISTER_EVENT(ObjectDestroyEvent);
}
void PortEnhancements_Exit() {

View File

@ -4,6 +4,7 @@
extern "C" {
#endif
void PortEnhancements_Register();
void PortEnhancements_Init();
void PortEnhancements_Exit();