-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cable rework part 2: Extension cords and more #66871
Conversation
This was an amazing and very much needed PR for the electrical grid thank you very much for doing it :). It will make doing static bases a lot more fun now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto-requesting reviews from non-collaborators: @Qrox
Just reviewed the code and everything LGTM one conflict to be resolved and then I'm happy to merge :) |
…nk iuse functions; add move_cost parameter; rename charge_rate to wattage
It's intended, there's still more incoming. It started as just moving find_vehicle back to a static vehicle function as andrei8l suggested but it snowballed into more significant rewrites as I discovered out-of-bubble vehicle connections didn't actually work for anything but appliances. Nearing completion on that, though, and then I can undraft this. |
…t now requires functions only accessible from vehicle
Significant reworks here:
I think this is ready now, assuming the tests are green. Probably needs another round of reviews on the new changes, though. |
…rget" is already used for part targets
Summary
Features "Cable rework part 2: Adds extending cables with extension cords; adds disconnecting cables from examined vehicle part; improves cable status in item name; other cable improvements"
Purpose of change
I didn't implement everything I'd planned for cables in #64334, and there were some issues with the system that came to light after seeing it in action for a few months. This PR is a followup to improve the cable system further.
Player-facing changes:
-
as the current length, unspooled cables show a×
. Cables consolidate based on their length and status.c
, with the "Fill container with water from faucet" action's hotkey being changed to capitalF
.Describe the solution
Back-end changes:
cables()
function to prevent cabled items from erroneously showing that oxygen as a cable extension, but that flag check could be safely removed eventually since there's no other way for a non-cable to get added to that pocket than this item migration.find_vehicle()
function public.invoke_item_activity_actor
was added, which is a simple activity that invokes a specific item, and optionally a specific method, and ends the activity.Plug in / Manage cables
as the default menu text, and use an ammo_scale of 0 by default. This lets json for link_up actions be much more concise.item_contents::clear_pockets_if
was added, a function that lets you easily clear an item's pockets if they meet a chosen lambda function.remove_remote_part()
reworked, now there's aget_remote_part()
function that returns both the remote vehicle and the part as a pair.remove_remote_part()
now uses that new function to delete the part.find_vehicle()
was made public, an easy way to load a vehicle outside the reality bubble into memory.properties_to_item()
was renamed topart_to_item()
and moved from being avehicle_part
function to avehicle
one, as it now needs to know the absolute position of the part, which the vehicle keeps track of. All uses of it were replaced appropriately.shed_loose_parts()
was heavily reworked, as it didn't actually work properly for cables attached to a mount other than [0,0]. It's now far more robust, accurately updating connection points between vehicles when either of them moves or rotates, at any speed, and even beyond reality bubble boundaries.Describe alternatives you've considered
c
hotkey, but when interacting with an appliance it will use the fallback hotkey assignment, which will probably assign it toa
.veh_app_interact::populate_app_actions()
has a set of specific commands it assigns hotkeys to, but assigns fallback alphabetical keys to everything else. Now that unplugging cables works for both vehicles and appliances, it can't be included in that list of specific commands anymore, and thus gets a fallback hotkey. I was able to make a fix for this, but it was hacky and felt like taking a shotgun to an issue that needs more nuance, so I ultimately let it be.Testing
Device Cables Stress Test-trimmed.tar.gz
A helicopter with many, many cables attached, used for testing that everything stays connected even when flying at high speeds, and stress testing to see the CPU impact. The results after this PR were much the same as the results for the first cable PR.
Device Cables All Connections-trimmed.tar.gz
A save created in a recent experimental version (e284941) with every kind of cable connection active. Used to ensure this PR's changes can handle saves made after #64334. Vehicle connections and cable items stay linked, but electrical devices do not. This was an expected outcome, and any attempt to somehow migrate the links wouldn't be worth it in my opinion, since players could easily just re-link the devices.
Additional context
This PR is in draft so after #66847 gets merged I can adjust it accordingly. My sincere thanks to everyone who added link_up actions to items, something I said I would do myself before getting lost in the weeds of making this PR. I made sure to not invalidate their work.