mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-29 02:51:41 +00:00
* 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>
130 lines
5.6 KiB
Plaintext
130 lines
5.6 KiB
Plaintext
/**
|
|
* Camera console used to control a base building drone
|
|
*
|
|
* Using this console will put the user in control of a [base building drone][/mob/camera/ai_eye/remote/base_construction].
|
|
* The drone will appear somewhere within the allowed_area var, or if no area is specified, at the location of the console.area
|
|
* Upon interacting, the user will be granted a set of base building actions that will generally be carried out at the drone's location.
|
|
* To create a new base builder system, this class should be the only thing that needs to be subtyped.
|
|
*
|
|
*/
|
|
/obj/machinery/computer/camera_advanced/base_construction
|
|
name = "generic base construction console"
|
|
desc = "An industrial computer integrated with a camera-assisted rapid construction drone."
|
|
networks = list("ss13")
|
|
circuit = /obj/item/circuitboard/computer/base_construction
|
|
off_action = /datum/action/innate/camera_off/base_construction
|
|
jump_action = null
|
|
icon_screen = "mining"
|
|
icon_keyboard = "rd_key"
|
|
light_color = LIGHT_COLOR_PINK
|
|
///Area that the eyeobj will be constrained to. If null, eyeobj will be able to build and move anywhere.
|
|
var/area/allowed_area
|
|
///Assoc. list ("structure_name" : count) that keeps track of the number of special structures that can't be built with an RCD, for example, tiny fans or turrets.
|
|
var/list/structures = list()
|
|
///Internal RCD. Some construction actions rely on having this.
|
|
var/obj/item/construction/rcd/internal/internal_rcd
|
|
|
|
/obj/machinery/computer/camera_advanced/base_construction/Initialize(mapload)
|
|
. = ..()
|
|
//Populate the actions list with the different action objects that will be granted to console users
|
|
populate_actions_list()
|
|
//Map spawned consoles will automatically restock their materials
|
|
if(mapload)
|
|
restock_materials()
|
|
|
|
/**
|
|
* Fill the construction_actios list with actions
|
|
*
|
|
* Instantiate each action object that we'll be giving to users of
|
|
* this console, and put it in the actions list
|
|
*/
|
|
/obj/machinery/computer/camera_advanced/base_construction/proc/populate_actions_list()
|
|
return
|
|
|
|
/**
|
|
* Reload materials used by the console
|
|
*
|
|
* Restocks any materials used by the base construction console.
|
|
* This might mean refilling the internal RCD (should it be initialized), or
|
|
* giving the structures list default values.
|
|
*/
|
|
/obj/machinery/computer/camera_advanced/base_construction/proc/restock_materials()
|
|
return
|
|
|
|
///Find a spawn location for the eyeobj. If no allowed_area is defined, spawn ontop of the console.
|
|
/obj/machinery/computer/camera_advanced/base_construction/proc/find_spawn_spot()
|
|
if (allowed_area)
|
|
return pick(get_area_turfs(allowed_area))
|
|
return get_turf(src)
|
|
|
|
/obj/machinery/computer/camera_advanced/base_construction/CreateEye()
|
|
var/turf/spawn_spot = find_spawn_spot()
|
|
if (!spawn_spot)
|
|
return FALSE
|
|
eyeobj = new /mob/camera/ai_eye/remote/base_construction(spawn_spot, src)
|
|
eyeobj.origin = src
|
|
return TRUE
|
|
|
|
/obj/machinery/computer/camera_advanced/base_construction/attackby(obj/item/W, mob/user, params)
|
|
//If we have an internal RCD, we can refill it by slapping the console with some materials
|
|
if(internal_rcd && (istype(W, /obj/item/rcd_ammo) || istype(W, /obj/item/stack/sheet)))
|
|
internal_rcd.attackby(W, user, params)
|
|
else
|
|
return ..()
|
|
|
|
/obj/machinery/computer/camera_advanced/base_construction/Destroy()
|
|
qdel(internal_rcd)
|
|
return ..()
|
|
|
|
///Go through every action object in the construction_action list (which should be fully initialized by now) and grant it to the user.
|
|
/obj/machinery/computer/camera_advanced/base_construction/GrantActions(mob/living/user)
|
|
..()
|
|
//When the eye is in use, make it visible to players so they know when someone is building.
|
|
eyeobj.invisibility = 0
|
|
|
|
/obj/machinery/computer/camera_advanced/base_construction/remove_eye_control(mob/living/user)
|
|
..()
|
|
//Hide the eye when not in use.
|
|
eyeobj.invisibility = INVISIBILITY_MAXIMUM
|
|
|
|
/**
|
|
* A mob used by [/obj/machinery/computer/camera_advanced/base_construction] for building in specific areas.
|
|
*
|
|
* Controlled by a user who is using a base construction console.
|
|
* The user will be granted a set of building actions by the console, and the actions will be carried out by this mob.
|
|
* The mob is constrained to a given area defined by the base construction console.
|
|
*
|
|
*/
|
|
/mob/camera/ai_eye/remote/base_construction
|
|
name = "construction holo-drone"
|
|
//Allows any curious crew to watch the base after it leaves. (This is safe as the base cannot be modified once it leaves)
|
|
move_on_shuttle = TRUE
|
|
icon = 'icons/obj/mining.dmi'
|
|
icon_state = "construction_drone"
|
|
///Reference to the camera console controlling this drone
|
|
var/obj/machinery/computer/camera_advanced/base_construction/linked_console
|
|
|
|
/mob/camera/ai_eye/remote/base_construction/Initialize(mapload, obj/machinery/computer/camera_advanced/console_link)
|
|
linked_console = console_link
|
|
if(!linked_console)
|
|
stack_trace("A base consturuction drone was created with no linked console")
|
|
return INITIALIZE_HINT_QDEL
|
|
return ..()
|
|
|
|
/mob/camera/ai_eye/remote/base_construction/setLoc(turf/destination, force_update = FALSE)
|
|
var/area/curr_area = get_area(destination)
|
|
//Only move if we're in the allowed area. If no allowed area is defined, then we're free to move wherever.
|
|
if(!linked_console.allowed_area || istype(curr_area, linked_console.allowed_area))
|
|
return ..()
|
|
|
|
/mob/camera/ai_eye/remote/base_construction/relaymove(mob/living/user, direction)
|
|
//This camera eye is visible, and as such needs to keep it's dir updated
|
|
dir = direction
|
|
return ..()
|
|
|
|
///[Base console's][/obj/machinery/computer/camera_advanced/base_construction] internal RCD. Has a large material capacity and a fast buildspeed.
|
|
/obj/item/construction/rcd/internal
|
|
name = "internal RCD"
|
|
max_matter = 600
|
|
delay_mod = 0.5
|