feat: implemented pinboard mechanic
This commit is contained in:
parent
ac70e60dc2
commit
de854910ee
7 changed files with 147 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "pinboard.h"
|
||||
#include "core/config/engine.h"
|
||||
#include "pinned_photo.h"
|
||||
|
||||
void Pinboard::_bind_methods() {
|
||||
|
|
@ -6,9 +7,30 @@ void Pinboard::_bind_methods() {
|
|||
|
||||
void Pinboard::enter_tree() {
|
||||
connect("body_entered", callable_mp(this, &self_type::on_body_entered));
|
||||
connect("body_exited", callable_mp(this, &self_type::on_body_exited));
|
||||
}
|
||||
|
||||
void Pinboard::on_body_entered(Node2D *node) {
|
||||
if (PinnedPhoto * photo{ cast_to<PinnedPhoto>(node) }) {
|
||||
photo->set_can_drop(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Pinboard::on_body_exited(Node2D *node) {
|
||||
if (PinnedPhoto * photo{ cast_to<PinnedPhoto>(node) }) {
|
||||
photo->set_can_drop(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Pinboard::_notification(int what) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
return;
|
||||
}
|
||||
switch (what) {
|
||||
default:
|
||||
return;
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
enter_tree();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue