Beispiel #1
0
    public static Entity GetTileEntity(ISimWorldReadAccessor accessor, int2 gridPosition)
    {
        GridInfo gridRect = accessor.GetSingleton <GridInfo>();

        if (!gridRect.Contains(gridPosition))
        {
            return(Entity.Null);
        }

        int2 offset = gridPosition - gridRect.TileMin;
        int  index  = offset.x + (offset.y * gridRect.Width);

        var allTiles = accessor.GetBufferReadOnly <GridTileReference>(accessor.GetSingletonEntity <GridInfo>());

        return(allTiles[index].Tile);
    }
Beispiel #2
0
 public bool IsValid(int2 tilePos)
 {
     return(_gridInfo.Contains(tilePos));
 }