Maescool/Catacomb-Snatch — Issue #787: Rails and DropTraps - General issue with FloorTiles being base of every Entity
Author: jbarabbas
Created: 2012-03-05 17:47:22+00:00
State: open

Right now you can technically build rails on DropTraps. The rail will be invisible, but Droids will drive over it.

![](http://bilder.xn--ngel-5qa.de/bilder/1330967859.309256770-screenShot15.png)

The problems basically result from the fact, that the DropTrap is meant to be a tile, but in fact is a Entity for the game:

1. LevelUtils:getNewTileFromColor() will return a FloorTile for any Entity-Pixel in the map. The FloorTile is set to the map (newLevel.setTile), then LevelUtils:getNewEntityFromColor() tries to get a Entity from the pixel and adds that to the entity-map with "newLevel.addEntity".
2. Player:handleRailBuilding() just checks the current Tile. As pointed out in (1) any entity in the game is based on a FloorTile. FloorTiles for the game are always buildable.

I think a possible solution would be to add a method setBuildable to the tile class. FloorTile:isBuildable would not return *always* true but the value of a attribute "buildable", which is true by default. So nothing would change for most of the cases but we would be able to have something like this in GameMode:loadColorTile:

if(entity instanceof DropTrap){
newLevel.getTile(x,y).setBuildable(false);
}

I tried to do fix it on my own, but somehow I seem to mess up class-vars/attributes. I am sure, someone of you will do better :)