board: allow placing signal on top of straght if direction matches
Dieser Commit ist enthalten in:
Ursprung
1d6929bc17
Commit
dd08ede080
@ -46,23 +46,35 @@ Board::Board(const std::weak_ptr<World>& world, std::string_view _id) :
|
|||||||
|
|
||||||
if(auto it = m_tiles.find(l); it != m_tiles.end())
|
if(auto it = m_tiles.find(l); it != m_tiles.end())
|
||||||
{
|
{
|
||||||
if(!replace && tileClassId == StraightRailTile::classId && it->second->tileId() == TileId::RailStraight) // merge to bridge
|
if(!replace)
|
||||||
{
|
{
|
||||||
const TileRotate tileRotate = it->second->rotate;
|
const TileRotate tileRotate = it->second->rotate;
|
||||||
if((tileRotate == rotate + TileRotate::Deg90 || tileRotate == rotate - TileRotate::Deg90) && deleteTile(x, y))
|
|
||||||
|
if(tileClassId == StraightRailTile::classId && it->second->tileId() == TileId::RailStraight) // merge to bridge
|
||||||
{
|
{
|
||||||
tileClassId = Bridge90RailTile::classId;
|
if((tileRotate == rotate + TileRotate::Deg90 || tileRotate == rotate - TileRotate::Deg90) && deleteTile(x, y))
|
||||||
rotate = tileRotate;
|
{
|
||||||
|
tileClassId = Bridge90RailTile::classId;
|
||||||
|
rotate = tileRotate;
|
||||||
|
}
|
||||||
|
else if((tileRotate == rotate + TileRotate::Deg45 || tileRotate == rotate + TileRotate::Deg225) && deleteTile(x, y))
|
||||||
|
{
|
||||||
|
tileClassId = Bridge45LeftRailTile::classId;
|
||||||
|
rotate = tileRotate;
|
||||||
|
}
|
||||||
|
else if((tileRotate == rotate - TileRotate::Deg45 || tileRotate == rotate - TileRotate::Deg225) && deleteTile(x, y))
|
||||||
|
{
|
||||||
|
tileClassId = Bridge45RightRailTile::classId;
|
||||||
|
rotate = tileRotate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else if((tileRotate == rotate + TileRotate::Deg45 || tileRotate == rotate + TileRotate::Deg225) && deleteTile(x, y))
|
else if(Tiles::isRailSignal(tileClassId) && // replace straight by a signal
|
||||||
|
it->second->tileId() == TileId::RailStraight &&
|
||||||
|
(tileRotate == rotate || (tileRotate + TileRotate::Deg180) == rotate) && deleteTile(x, y))
|
||||||
{
|
{
|
||||||
tileClassId = Bridge45LeftRailTile::classId;
|
// tileClassId and rotate are ok :)
|
||||||
rotate = tileRotate;
|
|
||||||
}
|
|
||||||
else if((tileRotate == rotate - TileRotate::Deg45 || tileRotate == rotate - TileRotate::Deg225) && deleteTile(x, y))
|
|
||||||
{
|
|
||||||
tileClassId = Bridge45RightRailTile::classId;
|
|
||||||
rotate = tileRotate;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -52,3 +52,10 @@ std::shared_ptr<Tile> Tiles::create(const std::shared_ptr<World>& world, std::st
|
|||||||
IF_CLASSID_CREATE(TunnelRailTile)
|
IF_CLASSID_CREATE(TunnelRailTile)
|
||||||
return std::shared_ptr<Tile>();
|
return std::shared_ptr<Tile>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Tiles::isRailSignal(std::string_view classId)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(classId == Signal2AspectRailTile::classId) ||
|
||||||
|
(classId == Signal3AspectRailTile::classId);
|
||||||
|
}
|
||||||
|
|||||||
@ -82,6 +82,8 @@ struct Tiles
|
|||||||
);
|
);
|
||||||
|
|
||||||
static std::shared_ptr<Tile> create(const std::shared_ptr<World>& world, std::string_view classId, std::string_view id = {});
|
static std::shared_ptr<Tile> create(const std::shared_ptr<World>& world, std::string_view classId, std::string_view id = {});
|
||||||
|
|
||||||
|
static bool isRailSignal(std::string_view classId);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren