Skip to content

Commit

Permalink
Creates a disposal pipe that filters items that haven't found a valid…
Browse files Browse the repository at this point in the history
… sorting pipe (#11375)

* Adds an unsorted sorting pipe

* Only send unsorted things if they need sorting

* Adds the ability to build the unsorted pipe with the RPD

* Fixes pipe sorting

* Update pipe_sorting.dm

* Bug fixes

* Entering a pipe backwards will send you the way that you came

* Update code/modules/recycling/disposal/pipe_sorting.dm
  • Loading branch information
PowerfulBacon authored Aug 25, 2024
1 parent 7e5c9c4 commit cebd9fd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions code/game/objects/items/RPD.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GLOBAL_LIST_INIT(disposal_pipe_recipes, list(
new /datum/pipe_info/disposal("Y-Junction", /obj/structure/disposalpipe/junction/yjunction),
new /datum/pipe_info/disposal("Sort Junction", /obj/structure/disposalpipe/sorting/mail, PIPE_TRIN_M),
new /datum/pipe_info/disposal("Package Junction", /obj/structure/disposalpipe/sorting/wrap, PIPE_TRIN_M),
new /datum/pipe_info/disposal("Unsorted Mail Junction", /obj/structure/disposalpipe/sorting/unsorted, PIPE_TRIN_M),
new /datum/pipe_info/disposal("Trunk", /obj/structure/disposalpipe/trunk),
new /datum/pipe_info/disposal("Bin", /obj/machinery/disposal/bin, PIPE_ONEDIR),
new /datum/pipe_info/disposal("Outlet", /obj/structure/disposaloutlet),
Expand Down
1 change: 1 addition & 0 deletions code/modules/recycling/disposal/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var/destinationTag = NONE // changes if contains a delivery container
var/tomail = FALSE // contains wrapped package
var/hasmob = FALSE // contains a mob
var/unsorted = TRUE // have we been sorted yet?

/obj/structure/disposalholder/Destroy()
QDEL_NULL(gas)
Expand Down
35 changes: 29 additions & 6 deletions code/modules/recycling/disposal/pipe_sorting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@

/obj/structure/disposalpipe/sorting/nextdir(obj/structure/disposalholder/H)
var/sortdir = dpdir & ~(dir | turn(dir, 180))
if(H.dir != sortdir) // probably came from the negdir
if(check_sorting(H)) // if destination matches filtered type...
return sortdir // exit through sortdirection

var/input_direction = dir
// probably came from the negdir
if(H.dir == input_direction)
// if destination matches filtered type...
if(check_sorting(H))
H.unsorted = FALSE
// exit through sortdirection
return sortdir
// If we are entering backwards, continue onwards
if (H.dir == turn(input_direction, 180))
return H.dir
// go with the flow to positive direction
return dir

Expand All @@ -23,7 +30,7 @@

// Mail sorting junction, uses package tags to sort objects.
/obj/structure/disposalpipe/sorting/mail
desc = "An underfloor disposal pipe that sorts wrapped objects based on their destination tags."
desc = "An underfloor disposal pipe that sorts wrapped objects based on their destination tags. Objects passing through it become sorted."
flip_type = /obj/structure/disposalpipe/sorting/mail/flip
var/sortType = 0
// sortType is to be set in map editor.
Expand Down Expand Up @@ -82,7 +89,7 @@
// Wrap sorting junction, sorts objects destined for the mail office mail table (tomail = 1)
/obj/structure/disposalpipe/sorting/wrap
name = "package sorting disposal pipe"
desc = "An underfloor disposal pipe which sorts wrapped and unwrapped objects."
desc = "An underfloor disposal pipe which sorts wrapped and unwrapped objects. Objects passing through it become sorted."
flip_type = /obj/structure/disposalpipe/sorting/wrap/flip
initialize_dirs = DISP_DIR_RIGHT | DISP_DIR_FLIP

Expand All @@ -93,3 +100,19 @@
icon_state = "pipe-j2s"
flip_type = /obj/structure/disposalpipe/sorting/wrap
initialize_dirs = DISP_DIR_LEFT | DISP_DIR_FLIP

// Unsorted junction, will divert things based on whether or not they have been sorted.
/obj/structure/disposalpipe/sorting/unsorted
name = "unsorted sorting disposal pipe"
desc = "An underfloor disposal pipe which sorts sorted and unsorted objects. Objects passing through it become sorted."
flip_type = /obj/structure/disposalpipe/sorting/unsorted/flip
initialize_dirs = DISP_DIR_RIGHT | DISP_DIR_FLIP

/obj/structure/disposalpipe/sorting/unsorted/check_sorting(obj/structure/disposalholder/H)
return H.unsorted && (H.destinationTag > 1 || H.tomail)

/obj/structure/disposalpipe/sorting/unsorted/flip
icon_state = "pipe-j2s"
flip_type = /obj/structure/disposalpipe/sorting/unsorted
initialize_dirs = DISP_DIR_LEFT | DISP_DIR_FLIP

0 comments on commit cebd9fd

Please sign in to comment.