2024-11-10 01:56:33 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-11-11 02:11:54 +01:00
|
|
|
#include "draggable.h"
|
2024-11-28 01:08:04 +01:00
|
|
|
#include "vmath.h"
|
2024-11-12 01:42:05 +01:00
|
|
|
#include <memory>
|
2024-11-13 01:58:44 +01:00
|
|
|
|
2024-11-10 01:56:33 +01:00
|
|
|
namespace VISEQ::BASE {
|
2024-12-03 01:25:49 +01:00
|
|
|
class Connectable : public Draggable {
|
2024-11-10 01:56:33 +01:00
|
|
|
public:
|
2024-11-13 01:58:44 +01:00
|
|
|
Connectable() {}
|
|
|
|
|
Connectable(Vec2Df position) : Draggable(position) {}
|
2024-12-03 01:25:49 +01:00
|
|
|
|
|
|
|
|
std::weak_ptr<Connectable> partner;
|
|
|
|
|
|
2024-11-28 08:49:35 +01:00
|
|
|
bool new_partner = false;
|
2024-11-30 12:47:33 +01:00
|
|
|
bool connecting = false;
|
|
|
|
|
Vec2Df connecting_position;
|
2024-12-03 01:25:49 +01:00
|
|
|
|
2024-11-28 01:08:04 +01:00
|
|
|
virtual void drag(Vec2Df new_position) override {
|
2024-11-30 12:47:33 +01:00
|
|
|
connecting = true;
|
|
|
|
|
connecting_position = new_position;
|
2024-11-10 01:56:33 +01:00
|
|
|
}
|
2024-11-13 01:58:44 +01:00
|
|
|
|
|
|
|
|
void putDown() override {
|
|
|
|
|
connect();
|
|
|
|
|
Draggable::putDown();
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-12 01:42:05 +01:00
|
|
|
virtual void connect() {
|
|
|
|
|
if(picked_up){
|
2024-11-30 12:47:33 +01:00
|
|
|
connecting = false;
|
2024-11-12 01:42:05 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-30 12:47:33 +01:00
|
|
|
|
|
|
|
|
virtual void draw(){
|
|
|
|
|
if(connecting) DrawLineV(position, connecting_position, (Color){229, 181, 103, 255});
|
|
|
|
|
}
|
2024-11-10 01:56:33 +01:00
|
|
|
};
|
|
|
|
|
}
|