/*

DO NOT EDIT THIS FILE!

Features are things you see on the overworld map, like Dormeho, the static dungeons, and so on.

The main reason this file is here is for compatibility. If you want to set up a map file with four-way directional entrances, you need to make sure you
have an entrance marker for all the sides titled nameofmap_north (or east or south or west, depending on the side).

When a map exits to an overworld feature, it is done by editing marker_tag in the area exit to the feature's type;
This step is optional and I can handle hooking it up in the main game just fine if you'd rather not bother.
But if you want to do it yourself to test it out then go right ahead.

*/


mob
	var
		l_click=0
		set_se=1
		area_theme
		list
			flags=list()

proc
	goto_feature(mob/combat/user,what)
		var/obj/jump
		for(var/obj/overworld/feature/X in world)
			if(X.type==what)
				jump=X
				break
		if(jump)
			user.loc=locate(jump.x,jump.y,jump.z)

proc
	update_music(mob/combat/user)
		if(!user) return
//		world << "Update music called; [user.z]"
		for(var/obj/world_obj/music/Z)
			if(Z.z==user.z)
//				user << "[Z] was found. [Z.song!=null ? "Has a song." : "No song."]"
				play_song(user,Z.song)
				return

proc
	play_song(mob/combat/user,song)
		if(!user.client) return
		if(user.area_theme!=song)
			for(var/mob/X in list(user))
				X.area_theme=song
				Do_Play_Music(X,X.area_theme,1)
//		else
//			user << "Theme was song apparently."

mob
	combat
		Bump(atom/obs)
			if(istype(obs,/obj/overworld/feature))
				obs:f_enter(src)


obj
	overworld
		icon='overworld 2.dmi'
		land
			density=0
/*			New()
				..()
				if((text2num(icon_state) in dense_states))
					density=1*/
		feature // Teleports to a map or something.
			density=1
			var
				marker

				theme
				dir_enter=0
				list
					ex_ent=list()
			proc
				f_enter(mob/combat/user)
					if(user.l_click==1) return
					user.l_click=1
					var/list/entrances=list("Main"=marker)
					var/sel_marker
					for(var/X in ex_ent)
						if((ex_ent[X][2] in user.flags))
							entrances+=X
							entrances[X]=ex_ent[X][1]
					if(length(entrances)>1)
						var/cho=input("Please select which entrance you wish to use.","Entrance")as null|anything in entrances
						if(cho)
							sel_marker=entrances[cho]
					else
						sel_marker=entrances["Main"]
					if(dir_enter==1)
//						user << "Dir Enter"
						var/dirs=get_dir_angle4(src,user)
						var/place="north"
						if(dirs==SOUTH) place="south"
						else if(dirs==EAST) place="east"
						else if(dirs==WEST) place="west"
//						user << "place: [place], marker: [marker]"
						sel_marker="[marker]_[place]"
					user.l_click=0
					if(sel_marker)
						goto_marker(user,sel_marker)





						wo_eyes(user)
						reg_weatherse(user)
						reg_weatherscreen(user)
						update_music(user)



			pink
				name="Professor Pink's Tower"
				icon_state="67"
				marker="pink_center"
			oldironmine
				icon='overworld 3.dmi'
				icon_state="cave"
				name="Old Iron Mine"
				marker="oldironmine_in"
			cellsvich
				icon='overworld 3.dmi'
				name="Cellsvich"
				marker="cellsvich_in_main"