fix: pinned photos reset texture on finding a mesh

This commit is contained in:
Sara Gerretsen 2025-11-03 16:08:08 +01:00
parent f952452b2e
commit 032408e7b2

View file

@ -5,6 +5,7 @@
#include "scene/2d/mesh_instance_2d.h"
#include "you_done_it/clue_db.h"
#include "you_done_it/conclusion_field.h"
#include "you_done_it/ydi_networking.h"
void PinnedPhoto::_bind_methods() {
BIND_PROPERTY(Variant::BOOL, can_drop);
@ -19,6 +20,7 @@ void PinnedPhoto::enter_tree() {
void PinnedPhoto::on_child_entered_tree(Node *node) {
if (MeshInstance2D * meshinst{ cast_to<MeshInstance2D>(node) }) {
this->photo_mesh = meshinst;
set_clue(get_clue()); // force reset clue to update image
}
}
@ -95,7 +97,7 @@ bool PinnedPhoto::get_can_drop() const {
void PinnedPhoto::set_clue(NetworkData::ClueID id) {
this->clue = id;
if (photo_mesh) {
if (photo_mesh && this->clue != NetworkData::CLUE_MAX) {
Ref<Texture2D> texture{ ClueDB::get_singleton()->get_clue(id)->get_image() };
if (texture.is_valid()) {
photo_mesh->set_texture(texture);