mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-04-28 21:27:58 +03:00
Add the ActorListIndex to ActorExtensions
This commit is contained in:
parent
b27eb59e2b
commit
64710b537f
6 changed files with 68 additions and 3 deletions
|
@ -60,7 +60,7 @@ void ActorExtension_Free(Actor* actor) {
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto& [ id, size ] : sGlobalSizes) {
|
||||
for (auto& [id, size] : sGlobalSizes) {
|
||||
auto it = sData.find(std::make_pair(actor, id));
|
||||
if (it != sData.end()) {
|
||||
free(it->second);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <z64actor.h>
|
||||
#include <z64actor.h>
|
||||
#endif
|
||||
|
||||
typedef uint32_t ActorExtensionId;
|
||||
|
@ -24,4 +24,4 @@ void ActorExtension_Free(Actor* actor);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif //ACTOR_EXTENSION_H
|
||||
#endif // ACTOR_EXTENSION_H
|
32
soh/soh/ActorExtension/ActorListIndex.cpp
Normal file
32
soh/soh/ActorExtension/ActorListIndex.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "ActorListIndex.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
|
||||
ActorExtensionId actorListIndexActorExt = 0;
|
||||
int16_t currentActorListIndex = -1;
|
||||
|
||||
static RegisterShipInitFunc initFunc(
|
||||
[]() {
|
||||
if (actorListIndexActorExt == 0) {
|
||||
actorListIndexActorExt = ActorExtension_CreateForAll(sizeof(int16_t));
|
||||
}
|
||||
},
|
||||
{});
|
||||
|
||||
int16_t GetActorListIndex(Actor* actor) {
|
||||
int16_t* listIndex = (int16_t*)ActorExtension_Get(actor, actorListIndexActorExt);
|
||||
if (listIndex == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
return *listIndex;
|
||||
}
|
||||
|
||||
void SetActorListIndex(Actor* actor, int16_t index) {
|
||||
int16_t* listIndex = (int16_t*)ActorExtension_Get(actor, actorListIndexActorExt);
|
||||
|
||||
if (listIndex == nullptr) {
|
||||
assert(false);
|
||||
} else {
|
||||
*listIndex = index;
|
||||
}
|
||||
}
|
22
soh/soh/ActorExtension/ActorListIndex.h
Normal file
22
soh/soh/ActorExtension/ActorListIndex.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef ACTOR_LIST_INDEX_H
|
||||
#define ACTOR_LIST_INDEX_H
|
||||
|
||||
#include <libultraship/libultraship.h>
|
||||
#include <soh/ActorExtension/ActorExtension.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include "z64actor.h"
|
||||
#endif
|
||||
|
||||
extern ActorExtensionId actorListIndexActorExt;
|
||||
extern int16_t currentActorListIndex;
|
||||
|
||||
int16_t GetActorListIndex(Actor* actor);
|
||||
void SetActorListIndex(Actor* actor, int16_t index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // ACTOR_LIST_INDEX_H
|
|
@ -26,6 +26,7 @@ extern PlayState* gPlayState;
|
|||
|
||||
#include "textures/icon_item_static/icon_item_static.h"
|
||||
#include "textures/icon_item_24_static/icon_item_24_static.h"
|
||||
#include <soh/ActorExtension/ActorListIndex.h>
|
||||
}
|
||||
|
||||
#define DEKUNUTS_FLOWER 10
|
||||
|
@ -924,6 +925,7 @@ void ActorViewerWindow::DrawElement() {
|
|||
ImGui::Text("Category: %s", acMapping[display->category]);
|
||||
ImGui::Text("ID: %d", display->id);
|
||||
ImGui::Text("Parameters: %d", display->params);
|
||||
ImGui::Text("Actor List Index: %d", GetActorListIndex(display));
|
||||
},
|
||||
"Selected Actor");
|
||||
ImGui::SameLine();
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
#include "textures/place_title_cards/g_pn_56.h"
|
||||
#include "textures/place_title_cards/g_pn_57.h"
|
||||
#endif
|
||||
#include <soh/ActorExtension/ActorListIndex.h>
|
||||
|
||||
static CollisionPoly* sCurCeilingPoly;
|
||||
static s32 sCurCeilingBgId;
|
||||
|
@ -2575,8 +2576,14 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
|
|||
if (play->numSetupActors != 0) {
|
||||
actorEntry = &play->setupActorList[0];
|
||||
for (i = 0; i < play->numSetupActors; i++) {
|
||||
// #region SOH [ActorExtension] ActorListIndex tracking
|
||||
currentActorListIndex = i;
|
||||
// #endregion
|
||||
Actor_SpawnEntry(&play->actorCtx, actorEntry++, play);
|
||||
}
|
||||
// #region SOH [ActorExtension] ActorListIndex tracking
|
||||
currentActorListIndex = -1;
|
||||
// #endregion
|
||||
play->numSetupActors = 0;
|
||||
GameInteractor_ExecuteOnSceneSpawnActors();
|
||||
}
|
||||
|
@ -3355,6 +3362,8 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
|||
|
||||
// #region SOH [ActorExtension]
|
||||
ActorExtension_Alloc(actor, dbEntry->id);
|
||||
SetActorListIndex(actor, currentActorListIndex);
|
||||
currentActorListIndex = -1;
|
||||
// #endregion
|
||||
|
||||
assert(dbEntry->numLoaded < 255);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue