Added optional parameters to public item-dropping methods to permit force removal of items from their current containers - #7066
Open
11BelowStudio wants to merge 3 commits into
Conversation
DropNextTo(), PlaceNextTo(), Insert(), and InsertOrDrop() now have optional `bool forceRemoval = false` parameter, to bypass CanRemove checks. Also added optional `bool forceInsertion = false` param to DropNextTo(), PlaceNextTo(), and InsertOrDrop(), in case that's of any use to anyone else.
…tainer has the desired result very hacky implementation, idk what I'm doing, but at least it is tested now I guess
force removal of items from their current containers
force removal of items from their current containersforce removal of items from their current containers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Unblocking space-wizards/space-station-14#45844
summary of code changes
bool forceRemoval = falseparameter toInsert()andInsertOrDrop()Remove()call inInsert()(and toInsert()itself)bool forceInsertion = falseparameter toInsertOrDrop()Insert()call asforcebool forceInsertion = falseandbool forceRemoval = falseparameter toDropNextTo()andPlaceNextTo()why
DropNextTo()method in RobustToolbox - this PR provides the option for a programmer to bypass removal checks in these methods if they have a very good reason for doing so.forceRemovalinstead offorceto make it clear which side of the operation is being forced.Insertmethod already has an optionalforceparameter to bypass insertion checks - figured that I may as well make that parameter accessible by these other methods which internally callInsert, in case it's of any use to anyone.forceInsertionin those other methods to make it clear that it's being used to force insertion aloneforceinInsert()toforceInsertionto avoid breaking the public interface - even though that parameter (still) only forces insertion.breaking changes
no breaking changes are anticipated as a result of this PR (existing method parameters are unchanged, new parameters are all optional, default values preserve prior behaviour).
testing
forceInsertionparams assume that theforceparameter of theInsert()method inSharedContainerSystem.Insert.csworks as describedforceRemovalparams assume that theforceparameter of theRemove()method inSharedContainerSystem.Remove.csworks as described.Robust.Shared.IntegrationTests/GameObjects/ContainerTests.ForceRemoval.cs