Skip to content

Commit

Permalink
refactored proc
Browse files Browse the repository at this point in the history
  • Loading branch information
TDSSS committed Feb 26, 2021
1 parent b2bf6ae commit fd8e1a1
Showing 1 changed file with 30 additions and 16 deletions.
46 changes: 30 additions & 16 deletions code/game/machinery/suit_storage_unit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -331,28 +331,42 @@
if(default_deconstruction_screwdriver(user, "panel", "close", I))
I.play_tool_sound(user, I.tool_volume)

/**
* Tries to store the item into whatever slot it can go, returns true if the item is stored successfully.
*
**/
/obj/machinery/suit_storage_unit/proc/store_item(obj/item/I, mob/user)
if(!user.canUnEquip(I))
return
. = FALSE
if(istype(I, /obj/item/clothing/suit) && !suit)
suit = I
. = TRUE
if(try_store_item(I, user))
suit = I
return TRUE
if(istype(I, /obj/item/clothing/head) && !helmet)
helmet = I
. = TRUE
if(try_store_item(I, user))
helmet = I
return TRUE
if(istype(I, /obj/item/clothing/mask) && !mask)
mask = I
. = TRUE
if(try_store_item(I, user))
mask = I
return TRUE
if(istype(I, /obj/item/clothing/shoes) && !boots)
boots = I
. = TRUE
if((istype(I, /obj/item/tank) || I.w_class <= WEIGHT_CLASS_SMALL) && !storage && !.)
storage = I
. = TRUE
if(.)
user.drop_item()
if(try_store_item(I, user))
boots = I
return TRUE
if((istype(I, /obj/item/tank) || I.w_class <= WEIGHT_CLASS_SMALL) && !storage)
if(try_store_item(I, user))
storage = I
return TRUE
return FALSE

/**
* Tries to store the item, returns true if it's moved successfully, false otherwise (because of nodrop etc)
*
**/
/obj/machinery/suit_storage_unit/proc/try_store_item(obj/item/I, mob/user)
if(user.drop_item())
I.forceMove(src)
return TRUE
return FALSE


/obj/machinery/suit_storage_unit/power_change()
Expand Down

0 comments on commit fd8e1a1

Please sign in to comment.