Preserve belts when placing zoomer
This commit is contained in:
parent
ea05a6e419
commit
2269c3aa76
1 changed files with 67 additions and 7 deletions
|
|
@ -492,10 +492,13 @@ namespace gmtk
|
|||
using index = index_base<vertex, util::make_uuid("vertex_index")>;
|
||||
using path_index = index_base<path_vertex, util::make_uuid("path_vertex_index")>;
|
||||
|
||||
void sink_belt(ecs::container & world, location m)
|
||||
// 1 - from center to m
|
||||
// -1 - from m to center
|
||||
// 0 - no belt
|
||||
int sink_belt(ecs::container & world, location m)
|
||||
{
|
||||
if (auto entity = world.index<index>().find(m.up()); !entity || !world.get(*entity).contains<zoomer>())
|
||||
return;
|
||||
return 0;
|
||||
|
||||
auto & index = world.index<path_index>();
|
||||
|
||||
|
|
@ -526,6 +529,8 @@ namespace gmtk
|
|||
add_belt(world, mde, ne);
|
||||
|
||||
sink_belt(world, md);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (cv.belts_from.contains(me))
|
||||
{
|
||||
|
|
@ -545,7 +550,11 @@ namespace gmtk
|
|||
add_belt(world, mde, cde);
|
||||
|
||||
sink_belt(world, md);
|
||||
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sink(ecs::container & world, location & c, location & m)
|
||||
|
|
@ -687,12 +696,63 @@ namespace gmtk
|
|||
zoomer{}
|
||||
);
|
||||
|
||||
auto c = l.down();
|
||||
auto & index = map.world->index<path_index>();
|
||||
|
||||
sink_belt(*map.world, c.left());
|
||||
sink_belt(*map.world, c.right());
|
||||
sink_belt(*map.world, c.bottom());
|
||||
sink_belt(*map.world, c.top());
|
||||
auto c = l.down();
|
||||
auto cd = c.down();
|
||||
|
||||
if (int d = sink_belt(*map.world, c.left()))
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
auto e0 = index.get(cd.moved({-i, 0}));
|
||||
auto e1 = index.get(cd.moved({-i-1, 0}));
|
||||
|
||||
if (d == 1)
|
||||
add_belt(*map.world, e0, e1);
|
||||
else
|
||||
add_belt(*map.world, e1, e0);
|
||||
}
|
||||
}
|
||||
if (int d = sink_belt(*map.world, c.right()))
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
auto e0 = index.get(cd.moved({i, 0}));
|
||||
auto e1 = index.get(cd.moved({i+1, 0}));
|
||||
|
||||
if (d == 1)
|
||||
add_belt(*map.world, e0, e1);
|
||||
else
|
||||
add_belt(*map.world, e1, e0);
|
||||
}
|
||||
}
|
||||
if (int d = sink_belt(*map.world, c.bottom()))
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
auto e0 = index.get(cd.moved({0, -i}));
|
||||
auto e1 = index.get(cd.moved({0, -i-1}));
|
||||
|
||||
if (d == 1)
|
||||
add_belt(*map.world, e0, e1);
|
||||
else
|
||||
add_belt(*map.world, e1, e0);
|
||||
}
|
||||
}
|
||||
if (int d = sink_belt(*map.world, c.top()))
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
auto e0 = index.get(cd.moved({0, i}));
|
||||
auto e1 = index.get(cd.moved({0, i+1}));
|
||||
|
||||
if (d == 1)
|
||||
add_belt(*map.world, e0, e1);
|
||||
else
|
||||
add_belt(*map.world, e1, e0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue