Exploring raycasters and possibly make a little "doom like" game based on it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
raycaster/gui/guecstra.cpp

40 lines
1.3 KiB

#include "gui/guecstra.hpp"
namespace guecs {
Clickable make_action(DinkyECS::World& target, Events::GUI event) {
return {[&, event](auto ent, auto data){
// BUG: I think entityt here shifted and isn't part of the world anymore
// BUG: it's actually coming from the GUI so passing it here is wrong
// remember that ent is passed in from the UI::mouse handler
target.send<Events::GUI>(event, ent, data);
}};
}
Clickable make_action(DinkyECS::World& target, Events::GUI event, std::any data) {
return {[&, event, data](auto ent, auto){
// BUG: I think entityt here shifted and isn't part of the world anymore
// BUG: it's actually coming from the GUI so passing it here is wrong
// remember that ent is passed in from the UI::mouse handler
target.send<Events::GUI>(event, ent, data);
}};
}
DinkyECS::Entity GrabSource::grab() {
return world_entity;
}
void GrabSource::setSprite(guecs::UI& gui, DinkyECS::Entity gui_id) {
dbc::check(gui.has<guecs::Sprite>(gui_id), "GrabSource given sprite gui_id that doesn't exist");
auto& sp = gui.get<guecs::Sprite>(gui_id);
sprite = sp.sprite;
}
void GrabSource::move(sf::Vector2i pos) {
if(sprite) {
sprite->setPosition({
float(pos.x), float(pos.y)});
}
}
}