Add crossing
This commit is contained in:
parent
de3aefac44
commit
69b5bed15b
1 changed files with 56 additions and 2 deletions
|
|
@ -191,6 +191,11 @@ namespace gmtk
|
|||
transformer_type type;
|
||||
};
|
||||
|
||||
struct crossing
|
||||
{
|
||||
psemek_ecs_declare_uuid("crossing")
|
||||
};
|
||||
|
||||
struct zoomer
|
||||
{
|
||||
psemek_ecs_declare_uuid("zoomer")
|
||||
|
|
@ -525,6 +530,17 @@ namespace gmtk
|
|||
draw_transformer(v.location, t.type, false);
|
||||
});
|
||||
|
||||
map.world.apply<vertex const, crossing const>([&](vertex const & v, crossing const &)
|
||||
{
|
||||
auto wbox = v.location.bbox(-0.2f);
|
||||
auto sbox = v.location.bbox(-0.3f);
|
||||
|
||||
gfx::color_rgba color{64, 64, 64, 255};
|
||||
|
||||
painter.rect({wbox[0], sbox[1]}, color);
|
||||
painter.rect({sbox[0], wbox[1]}, color);
|
||||
});
|
||||
|
||||
map.world.apply<vertex const, lab const>([&](vertex const & v, lab const & l)
|
||||
{
|
||||
painter.rect(v.location.bbox(-0.2f), {128, 192, 255, 255});
|
||||
|
|
@ -748,6 +764,17 @@ namespace gmtk
|
|||
}
|
||||
}
|
||||
|
||||
if (event.down && event.key == app::keycode::T)
|
||||
{
|
||||
if (selected_ && !map_.world.index<index>().find(*selected_))
|
||||
{
|
||||
map_.world.create(
|
||||
vertex{*selected_},
|
||||
crossing{}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.down && event.key == app::keycode::Z)
|
||||
{
|
||||
if (selected_ && !map_.world.index<index>().find(*selected_))
|
||||
|
|
@ -892,8 +919,8 @@ namespace gmtk
|
|||
if (i.target)
|
||||
{
|
||||
{
|
||||
auto & v = map_.world.get(map_.world.index<path_index>().get(i.start)).get<path_vertex const>();
|
||||
if (!v.belts_to.contains(i.target))
|
||||
auto & v = map_.world.get(i.target).get<path_vertex const>();
|
||||
if (v.belts_from.empty() && v.belts_to.empty())
|
||||
{
|
||||
map_.world.detach<occupied>(i.target);
|
||||
map_.world.destroy(entity);
|
||||
|
|
@ -933,6 +960,33 @@ namespace gmtk
|
|||
return;
|
||||
}
|
||||
|
||||
if (map_.world.get(*cell).contains<crossing>())
|
||||
{
|
||||
auto c = i.start.up().down();
|
||||
auto d = c.coords - i.start.coords;
|
||||
auto n = c.moved(d);
|
||||
|
||||
auto & index = map_.world.index<path_index>();
|
||||
|
||||
auto se = index.get(i.start);
|
||||
auto ce = index.get(c);
|
||||
auto ne = index.get(n);
|
||||
|
||||
if (map_.world.get(se).get<path_vertex>().belts_to.contains(ce))
|
||||
{
|
||||
if (map_.world.get(ce).get<path_vertex>().belts_to.contains(ne) && !map_.world.get(ne).contains<occupied>())
|
||||
{
|
||||
i.target = ne;
|
||||
map_.world.attach(ne, occupied{entity});
|
||||
}
|
||||
else
|
||||
{
|
||||
map_.world.attach(se, occupied{entity});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (map_.world.get(*cell).get_if<transformer>())
|
||||
{
|
||||
auto se = map_.world.index<path_index>().get(i.start);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue