Files
Paradise/code/game/objects/items/mountable_frames/mountables.dm
ComicIronic 44aa2ba225 Code rework of placing things on walls.
Stuff goes under types.
Types have procs.
Never have 500 lines of repeated code again.

I came very close to crying while editing this. You should appreciate
that.

----

This commit entirely reworks how placing things on walls work- Posters
have intentionally been left alone to reduce the amount of lines
changed. With this commit, wall-mounted objects are no longer snowflaked
into the wall file.
2015-04-19 14:29:42 -07:00

35 lines
948 B
Plaintext

/obj/item/mounted
var/list/buildon_types = list(/turf/simulated/wall)
/obj/item/mounted/afterattack(var/atom/A, mob/user, proximity_flag)
var/found_type = 0
for(var/turf_type in src.buildon_types)
if(istype(A, turf_type))
found_type = 1
break
if(found_type)
if(try_build(A, user, proximity_flag))
return do_build(A, user)
else
..()
/obj/item/mounted/proc/try_build(turf/on_wall, mob/user, proximity_flag) //checks
if(!on_wall || !user)
return
if (proximity_flag != 1) //if we aren't next to the wall
return
if (!( get_dir(on_wall,user) in cardinal))
user << "<span class='rose'>You need to be standing next to a wall to place \the [src].</span>"
return
if(gotwallitem(get_turf(user), get_dir(on_wall,user)))
user << "<span class='rose'>There's already an item on this wall!</span>"
return
return 1
/obj/item/mounted/proc/do_build(turf/on_wall, mob/user) //the buildy bit after we pass the checks
return