Skip to content

Commit

Permalink
Prevent twillen from crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
MunWolf committed Nov 25, 2023
1 parent ae82db8 commit 662ead4
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions projects/Randomizer/game/shops/twillen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,22 @@ namespace {

IL2CPP_INTERCEPT(SpiritShardUIItem, void, UpdateShardIcon, (app::SpiritShardUIItem * this_ptr)) {
if (is_in_shop(ShopType::Twillen)) {
auto slot = this_ptr->fields.m_spiritShard == nullptr ? nullptr : twillen_shop().slot(this_ptr->fields.m_spiritShard->fields.m_type);
auto& info = slot->active_info();

auto renderer = il2cpp::unity::get_component<app::Renderer>(this_ptr->fields.IconGO, types::Renderer::get_class());
auto is_visible = slot != nullptr && slot->visibility == SlotVisibility::Visible;
auto is_locked = slot == nullptr || slot->visibility == SlotVisibility::Locked;
GameObject::SetActive(this_ptr->fields.IconGO, is_visible);
GameObject::SetActive(this_ptr->fields.LockedGO, is_locked);
info.icon->apply(renderer);
}
else {
auto renderer = il2cpp::unity::get_component<app::Renderer>(this_ptr->fields.IconGO, types::Renderer::get_class());
core::api::graphics::textures::apply_default(renderer);
next::SpiritShardUIItem::UpdateShardIcon(this_ptr);
const auto slot = this_ptr->fields.m_spiritShard == nullptr ? nullptr : twillen_shop().slot(this_ptr->fields.m_spiritShard->fields.m_type);
if (slot == nullptr) {
const auto& info = slot->active_info();
const auto renderer = il2cpp::unity::get_component<app::Renderer>(this_ptr->fields.IconGO, types::Renderer::get_class());
const auto is_visible = slot != nullptr && slot->visibility == SlotVisibility::Visible;
const auto is_locked = slot == nullptr || slot->visibility == SlotVisibility::Locked;
GameObject::SetActive(this_ptr->fields.IconGO, is_visible);
GameObject::SetActive(this_ptr->fields.LockedGO, is_locked);
info.icon->apply(renderer);
return;
}
}

const auto renderer = il2cpp::unity::get_component<app::Renderer>(this_ptr->fields.IconGO, types::Renderer::get_class());
core::api::graphics::textures::apply_default(renderer);
next::SpiritShardUIItem::UpdateShardIcon(this_ptr);
}

IL2CPP_INTERCEPT(SpiritShardDescription, int, get_BuyCost, (app::SpiritShardDescription * this_ptr)) { return twillen_shop().slot(static_cast<app::SpiritShardType__Enum>(this_ptr->fields.InitialBuyCost))->cost.get<int>(); }
Expand Down

0 comments on commit 662ead4

Please sign in to comment.