Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

RY-04: Adds wall-mounted variants of rechargers #194

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions code/WorkInProgress/Electronics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,80 @@
var/list/needed_parts = new/list()
module_research = list("electronics" = 3, "engineering" = 1)


/**
This deploys an assembly as an attachment to a turf, much like how a user can attach light frames to walls.
The attached object is not actually *ON* the wall turf itself but instead is at the location of the user
and its pixels are appropriately displaced depending on which direction the user is facing when they
deploy it.
*/
proc/deploy_turf(atom/target as mob|obj|turf|area, mob/user as mob)
var/turf/T = get_turf(src)
// I'd like to use the progress bar delay proc right here like the normal deploy() does but uuuhhhh... yeah, could a coder put it in here please?
var/obj/O = new store_type(T)
O.dir = user.dir

switch (O.dir)
if (1)
O.pixel_x = 1
O.pixel_y = 18
if (2)
O.pixel_x = -1
O.pixel_y = -18
if (4)
O.pixel_x = 18
O.pixel_y = 1
if (8)
O.pixel_x = -18
O.pixel_y = -1

O.mats = "Built"
user.visible_message("<span style=\"color:red\">[user] assembles a [O.name]!</span>")
qdel(src)




//If the assembly contains a wall mounted recharger and the user is holding a solder,
//attach it to a wall in the same way the charger placer does
afterattack(atom/target as mob|obj|turf|area, mob/user as mob)
if(src.secured == 2)

if (user.find_in_hand(src))

if(istype(user, /mob/living/carbon/human) && user.bioHolder)

if (user.find_in_hands(/obj/item/electronics/soldering))

if (src.store_type == /obj/machinery/recharger/wall)

if(isturf(target) && target.density)
user.drop_item()
src.loc = user.loc
deploy_turf(target, user)
return
else
boutput(user, "<span style=\"color:red\">You can only deploy wall-mounted rechargers this way!</span>")
return

else
boutput(user, "<span style=\"color:red\">You must be holding a soldering iron in another hand to assemble this!</span>")
return

else
boutput(user, "<span style=\"color:red\">The assembly can only be deployed by humanoids.</span>")
return

else
boutput(user, "<span style=\"color:red\">The assembly needs to be in one of your hands. How did you even do that?</span>")
return

else
boutput (user, "<span style=\"color:red\">The assembly should be secured first!</span>")
return



/obj/item/electronics/frame/verb/rotate()
set src in view(1)
if (!istype(usr, /mob/living))
Expand Down
73 changes: 63 additions & 10 deletions code/obj/machinery/recharger.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ obj/machinery/recharger
desc = "An anchored minature recharging device, used to recharge small, hand-held objects that don't require much electrical charge."
power_usage = 50

// So we can have rechargers with different sprites, let's use their icon states as variables!
// This way we won't have to make a new proc altogether just so we can have different sprites
var/sprite_empty = "recharger0"
var/sprite_charging = "recharger1"
var/sprite_complete = "recharger2"

var
obj/item/gun/energy/charging = null
obj/item/baton/charging2 = null
Expand Down Expand Up @@ -82,39 +88,86 @@ obj/machinery/recharger
power_usage = 50
..()
if(stat & NOPOWER)
src.icon_state = "recharger0"
src.icon_state = sprite_empty
return

if((src.charging) && ! (stat & NOPOWER) )
if (src.charging.cell)
if(src.charging.cell.charge(20))
src.icon_state = "recharger1"
src.icon_state = sprite_charging
use_power(600)
else
src.icon_state = "recharger2"
src.icon_state = sprite_complete

else if ((src.charging2) && ! (stat & NOPOWER) )
if (src.charging2.cell)
if(src.charging2.cell.charge(15))
src.icon_state = "recharger1"
src.icon_state = sprite_charging
use_power(500)
else
src.icon_state = "recharger2"
src.icon_state = sprite_complete

else if ((src.charging3) && ! (stat & NOPOWER) )
if (src.charging3.charges < src.charging3.maximum_charges)
src.charging3.charges++
src.icon_state = "recharger1"
src.icon_state = sprite_charging
use_power(250)
else
src.icon_state = "recharger2"
src.icon_state = sprite_complete

else if ((src.charging4) && ! (stat & NOPOWER) )
if(src.charging4.charge(15))
src.icon_state = "recharger1"
src.icon_state = sprite_charging
use_power(500)
else
src.icon_state = "recharger2"
src.icon_state = sprite_complete

else if (!(src.charging || src.charging2 || src.charging3 || src.charging4))
src.icon_state = "recharger0"
src.icon_state = sprite_empty


obj/machinery/recharger/wall
icon_state = "wall_recharger0"
name = "wall mounted recharger"
desc = "A recharger, refitted to be mounted onto a wall. Handy!"
sprite_empty = "wall_recharger0"
sprite_charging = "wall_recharger1"
sprite_complete = "wall_recharger2"

/**
This is a handy dandy little placer for the wall rechargers, so you don't have to move the things pixel by pixel
every time you want to place a charger on a wall somewhere.

Just place this in a map, point it in a direction, and it will automagically create a wall recharger that
appropriately attaches to the wall! Wow!
*/
obj/recharger_placer
name = "wall mounted recharger placer"
desc = "You are not supposed to be seeing this! The secrets of creation have been unravelled to you, oh god OH FUCK IMCODER"
icon = 'icons/obj/stationobjs.dmi'
icon_state = "wall_recharger_placer"

New()
..()
var/obj/machinery/recharger/wall/C = new/obj/machinery/recharger/wall

C.loc = src.loc
C.dir = src.dir

switch(dir)
if(1)
C.pixel_x = 1
C.pixel_y = 18
if(2)
C.pixel_x = -1
C.pixel_y = -18
if(4)
C.pixel_x = 18
C.pixel_y = 1
if(8)
C.pixel_x = -18
C.pixel_y = -1

qdel(src)


Binary file modified icons/obj/stationobjs.dmi
Binary file not shown.