Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
Rozelette committed Jan 24, 2024
1 parent a5ce34e commit 9f70b9b
Show file tree
Hide file tree
Showing 4 changed files with 1,122 additions and 32 deletions.
18 changes: 18 additions & 0 deletions soh/soh/ActorDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ static std::unordered_map<u16, const char*> actorDescriptions = {
};

using CallActorFunc = std::remove_pointer_t<ActorFunc>;
using CallOverrideLimbDraw = std::remove_pointer_t<OverrideLimbDraw>;
using CallPostLimbDraw = std::remove_pointer_t<PostLimbDraw>;

static void ActorInitScriptWrapper(ScriptActor* actor, PlayState* play) {
std::shared_ptr<ICompiledScript> script = ActorDB::Instance->RetrieveEntry(actor->actor.id).script;
Expand Down Expand Up @@ -510,6 +512,22 @@ static void ActorResetScriptWrapper() {
// TODO
}

s32 ActorDB::ActorOverrideLimbDrawScriptWrapper(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, ScriptActor* actor, Gfx** gfx) {
std::shared_ptr<ICompiledScript> script = ActorDB::Instance->RetrieveEntry(actor->actor.id).script;

assert(script != nullptr);

return Scripting::CallIfExists<CallOverrideLimbDraw>(script, "OverrideLimbDraw", play, limbIndex, dList, pos, rot, (void*)actor, gfx);
}

void ActorDB::ActorPostLimbDrawScriptWrapper(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, ScriptActor* actor, Gfx** gfx) {
std::shared_ptr<ICompiledScript> script = ActorDB::Instance->RetrieveEntry(actor->actor.id).script;

assert(script != nullptr);

Scripting::CallIfExists<CallPostLimbDraw>(script, "PostLimbDraw", play, limbIndex, dList, rot, (void*)actor, gfx);
}

ActorDB::ActorDB() {
db.reserve(ACTOR_NUMBER_MAX); // reserve size for all initial entries so we don't do it for each
for (const AddPair& pair : initialActorTable) {
Expand Down
4 changes: 4 additions & 0 deletions soh/soh/ActorDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class ActorDB {

static void AddBuiltInCustomActors();

static s32 ActorOverrideLimbDrawScriptWrapper(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, ScriptActor* actor, Gfx** gfx);

static void ActorPostLimbDrawScriptWrapper(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, ScriptActor* actor, Gfx** gfx);

private:
Entry& AddEntry(const std::string& name, const std::string& desc, size_t index);
Entry& AddEntry(const std::string& name, const std::string& desc, const ActorInit& init);
Expand Down
Loading

0 comments on commit 9f70b9b

Please sign in to comment.