Files
Bubberstation/code/game/objects/items/wall_mounted.dm
SkyratBot 6ee8dbb9c7 [MIRROR] Code clean-up & refactor for all RCD related & like devices. [MDB IGNORE] (#20394)
* Code clean-up & refactor for all RCD related & like devices. (#74527)

## About The Pull Request

1. Debloats the RCD.dm file i.e. renames it to RHD[Rapid handheld device
the base for all rcd like devices] and moves its subtypes into their
respective files
`/obj/item/construction/rcd` moved to RCD.dm
`/obj/item/construction/rld` moved to RLD.dm
`/obj/item/construction/plumbing` moved to RPLD.dm
`/obj/item/construction/rtd` stays in RTD.dm
Other rcd like device i.e. RPD, RFC, RWD, along with the above mentioned
files are now all moved into 1 folder called "rcd"
majority of the `to_chat()` are now replaced with `balloon_alert()` to
reduce spam

2. Adds early returns, optimizes & adds extra resource sanity checks
before and after the `do_after()` proc for the RLD. RLD silo links now
works again.
- RLD now uses an ammo bar just like the RCD for updating only its
overlays & not its entire icon state, it also has a blinking yellow icon
state when low on ammo
- Remove unused empty blinking yellow icon state for plumbing RCD.
nobody designed the ammo bars for them so having`has_ammobar = TRUE`
caused the unit tests to fail

4. Adds extra structure placement & resource sanity checks for RCD, RTD
& Plumbing RCD before & after the `do_after()` proc
  RCD Patches
- removes unused vars window_type & window_glass, these can be infered
from window_type directly
- removes furnish type & cost and let the rcd_vals() proc decide those
for consistency
- copies the rcd stuff from turf/floor to turf/open/misc with some
exceptions, It wasen't updated in a long time
- rcd vals i.e. cost & delay for window types are set for each
directional, full-tile, reinforced types. These all used constant values
& now they are adjusted accordingly

   RTD patches
      - Fixes #74526 RTD can lay floor tiles on all types of plating's
- The cost of deconstructing tiles was not calculated correctly i.e. it
always used the cost of the selected design & not the cost of the actual
floor type we are trying to deconstruct
- The construction & deconstruction time was constant & very fast for
all tile types, now the delay is adjusted based on the cost of the type
of tile in question
- RTD now has a blinking yellow empty icon state just like the RCD when
low on ammo

6. Fixes #73479 RCL now updates its pipe cleaning coil appearance when
changing colours & selecting white colour no longer yields a random coil
colour

7. makes sure `useResource() ` actually succeeds before doing any
action. The return value of this proc was not previously checked for
some devices

## Why It's Good For The Game
1. rcd like devices all moved into 1 folder for better organization
2. splits the original RCD.dm file into more logical & manageable files
for better maintainability
3. removes unused code & adds some extra sanity checks for everything
4. adds missing sprites for RLD & RTD

## Changelog
🆑
code: RCD & all its subtypes and other devices like it[RTD, RLD,
Plumbing RCD, RWD, RFC, RPD] now moved into 1 folder, removes unused
vars
refactor: RCD window type cost & delay are set based on the window type
selected.
refactor: RLD, RCD & plumbing RCD now has extra resource & target
placement sanity checks, optimizes RLD and code readability.
refactor: RTD now sets the correct delay with the cost of the tile type
currently being constructed/deconstructed taken into account
refactor: large majority of to_chat() replaced with balloon alerts
fix: RLD silo link now works again
fix: RTD can place tiles on any subtype of plating
fix: RCL now lays the correct colour of pipe cleaner when its colour is
changed
imageadd: empty blinking yellow icon states for RTD & RLD & an ammo bar
for RLD
/🆑

* Code clean-up & refactor for all RCD related & like devices.

* Update RHD.dm

---------

Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
2023-04-12 20:29:46 +01:00

97 lines
3.3 KiB
Plaintext

/obj/item/wallframe
icon = 'icons/obj/wallframe.dmi'
custom_materials = list(/datum/material/iron=MINERAL_MATERIAL_AMOUNT*2)
flags_1 = CONDUCT_1
inhand_icon_state = "syringe_kit"
lefthand_file = 'icons/mob/inhands/equipment/medical_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/medical_righthand.dmi'
w_class = WEIGHT_CLASS_SMALL
var/result_path
var/wall_external = FALSE // For frames that are external to the wall they are placed on, like light fixtures and cameras.
var/pixel_shift //The amount of pixels
/obj/item/wallframe/proc/try_build(turf/on_wall, mob/user)
if(get_dist(on_wall,user) > 1)
balloon_alert(user, "you are too far!")
return
var/floor_to_wall = get_dir(user, on_wall)
if(!(floor_to_wall in GLOB.cardinals))
balloon_alert(user, "stand in line with wall!")
return
var/turf/T = get_turf(user)
var/area/A = get_area(T)
if(!isfloorturf(T))
balloon_alert(user, "cannot place here!")
return
if(A.always_unpowered)
balloon_alert(user, "cannot place in this area!")
return
if(check_wall_item(T, floor_to_wall, wall_external))
balloon_alert(user, "already something here!")
return
return TRUE
/obj/item/wallframe/proc/attach(turf/on_wall, mob/user)
if(result_path)
playsound(src.loc, 'sound/machines/click.ogg', 75, TRUE)
user.visible_message(span_notice("[user.name] attaches [src] to the wall."),
span_notice("You attach [src] to the wall."),
span_hear("You hear clicking."))
var/floor_to_wall = get_dir(user, on_wall)
var/obj/O = new result_path(get_turf(user), floor_to_wall, TRUE)
O.setDir(floor_to_wall)
if(pixel_shift)
switch(floor_to_wall)
if(NORTH)
O.pixel_y = pixel_shift
if(SOUTH)
O.pixel_y = -pixel_shift
if(EAST)
O.pixel_x = pixel_shift
if(WEST)
O.pixel_x = -pixel_shift
after_attach(O)
qdel(src)
/obj/item/wallframe/proc/after_attach(obj/attached_to)
transfer_fingerprints_to(attached_to)
/obj/item/wallframe/screwdriver_act(mob/living/user, obj/item/tool)
// For camera-building borgs
var/turf/T = get_step(get_turf(user), user.dir)
if(iswallturf(T))
T.attackby(src, user)
return TOOL_ACT_TOOLTYPE_SUCCESS
/obj/item/wallframe/wrench_act(mob/living/user, obj/item/tool)
var/metal_amt = round(custom_materials[GET_MATERIAL_REF(/datum/material/iron)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later
var/glass_amt = round(custom_materials[GET_MATERIAL_REF(/datum/material/glass)]/MINERAL_MATERIAL_AMOUNT) //Replace this shit later
if(!metal_amt && !glass_amt)
return FALSE
to_chat(user, span_notice("You dismantle [src]."))
tool.play_tool_sound(src)
if(metal_amt)
new /obj/item/stack/sheet/iron(get_turf(src), metal_amt)
if(glass_amt)
new /obj/item/stack/sheet/glass(get_turf(src), glass_amt)
qdel(src)
return TOOL_ACT_TOOLTYPE_SUCCESS
/obj/item/electronics
desc = "Looks like a circuit. Probably is."
icon = 'icons/obj/module.dmi'
icon_state = "door_electronics"
inhand_icon_state = "electronic"
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
flags_1 = CONDUCT_1
w_class = WEIGHT_CLASS_SMALL
custom_materials = list(/datum/material/iron=50, /datum/material/glass=50)
grind_results = list(/datum/reagent/iron = 10, /datum/reagent/silicon = 10)
custom_price = PAYCHECK_CREW * 0.5