Skip to content

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
space-wizards:masterfrom
11BelowStudio:20260904-force-DropNextTo
Open

11BelowStudio wants to merge 3 commits into
space-wizards:masterfrom
11BelowStudio:20260904-force-DropNextTo

Conversation

@11BelowStudio

@11BelowStudio 11BelowStudio commented Sep 4, 2026

Copy link
Copy Markdown

Unblocking space-wizards/space-station-14#45844

summary of code changes

  • SharedContainerSystem.Insert.cs
    • Added bool forceRemoval = false parameter to Insert() and InsertOrDrop()
      • Passed to the internal Remove() call in Insert() (and to Insert() itself)
    • Added bool forceInsertion = false parameter to InsertOrDrop()
      • Passed as to internal Insert() call as force
  • SharedTransformSystem.Component.cs
    • Added bool forceInsertion = false and bool forceRemoval = false parameter to DropNextTo() and PlaceNextTo()
      • Passed along to internal calls to those other methods

why

  • linked PR in ss14 repo is blocked by the inability to bypass removal checks in 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.
    • named it forceRemoval instead of force to make it clear which side of the operation is being forced.
  • also, I noticed that the public Insert method already has an optional force parameter to bypass insertion checks - figured that I may as well make that parameter accessible by these other methods which internally call Insert, in case it's of any use to anyone.
    • named it forceInsertion in those other methods to make it clear that it's being used to force insertion alone
    • did not rename force in Insert() to forceInsertion to 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

  • new forceInsertion params assume that the force parameter of the Insert() method in SharedContainerSystem.Insert.cs works as described
    • not sure where to start with writing a unit test for that, could just remove those parameters from the PR instead
  • new forceRemoval params assume that the force parameter of the Remove() method in SharedContainerSystem.Remove.cs works as described.
    • Bodged together an (admittedly rather shoddy) test for that in Robust.Shared.IntegrationTests/GameObjects/ContainerTests.ForceRemoval.cs

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
@11BelowStudio 11BelowStudio changed the title Added optional parameters to force removal of items from containers. Added optional parameters to force removal of items from containers in public methods which internally attempt removing items from containers Sep 4, 2026
@11BelowStudio 11BelowStudio changed the title Added optional parameters to force removal of items from containers in public methods which internally attempt removing items from containers Added optional parameters to certain public methods to permit force removal of items from their current containers Sep 4, 2026
@11BelowStudio 11BelowStudio changed the title Added optional parameters to certain public methods to permit force removal of items from their current containers Added optional parameters to public item-dropping methods to permit force removal of items from their current containers Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant