Make Custom Tunic Local (#6065)
* Make Custom Tunic Local * Guard against Anchor * Make Pause Menu Model treated as a Local
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
#include <soh_assets.h>
|
||||
#include <objects/object_link_child/object_link_child.h>
|
||||
#include <objects/object_link_boy/object_link_boy.h>
|
||||
#include "macros.h"
|
||||
|
||||
extern "C" {
|
||||
#include "variables.h"
|
||||
#include "z64.h"
|
||||
#include "z64player.h"
|
||||
extern PlayState* gPlayState;
|
||||
}
|
||||
|
||||
extern "C" SaveContext gSaveContext;
|
||||
extern "C" u16 gEquipMasks[4];
|
||||
@@ -30,12 +38,32 @@ size_t Skeleton::GetPointerSize() {
|
||||
|
||||
std::vector<SkeletonPatchInfo> SkeletonPatcher::skeletons;
|
||||
|
||||
bool SkeletonPatcher::IsLinkSkeletonPath(const std::string& path) {
|
||||
return (sOtr + path == std::string(gLinkAdultSkel)) || (sOtr + path == std::string(gLinkChildSkel));
|
||||
}
|
||||
|
||||
bool SkeletonPatcher::IsLocalPlayerSkelAnime(SkelAnime* skelAnime) {
|
||||
if (gPlayState == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player* player = GET_PLAYER(gPlayState);
|
||||
|
||||
if (player == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PauseContext* pauseCtx = &gPlayState->pauseCtx;
|
||||
|
||||
return (skelAnime == &player->skelAnime) || (skelAnime == &player->upperSkelAnime) ||
|
||||
(skelAnime == &pauseCtx->playerSkelAnime);
|
||||
}
|
||||
|
||||
void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime) {
|
||||
SkeletonPatchInfo info;
|
||||
|
||||
info.skelAnime = skelAnime;
|
||||
|
||||
static const std::string sOtr = "__OTR__";
|
||||
info.isLocalPlayer = false;
|
||||
|
||||
if (path.starts_with(sOtr)) {
|
||||
path = path.substr(sOtr.length());
|
||||
@@ -49,6 +77,15 @@ void SkeletonPatcher::RegisterSkeleton(std::string& path, SkelAnime* skelAnime)
|
||||
info.vanillaSkeletonPath = path;
|
||||
}
|
||||
|
||||
if (IsLinkSkeletonPath(info.vanillaSkeletonPath)) {
|
||||
info.isLocalPlayer = IsLocalPlayerSkelAnime(skelAnime);
|
||||
|
||||
// Skip registering skeletons that do not belong to the local player (e.g. Anchor dummy actors)
|
||||
if (!info.isLocalPlayer) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
skeletons.push_back(info);
|
||||
}
|
||||
|
||||
@@ -88,6 +125,10 @@ void SkeletonPatcher::UpdateSkeletons() {
|
||||
|
||||
void SkeletonPatcher::UpdateCustomSkeletons() {
|
||||
for (auto skel : skeletons) {
|
||||
if (!skel.isLocalPlayer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UpdateTunicSkeletons(skel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class Skeleton : public Ship::Resource<SkeletonData> {
|
||||
struct SkeletonPatchInfo {
|
||||
SkelAnime* skelAnime;
|
||||
std::string vanillaSkeletonPath;
|
||||
bool isLocalPlayer;
|
||||
};
|
||||
|
||||
class SkeletonPatcher {
|
||||
@@ -92,8 +93,10 @@ class SkeletonPatcher {
|
||||
|
||||
private:
|
||||
inline static const std::string sOtr = "__OTR__";
|
||||
static bool IsLinkSkeletonPath(const std::string& path);
|
||||
static bool IsLocalPlayerSkelAnime(SkelAnime* skelAnime);
|
||||
static void UpdateTunicSkeletons(SkeletonPatchInfo& skel);
|
||||
static void UpdateCustomSkeletonFromPath(const std::string& skeletonPath, SkeletonPatchInfo& skel);
|
||||
};
|
||||
|
||||
} // namespace SOH
|
||||
} // namespace SOH
|
||||
|
||||
Reference in New Issue
Block a user