mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-05-18 12:50:29 +01:00
b0f0f4685f
* First pass * fixes * more fixes * num2hex length changes * pass 2 * fixed warning * looc log fix * . * update tgui * . * . * . * . * perttier * cleanup * . * . * fix token * no * . * . * . * , * modsay eventsay * . --------- Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
127 lines
4.0 KiB
Plaintext
127 lines
4.0 KiB
Plaintext
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer
|
|
name = "Cable Layer"
|
|
icon_state = "mecha_wire"
|
|
var/turf/old_turf
|
|
var/obj/structure/cable/last_piece
|
|
var/obj/item/stack/cable_coil/cable
|
|
var/max_cable = 1000
|
|
required_type = list(/obj/mecha/working)
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/Initialize(mapload)
|
|
. = ..()
|
|
cable = new(src, 0)
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/MoveAction()
|
|
layCable()
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/action(var/obj/item/stack/cable_coil/target)
|
|
if(!action_checks(target))
|
|
return
|
|
var/result = load_cable(target)
|
|
var/message
|
|
if(isnull(result))
|
|
message = span_red("Unable to load [target] - no cable found.")
|
|
else if(!result)
|
|
message = "Reel is full."
|
|
else
|
|
message = "[result] meters of cable successfully loaded."
|
|
send_byjax(chassis.occupant,"exosuit.browser","\ref[src]",src.get_equip_info())
|
|
occupant_message(message)
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/Topic(href,href_list)
|
|
..()
|
|
if(href_list["toggle"])
|
|
set_ready_state(!equip_ready)
|
|
occupant_message("[src] [equip_ready?"dea":"a"]ctivated.")
|
|
src.mecha_log_message("[equip_ready?"Dea":"A"]ctivated.")
|
|
return
|
|
if(href_list["cut"])
|
|
if(cable && cable.get_amount())
|
|
var/m = tgui_input_number(chassis.occupant, "Please specify the length of cable to cut", "Cut cable", min(cable.get_amount(), 30))
|
|
m = min(m, cable.get_amount())
|
|
if(m)
|
|
use_cable(m)
|
|
new /obj/item/stack/cable_coil(get_turf(chassis), m)
|
|
else
|
|
occupant_message("There's no more cable on the reel.")
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/get_equip_info()
|
|
var/output = ..()
|
|
if(output)
|
|
return "[output] \[Cable: [cable ? cable.get_amount() : 0] m\][(cable && cable.get_amount()) ? "- <a href='byond://?src=\ref[src];toggle=1'>[!equip_ready?"Dea":"A"]ctivate</a>|<a href='byond://?src=\ref[src];cut=1'>Cut</a>" : null]"
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/load_cable(var/obj/item/stack/cable_coil/CC)
|
|
if(istype(CC) && CC.get_amount())
|
|
var/cur_amount = cable? cable.get_amount() : 0
|
|
var/to_load = max(max_cable - cur_amount,0)
|
|
if(to_load)
|
|
to_load = min(CC.get_amount(), to_load)
|
|
if(!cable)
|
|
cable = new(src, to_load)
|
|
else
|
|
cable.add(to_load)
|
|
CC.use(to_load)
|
|
return to_load
|
|
else
|
|
return 0
|
|
return
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/use_cable(amount)
|
|
if(!cable || cable.get_amount() < 1)
|
|
set_ready_state(TRUE)
|
|
occupant_message("Cable depleted, [src] deactivated.")
|
|
src.mecha_log_message("Cable depleted, [src] deactivated.")
|
|
return
|
|
if(cable.get_amount() < amount)
|
|
occupant_message("No enough cable to finish the task.")
|
|
return
|
|
cable.use(amount)
|
|
update_equip_info()
|
|
return 1
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/reset()
|
|
last_piece = null
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/dismantleFloor(var/turf/new_turf)
|
|
new_turf = get_turf(chassis)
|
|
if(istype(new_turf, /turf/simulated/floor))
|
|
var/turf/simulated/floor/T = new_turf
|
|
if(!T.is_plating())
|
|
T.make_plating(!(T.broken || T.burnt))
|
|
return new_turf.is_plating()
|
|
|
|
/obj/item/mecha_parts/mecha_equipment/tool/cable_layer/proc/layCable(var/turf/new_turf)
|
|
new_turf = get_turf(chassis)
|
|
if(equip_ready || !istype(new_turf, /turf/simulated/floor) || !dismantleFloor(new_turf))
|
|
return reset()
|
|
var/fdirn = turn(chassis.dir,180)
|
|
for(var/obj/structure/cable/LC in new_turf) // check to make sure there's not a cable there already
|
|
if(LC.d1 == fdirn || LC.d2 == fdirn)
|
|
return reset()
|
|
if(!use_cable(1))
|
|
return reset()
|
|
var/obj/structure/cable/NC = new(new_turf)
|
|
NC.cableColor("red")
|
|
NC.d1 = 0
|
|
NC.d2 = fdirn
|
|
NC.update_icon()
|
|
|
|
var/datum/powernet/PN
|
|
if(last_piece && last_piece.d2 != chassis.dir)
|
|
last_piece.d1 = min(last_piece.d2, chassis.dir)
|
|
last_piece.d2 = max(last_piece.d2, chassis.dir)
|
|
last_piece.update_icon()
|
|
PN = last_piece.powernet
|
|
|
|
if(!PN)
|
|
PN = new()
|
|
PN.add_cable(NC)
|
|
NC.mergeConnectedNetworks(NC.d2)
|
|
|
|
//NC.mergeConnectedNetworksOnTurf()
|
|
last_piece = NC
|
|
return 1
|