mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Library/Execute: Implement ExecuteRequestKeeper (#630)
This commit is contained in:
parent
2ce9c565b3
commit
6a2bb093a3
|
|
@ -53971,14 +53971,14 @@ Address,Quality,Size,Name
|
|||
0x0000007100891bbc,O,000064,_ZN2al16ActorExecuteInfoC2EPNS_20ExecuteRequestKeeperE
|
||||
0x0000007100891bfc,O,000028,_ZN2al16ActorExecuteInfo10addUpdaterEPNS_24ExecutorActorExecuteBaseE
|
||||
0x0000007100891c18,O,000028,_ZN2al16ActorExecuteInfo9addDrawerEPNS_15ModelDrawerBaseE
|
||||
0x0000007100891c34,U,000008,_ZN2al18ExecuteRequestInfoC2Ev
|
||||
0x0000007100891c3c,U,000104,_ZN2al19ExecuteRequestTableC2Ei
|
||||
0x0000007100891ca4,U,000388,_ZN2al20ExecuteRequestKeeperC2Ei
|
||||
0x0000007100891e28,U,000140,_ZN2al20ExecuteRequestKeeper32executeRequestActorMovementAllOnEv
|
||||
0x0000007100891eb4,U,000140,_ZN2al20ExecuteRequestKeeper33executeRequestActorMovementAllOffEv
|
||||
0x0000007100891f40,U,000152,_ZN2al20ExecuteRequestKeeper28executeRequestActorDrawAllOnEv
|
||||
0x0000007100891fd8,U,000152,_ZN2al20ExecuteRequestKeeper29executeRequestActorDrawAllOffEv
|
||||
0x0000007100892070,U,000208,_ZN2al20ExecuteRequestKeeper7requestEPNS_9LiveActorEi
|
||||
0x0000007100891c34,O,000008,_ZN2al18ExecuteRequestInfoC2Ev
|
||||
0x0000007100891c3c,O,000104,_ZN2al19ExecuteRequestTableC2Ei
|
||||
0x0000007100891ca4,O,000388,_ZN2al20ExecuteRequestKeeperC2Ei
|
||||
0x0000007100891e28,O,000140,_ZN2al20ExecuteRequestKeeper32executeRequestActorMovementAllOnEv
|
||||
0x0000007100891eb4,O,000140,_ZN2al20ExecuteRequestKeeper33executeRequestActorMovementAllOffEv
|
||||
0x0000007100891f40,O,000152,_ZN2al20ExecuteRequestKeeper28executeRequestActorDrawAllOnEv
|
||||
0x0000007100891fd8,O,000152,_ZN2al20ExecuteRequestKeeper29executeRequestActorDrawAllOffEv
|
||||
0x0000007100892070,O,000208,_ZN2al20ExecuteRequestKeeper7requestEPNS_9LiveActorEi
|
||||
0x0000007100892140,U,000052,_ZN2al22ExecuteTableHolderDrawC2Ev
|
||||
0x0000007100892174,U,000100,_ZN2al22ExecuteTableHolderDrawD2Ev
|
||||
0x00000071008921d8,U,000104,_ZN2al22ExecuteTableHolderDrawD0Ev
|
||||
|
|
|
|||
|
Can't render this file because it is too large.
|
|
|
@ -15,10 +15,14 @@ public:
|
|||
|
||||
ExecuteRequestKeeper* getRequestKeeper() const { return mRequestKeeper; }
|
||||
|
||||
ModelDrawerBase* getDrawer(s32 idx) const { return mDrawers[idx]; }
|
||||
s32 getUpdaterCount() const { return mUpdaterCount; }
|
||||
|
||||
ExecutorActorExecuteBase* getUpdater(s32 idx) const { return mUpdaters[idx]; }
|
||||
|
||||
s32 getDrawerCount() const { return mDrawerCount; }
|
||||
|
||||
ModelDrawerBase* getDrawer(s32 idx) const { return mDrawers[idx]; }
|
||||
|
||||
private:
|
||||
ExecuteRequestKeeper* mRequestKeeper = nullptr;
|
||||
s32 mUpdaterCount = 0;
|
||||
|
|
|
|||
102
lib/al/Library/Execute/ExecuteRequestKeeper.cpp
Normal file
102
lib/al/Library/Execute/ExecuteRequestKeeper.cpp
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
#include "Library/Execute/ExecuteRequestKeeper.h"
|
||||
|
||||
#include "Library/Execute/ActorExecuteInfo.h"
|
||||
#include "Library/Execute/ExecutorActorExecuteBase.h"
|
||||
#include "Library/LiveActor/LiveActor.h"
|
||||
#include "Library/Model/ModelDrawerBase.h"
|
||||
#include "Library/Model/ModelKeeper.h"
|
||||
|
||||
namespace al {
|
||||
|
||||
ExecuteRequestInfo::ExecuteRequestInfo() = default;
|
||||
|
||||
ExecuteRequestTable::ExecuteRequestTable(s32 maxSize) : mMaxSize{maxSize} {
|
||||
LiveActor** actors = new LiveActor*[mMaxSize];
|
||||
|
||||
for (s64 i = 0; i != mMaxSize; i++)
|
||||
actors[i] = nullptr;
|
||||
|
||||
mRequests = actors;
|
||||
}
|
||||
|
||||
ExecuteRequestKeeper::ExecuteRequestKeeper(s32 maxSize) {
|
||||
for (s32 i = 0; i < 4; i++)
|
||||
mRequestTables[i] = new ExecuteRequestTable(maxSize);
|
||||
}
|
||||
|
||||
void ExecuteRequestKeeper::executeRequestActorMovementAllOn() {
|
||||
ExecuteRequestTable* movementOn = mRequestTables[Request_Movement];
|
||||
|
||||
for (s32 i = 0; i < movementOn->getSize(); i++) {
|
||||
LiveActor* actor = movementOn->getRequest(i);
|
||||
ActorExecuteInfo* info = actor->getExecuteInfo();
|
||||
for (s32 j = 0; j < info->getUpdaterCount(); j++)
|
||||
info->getUpdater(j)->addActor(actor);
|
||||
}
|
||||
|
||||
movementOn->clear();
|
||||
}
|
||||
|
||||
void ExecuteRequestKeeper::executeRequestActorMovementAllOff() {
|
||||
ExecuteRequestTable* movementOff = mRequestTables[Request_RemoveFromMovement];
|
||||
|
||||
for (s32 i = 0; i < movementOff->getSize(); i++) {
|
||||
LiveActor* actor = movementOff->getRequest(i);
|
||||
ActorExecuteInfo* info = actor->getExecuteInfo();
|
||||
for (s32 j = 0; j < info->getUpdaterCount(); j++)
|
||||
info->getUpdater(j)->removeActor(actor);
|
||||
}
|
||||
|
||||
movementOff->clear();
|
||||
}
|
||||
|
||||
void ExecuteRequestKeeper::executeRequestActorDrawAllOn() {
|
||||
ExecuteRequestTable* drawOn = mRequestTables[Request_Draw];
|
||||
|
||||
for (s32 i = 0; i < drawOn->getSize(); i++) {
|
||||
LiveActor* actor = drawOn->getRequest(i);
|
||||
ActorExecuteInfo* info = actor->getExecuteInfo();
|
||||
for (s32 j = 0; j < info->getDrawerCount(); j++)
|
||||
info->getDrawer(j)->addModel(actor->getModelKeeper()->getModelCtrl());
|
||||
}
|
||||
|
||||
drawOn->clear();
|
||||
}
|
||||
|
||||
void ExecuteRequestKeeper::executeRequestActorDrawAllOff() {
|
||||
ExecuteRequestTable* drawOff = mRequestTables[Request_RemoveFromDraw];
|
||||
|
||||
for (s32 i = 0; i < drawOff->getSize(); i++) {
|
||||
LiveActor* actor = drawOff->getRequest(i);
|
||||
ActorExecuteInfo* info = actor->getExecuteInfo();
|
||||
for (s32 j = 0; j < info->getDrawerCount(); j++)
|
||||
info->getDrawer(j)->removeModel(actor->getModelKeeper()->getModelCtrl());
|
||||
}
|
||||
|
||||
drawOff->clear();
|
||||
}
|
||||
|
||||
void ExecuteRequestKeeper::request(LiveActor* actor, s32 requestType) {
|
||||
ExecuteRequestTable* addRequestTable = mRequestTables[requestType];
|
||||
ExecuteRequestTable* removeRequestTable = nullptr;
|
||||
|
||||
switch (requestType) {
|
||||
case Request_Movement:
|
||||
removeRequestTable = mRequestTables[Request_RemoveFromMovement];
|
||||
break;
|
||||
case Request_RemoveFromMovement:
|
||||
removeRequestTable = mRequestTables[Request_Movement];
|
||||
break;
|
||||
case Request_Draw:
|
||||
removeRequestTable = mRequestTables[Request_RemoveFromDraw];
|
||||
break;
|
||||
case Request_RemoveFromDraw:
|
||||
removeRequestTable = mRequestTables[Request_Draw];
|
||||
break;
|
||||
}
|
||||
|
||||
removeRequestTable->removeRequest(actor);
|
||||
addRequestTable->addRequest(actor);
|
||||
}
|
||||
|
||||
} // namespace al
|
||||
|
|
@ -10,7 +10,7 @@ public:
|
|||
ExecuteRequestInfo();
|
||||
|
||||
private:
|
||||
u64 _0;
|
||||
u64 _0 = 0;
|
||||
};
|
||||
|
||||
static_assert(sizeof(ExecuteRequestInfo) == 0x8);
|
||||
|
|
@ -19,10 +19,33 @@ class ExecuteRequestTable {
|
|||
public:
|
||||
ExecuteRequestTable(s32 maxSize);
|
||||
|
||||
void addRequest(LiveActor* actor) {
|
||||
for (s32 i = 0; i < mSize; i++)
|
||||
if (mRequests[i] == actor)
|
||||
return;
|
||||
|
||||
mRequests[mSize++] = actor;
|
||||
}
|
||||
|
||||
void removeRequest(LiveActor* actor) {
|
||||
for (s32 i = 0; i < mSize; i++) {
|
||||
if (mRequests[i] == actor) {
|
||||
mRequests[i] = mRequests[mSize - 1];
|
||||
mSize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 getSize() const { return mSize; };
|
||||
|
||||
void clear() { mSize = 0; };
|
||||
|
||||
LiveActor* getRequest(s32 index) const { return mRequests[index]; };
|
||||
|
||||
private:
|
||||
s32 mCount;
|
||||
s32 mMaxSize;
|
||||
LiveActor** mRequests;
|
||||
s32 mMaxSize = 0;
|
||||
s32 mSize = 0;
|
||||
LiveActor** mRequests = nullptr;
|
||||
};
|
||||
|
||||
static_assert(sizeof(ExecuteRequestTable) == 0x10);
|
||||
|
|
@ -42,13 +65,10 @@ public:
|
|||
void executeRequestActorMovementAllOff();
|
||||
void executeRequestActorDrawAllOn();
|
||||
void executeRequestActorDrawAllOff();
|
||||
void request(LiveActor* actor, Request requestType);
|
||||
void request(LiveActor* actor, s32 requestType);
|
||||
|
||||
private:
|
||||
ExecuteRequestTable* mMovementOn;
|
||||
ExecuteRequestTable* mMovementOff;
|
||||
ExecuteRequestTable* mDrawOn;
|
||||
ExecuteRequestTable* mDrawOff;
|
||||
ExecuteRequestTable* mRequestTables[4];
|
||||
};
|
||||
|
||||
static_assert(sizeof(ExecuteRequestKeeper) == 0x20);
|
||||
|
|
|
|||
28
lib/al/Library/Execute/ExecutorActorExecuteBase.h
Normal file
28
lib/al/Library/Execute/ExecutorActorExecuteBase.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <container/seadPtrArray.h>
|
||||
|
||||
#include "Library/HostIO/HioNode.h"
|
||||
|
||||
namespace al {
|
||||
class LiveActor;
|
||||
|
||||
class ExecutorActorExecuteBase : public HioNode {
|
||||
public:
|
||||
ExecutorActorExecuteBase(const char* name);
|
||||
|
||||
void registerActor(LiveActor* actor);
|
||||
void createExecutorTable();
|
||||
void addActor(LiveActor* actor);
|
||||
void removeActor(LiveActor* actor);
|
||||
|
||||
virtual void execute() const = 0;
|
||||
|
||||
private:
|
||||
const char* mName;
|
||||
sead::PtrArray<LiveActor> mActors;
|
||||
};
|
||||
|
||||
static_assert(sizeof(ExecutorActorExecuteBase) == 0x20);
|
||||
|
||||
} // namespace al
|
||||
Loading…
Reference in a new issue