mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-01-23 05:25:01 +03:00
Added even more events
Some checks are pending
Some checks are pending
This commit is contained in:
parent
fd0cd322f8
commit
dbf9b0378f
@ -2824,27 +2824,37 @@ void Actor_Update(Actor* this) {
|
||||
}
|
||||
|
||||
switch (this->obj.status) {
|
||||
case OBJ_INIT:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
if (this->obj.id != OBJ_ACTOR_ZO_RADARBUOY) {
|
||||
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: {
|
||||
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_ACTIVE:
|
||||
Actor_Move(this);
|
||||
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
|
||||
this->info.action(&this->obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case OBJ_DYING:
|
||||
Actor_Move(this);
|
||||
if (this->obj.status != OBJ_FREE) {
|
||||
Object_Dying(this->index, this->obj.id);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2872,25 +2882,34 @@ void Boss_Update(Boss* this) {
|
||||
}
|
||||
|
||||
switch (this->obj.status) {
|
||||
case OBJ_INIT:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
Boss_Move(this);
|
||||
break;
|
||||
|
||||
case OBJ_ACTIVE:
|
||||
Boss_Move(this);
|
||||
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
|
||||
this->info.action(&this->obj);
|
||||
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_DYING:
|
||||
Boss_Move(this);
|
||||
if (this->obj.status != OBJ_FREE) {
|
||||
Object_Dying(this->index, this->obj.id);
|
||||
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: {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2900,40 +2919,54 @@ void Scenery_Update(Scenery* this) {
|
||||
}
|
||||
|
||||
switch (this->obj.status) {
|
||||
case OBJ_INIT:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
Scenery_Move(this);
|
||||
break;
|
||||
|
||||
case OBJ_ACTIVE:
|
||||
Scenery_Move(this);
|
||||
if (this->info.action != NULL) {
|
||||
this->info.action(&this->obj);
|
||||
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: {
|
||||
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:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
Sprite_Move(this);
|
||||
break;
|
||||
|
||||
case OBJ_ACTIVE:
|
||||
Sprite_Move(this);
|
||||
if (this->info.action != NULL) {
|
||||
this->info.action(&this->obj);
|
||||
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_DYING:
|
||||
Sprite_Move(this);
|
||||
Object_Dying(this->index, this->obj.id);
|
||||
}
|
||||
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: {
|
||||
CALL_CANCELLABLE_EVENT(ObjectDestroyEvent, OBJECT_TYPE_SPRITE, this) {
|
||||
Sprite_Move(this);
|
||||
Object_Dying(this->index, this->obj.id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2946,18 +2979,24 @@ void Item_Update(Item* this) {
|
||||
}
|
||||
|
||||
switch (this->obj.status) {
|
||||
case OBJ_INIT:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
Item_Move(this);
|
||||
break;
|
||||
|
||||
case OBJ_ACTIVE:
|
||||
Item_Move(this);
|
||||
if (this->info.action != NULL) {
|
||||
this->info.action(&this->obj);
|
||||
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: {
|
||||
CALL_CANCELLABLE_EVENT(ObjectUpdateEvent, OBJECT_TYPE_ITEM, this) {
|
||||
Item_Move(this);
|
||||
if (this->info.action != NULL) {
|
||||
this->info.action(&this->obj);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2967,16 +3006,23 @@ void Effect_Update(Effect* this) {
|
||||
}
|
||||
|
||||
switch (this->obj.status) {
|
||||
case OBJ_INIT:
|
||||
this->obj.status = OBJ_ACTIVE;
|
||||
Object_Init(this->index, this->obj.id);
|
||||
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:
|
||||
Effect_Move(this);
|
||||
if ((this->obj.status != OBJ_FREE) && (this->info.action != NULL)) {
|
||||
this->info.action(&this->obj);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "list/EngineEvent.h"
|
||||
#include "list/ActorEvent.h"
|
||||
#include "list/ItemEvent.h"
|
34
src/port/hooks/list/ActorEvent.h
Normal file
34
src/port/hooks/list/ActorEvent.h
Normal 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;
|
||||
);
|
@ -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() {
|
||||
|
@ -4,6 +4,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void PortEnhancements_Register();
|
||||
void PortEnhancements_Init();
|
||||
void PortEnhancements_Exit();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user