[MIRROR] Rack sounds pr turned rack code refactor #2563
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mirrored on Nova: NovaSector/NovaSector#1622
Original PR: tgstation/tgstation#81973
About The Pull Request
Alternate title: "Label Hoarding PR"
You ever just want to add sounds to a thing and then end up just refactoring half of the damn thing?
Yeah.
Anyhow.
So in rough chronological order!
Putting items in racks actually plays the sounds
Picking things up from racks plays their pickup sound, but putting them on them doesn't. Just dropping it or putting it on tables does make the right sounds. This seems to be because of a
silent
parameter intransferItemToLoc
that's set by tables but not racks.Adding this makes it work just fine.
Attackby single letter parameters, 1 instead of TRUE
Then, I noticed
attackby
just returns1
to mean true after callingtransferItemToLoc
, when we just have the more readableTRUE
.Similarly it uses a single letter parameter
W
, which on its own is already unreadable, but is also mismatched with the parent proc usingattacking_item
.So we change it
1
toTRUE
andW
toattacking_item
to make it more readable!Don't let them try to put Abstract items
While looking over the table code, though, I also noticed it has a check for the
ABSTRACT
item flag when placing items. Having tested this, we add this too for consistency and to avoid awkward situations down the line.Split off rack structure attackby wrenching into wrench_act procs
But that's still kind of bad! But wait, we have procs for wrenching actions, so it should really be in there.
So we move this to its own proc.
Split off rack item attackby wrenching into wrench_act procs, include sounds
But the item can also be deconstructed, and sure enough, it does the same thing.
So we give this the same treatment, and include a
deconstruct
method rather than just having it be separate. We also play the tool sound for consistency with deconstructing the rack structure.Note: this makes it so it only deconstructs rack items on left click. I think that's perfectly fine.
Ancient code removal
Now we get to the fun part! Ancient code.
When removing the single letter parameters from
attackby
previously, I thought I might as well remove other such instances while we're at it.This gets us to
MouseDrop_T
.What the fuck?
Right so, this lets us click-drag-drop an item onto the rack, but only for our active item. And it just drops it and steps it in the right direction.
So we just, we just kill it. We just kill it.
You can just click on the rack to do functionally the exact same thing, so we just kill it.
It's blocking us from dumping storage item contents, so just.
We Just Kill It.
We Just Fucking Kill It.
Combat mode kicking
Anyhow! With that out of the way, we move to the finishing touches: usage context and kicking!
While writing up context I was reminded that currently clicking on a rack with an empty hand would just, kick it, regardless of combat mode.
This is awkward, misclick a few times and you've kicked it back into item form.
So we make it only kick it while in combat mode to avoid this.
Usage context
Then finally! Usage context!
This part's easy, just copying over the logic from tables and making it show deconstruct context for the rack structure and item and construction context for the item.
And then don't forget to register said context.
And that's all!
Now please remind me not to be this comprehensive again.
Not for something that's less than thirty lines, at least.
Thanks.
Why It's Good For The Game
Doing this in chronological order.
First off, it's wonky that putting say a toolbox on a table or the ground makes sound but putting it in a rack is perfectly silent, especially when taking it from the rack isn't. This makes it consistent with tables.
Returning TRUE is more readable than returning 1. Single letter parameters are awful for readability, especially when inconsistent with the parent parameters. This resolves those.
It shouldn't let you attempt to place items tagged with
ABSTRACT
, as you shouldn't be able to place those. This makes it consistent with tables.We have procs for wrench actions, better to use those than implementing your own wrench checks in
attackby
. This makes it do so.It's just nice to have a deconstruction sound, so this makes deconstructing the item also play the sound of the used tool.
The ancient rack code we're removing is entirely just a more awkward way of doing what we can already do without it, it only let you drag your active item onto them, but you can just click. It was awkwardly implemented, and blocked anything from doing its own click-drag onto surface thing like say storage dumping contents.
Usage context is just nice to have. This adds context for deconstructing to the rack structure and for deconstructing and constructing to the rack item.
Changelog
🆑 00-Steven
refactor: Touched most of the code for racks. It should function almost entirely the same save for what's noted here, please report any issues.
code: Wrenching moved to wrenching procs. Side-effect, rack items are only deconstructed on left-click
sound: Items that have sounds make them when placed on racks, much like when placed on tables.
sound: Rack items now make a sound upon deconstructing them.
fix: Racks no longer let you attempt to place abstract items like the slap hand or water tank spray nozzles on them.
qol: Clicking on a rack no longer kicks the shit out of it if you don't actually have combat mode on.
qol: Racks and rack items have hover tooltip usage context.
del: Killed ancient rack code for dragging your active item onto a rack. Just click it does the same thing. This allows you to actually dump items onto racks, though currently disorderly.
/:cl: