mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 20:43:10 +01:00
Fixed APC construction (#20061)
Fixed APC construction. Cleaned up APC construction try_build() proc. Fixes #20057
This commit is contained in:
@@ -14,31 +14,59 @@
|
||||
return TRUE
|
||||
return ..()
|
||||
|
||||
/obj/item/frame/apc/try_build(turf/on_wall)
|
||||
if (get_dist(on_wall,usr)>1)
|
||||
/obj/item/frame/apc/try_build(turf/on_wall, mob/user)
|
||||
if(!istype(user))
|
||||
stack_trace("APC being built by a non-mob, somehow!")
|
||||
return
|
||||
var/ndir = get_dir(usr,on_wall)
|
||||
if (!(ndir in GLOB.cardinal))
|
||||
|
||||
if(get_dist(on_wall, user) > 1)
|
||||
return
|
||||
var/turf/loc = get_turf(usr)
|
||||
var/area/A = loc.loc
|
||||
if (!istype(loc, /turf/simulated/floor))
|
||||
to_chat(usr, SPAN_WARNING("APC cannot be placed on this spot."))
|
||||
|
||||
var/ndir = get_dir(user, on_wall)
|
||||
if(!(ndir in GLOB.cardinal))
|
||||
to_chat(user, SPAN_WARNING("You need to stand in front of the wall, directly, to build an APC!"))
|
||||
return
|
||||
if (A.requires_power == 0 || istype(A, /area/space) || istype(A, /area/mine/unexplored) || istype(A, /area/mine/explored))
|
||||
to_chat(usr, SPAN_WARNING("APC cannot be placed in this area."))
|
||||
|
||||
var/turf/user_turf = get_turf(user)
|
||||
var/area/A = get_area(user)
|
||||
|
||||
if(!istype(user_turf, /turf/simulated/floor))
|
||||
to_chat(user, SPAN_WARNING("APC cannot be placed on this spot."))
|
||||
return
|
||||
if (A.get_apc())
|
||||
to_chat(usr, SPAN_WARNING("This area already has an APC."))
|
||||
|
||||
if(A.requires_power == 0 || istype(A, /area/space) || istype(A, /area/mine/unexplored) || istype(A, /area/mine/explored))
|
||||
to_chat(user, SPAN_WARNING("APC cannot be placed in this area."))
|
||||
return
|
||||
|
||||
if(A.get_apc())
|
||||
to_chat(user, SPAN_WARNING("This area already has an APC."))
|
||||
return //only one APC per area
|
||||
for(var/obj/machinery/power/terminal/T in loc)
|
||||
|
||||
for(var/obj/machinery/power/terminal/T in user_turf)
|
||||
if (T.master)
|
||||
to_chat(usr, SPAN_WARNING("There is another network terminal here."))
|
||||
to_chat(user, SPAN_WARNING("There is another network terminal here."))
|
||||
return
|
||||
else
|
||||
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(loc)
|
||||
var/obj/item/stack/cable_coil/C = new /obj/item/stack/cable_coil(user_turf)
|
||||
C.amount = 10
|
||||
to_chat(usr, "You cut the cables and disassemble the unused power terminal.")
|
||||
to_chat(user, "You cut the cables and disassemble the unused power terminal.")
|
||||
qdel(T)
|
||||
new /obj/machinery/power/apc(loc, ndir, 1)
|
||||
|
||||
//Select the correct prefab path based on where the mob is facing
|
||||
var/apc_path
|
||||
switch(ndir)
|
||||
if(NORTH)
|
||||
apc_path = /obj/machinery/power/apc/north
|
||||
if(SOUTH)
|
||||
apc_path = /obj/machinery/power/apc/south
|
||||
if(EAST)
|
||||
apc_path = /obj/machinery/power/apc/east
|
||||
if(WEST)
|
||||
apc_path = /obj/machinery/power/apc/west
|
||||
|
||||
if(!apc_path)
|
||||
stack_trace("APC being built by a non-mob, or somehow the direction grabbing or the cardinal directions are fucked!")
|
||||
return
|
||||
|
||||
new apc_path(user_turf, ndir, TRUE)
|
||||
qdel(src)
|
||||
|
||||
Reference in New Issue
Block a user