Skip to content

Commit

Permalink
Fix body type resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Aug 4, 2024
1 parent 1750db5 commit cd6707e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
27 changes: 11 additions & 16 deletions src/App/Extensions/PuppetState/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ bool App::PuppetStateModule::Load()
HookBefore<Raw::CharacterCustomizationGenitalsController::OnAttach>(&OnAttachPuppet).OrThrow();
HookBefore<Raw::CharacterCustomizationHairstyleController::OnDetach>(&OnDetachPuppet).OrThrow();

s_baseBodyType = Red::CNamePool::Add(BaseBodyName);

return true;
}

Expand Down Expand Up @@ -141,33 +143,26 @@ App::PuppetFeetState App::PuppetStateModule::GetFeetState(const Red::WeakHandle<

Red::CName App::PuppetStateModule::GetBodyType(const Red::WeakHandle<Red::GameObject>& aPuppet)
{
if (!aPuppet)
{
return BaseBodyName;
}

const auto& bodyTags = PuppetStateModule::GetBodyTags();

if (bodyTags.empty())
if (!aPuppet || s_bodyTags.empty())
{
return BaseBodyName;
return s_baseBodyType;
}

const auto& entityTags = Raw::Entity::EntityTags::Ref(aPuppet.instance);
const auto& visualTags = Raw::Entity::VisualTags::Ref(aPuppet.instance);

if (!entityTags.IsEmpty() || !visualTags.IsEmpty())
{
for (const auto& [bodyTag, bodyType] : bodyTags)
for (const auto& [bodyTag, bodyType] : s_bodyTags)
{
if (entityTags.Contains(bodyTag))
{
return bodyType.ToString();
return bodyType;
}

if (visualTags.Contains(bodyTag))
{
return bodyType.ToString();
return bodyType;
}
}
}
Expand All @@ -176,24 +171,24 @@ Red::CName App::PuppetStateModule::GetBodyType(const Red::WeakHandle<Red::GameOb
{
const auto& morphTarget = Red::Cast<Red::entMorphTargetSkinnedMeshComponent>(component);

for (const auto& [bodyTag, bodyType] : bodyTags)
for (const auto& [bodyTag, bodyType] : s_bodyTags)
{
if (component->name == bodyTag)
{
return bodyType.ToString();
return bodyType;
}

if (morphTarget)
{
if (morphTarget->tags.Contains(bodyTag))
{
return bodyType.ToString();
return bodyType;
}
}
}
}

return BaseBodyName;
return s_baseBodyType;
}

const Core::Set<Red::CName>& App::PuppetStateModule::GetBodyTypes()
Expand Down
1 change: 1 addition & 0 deletions src/App/Extensions/PuppetState/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PuppetStateModule : public ConfigurableModuleImpl<PuppetStateConfig>
static void CreateSuffixAlias(Red::TweakDBID aSuffixID, Red::TweakDBID aAliasID);
static void ActivateSuffixRecords(const Core::Vector<Red::TweakDBID>& aSuffixIDs);

inline static Red::CName s_baseBodyType;
inline static Core::Set<Red::CName> s_bodyTypes;
inline static Core::Map<Red::CName, Red::CName> s_bodyTags;
inline static Core::Map<Red::Entity*, Red::Handle<PuppetStateHandler>> s_handlers;
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_xmakever("2.5.9")

set_project("ArchiveXL")
set_version("1.16.2", {build = "%y%m%d%H%M"})
set_version("1.16.3", {build = "%y%m%d%H%M"})

set_arch("x64")
set_languages("cxx2a")
Expand Down

0 comments on commit cd6707e

Please sign in to comment.