var/list/dir_to_bitflag = list(1,16,0,4,2,8,0,64,128,32)
var
	const
		DD_N=1
		DD_S=16
		DD_NS=0
		DD_E=4
		DD_NE=2
		DD_SE=8
		DD_SW=32
		DD_NW=128
		DD_W=64
/*
turf
	var
		blocked_dirs
	Enter(atom/movable/o)
		.=..()
		var/d = get_dir(src,o)
		usr << d
		if(d && (dir_to_bitflag[d] & blocked_dirs))
			return 0
*/
turf
	var BlockedEntry = 0, BlockedExit = 0, BlockedEntrySpec=0, BlockedExitSpec=0, ComplexEntry, ComplexExit, Shift_X=0,Shift_Y=0

	Enter(atom/movable/o)
		.=..()
		if(!o.loc) return 1
		if(.==1&&o)
			if(BlockedEntrySpec||(o.loc? o.loc:BlockedExitSpec : 0)) // Only really used for corner tiles. Simple solution doesn't let it work with basic blocks.
				.=( !(density||o.density) || !(o.dir == BlockedEntrySpec || o.dir == (o.loc? o.loc:BlockedExitSpec : 0)) )
			if(.) .=( !(density||o.density) || !(o.dir & (BlockedEntry | (o.loc? o.loc:BlockedExit : 0))) )
			if(.)
				if(ComplexEntry) .=(!(density||o.density) || !(dir_to_bitflag[o.dir] & ComplexEntry))
				if(.)
					if(o.loc:ComplexExit) .=(!(density||o.density) || !(dir_to_bitflag[o.dir] & o.loc:ComplexExit))
				//o << .
		if(.==0)
			for(var/obj/pathway/P in src)
				if(!P.density)
					.=1 // Pathways will automatically allow entry if they aren't dense.


mob
	combat
		var
			tmp
				old_shiftx=0
				old_shifty=0
		proc
			update_turf_shift()
				if(loc)
					if(loc:Shift_X!=old_shiftx||loc:Shift_Y!=old_shifty)
						animate(src,pixel_x=(pixel_x-old_shiftx)+loc:Shift_X,pixel_y=(pixel_y-old_shifty)+loc:Shift_Y,time=2)
						old_shiftx=loc:Shift_X
						old_shifty=loc:Shift_Y


obj
	var BlockedEntry = 0, BlockedExit = 0
	Cross(atom/movable/o)

		if(BlockedEntry||BlockedExit)
			return !(density||o.density) || !(o.dir & (BlockedEntry | (o.loc? o.loc:BlockedExit : 0)))
		else .=..()
	Uncross(atom/movable/o)
		if(BlockedExit&&o.density)
//			o << "BlockedExit [BlockedExit]; [!(density||o.density) || !(o.dir & ((o.loc? o.loc:BlockedExit : 0)))]"
			return !(o.dir & ((BlockedExit)))
		else .=..()


///////////////////
mob
	Move()
		..()
//		usr << usr.dir
		usr:update_turf_shift()
