Move vehicle flyability to a flag, allow modifying flying vehicles #40509
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.
Summary
SUMMARY: None
Purpose of change
Follow-up to #40467
Instead of forbidding modification, use a tag on a vehicle to determine if it is airworthy. Doing any of the previously prevented activities will not set this tag to false.
Describe the solution
Add
vehicle::flyable
,vehicle::is_flyable()
andvehicle::set_flyable()
these either return or modify this value. This value defaults to true.Add
vehicle::would_prevent_flyable()
this determines if modifying a specific vehicle part would render this vehicle non-flyable.In vehicle interaction, query if the player wants to render the vehicle unflyable, and if they consent to it, render the vehicle non-flyable.
In vehicle modification activities, bail out if the selected action would make the vehicle unflyable.
When determining if the player can change z levels, check if the vehicle is flyable, and if it is not, bail out.
Testing
Spawn in a helicopter. Attempt to uninstall a part that is not a curtain or seatbelt.
Spawn in a helicopter. Attempt to install a part that is not a curtain or seatbelt.
Spawn in a helicopter. Smash it up a bit, then attempt to repair a part that is not a curtain or seatbelt.
Say no to each of these actions. You can still fly the helicopter. Say yes to each of these actions. Be prevented from flying the helicopter.
Save and load, unflyable vehicles are still unflyable.
Attempt to deconstruct an untouched vehicle. It works fine.
Attempt to deconstruct an intact helicopter. It bails out.
Additional context