Files
Delta-v/Content.Shared/Interaction/SharedInteractionSystem.cs
T
+88 22aa10443e upstream merge 27/04/2025 (#3596)
* Fix glass duplication with beakers (#34441)

Update chemistry.yml

Fixing glass dupe.

* Automatic changelog update

* Heterochromia for Moth (#36061)

* 1

* Fix local

* formatting

---------

Co-authored-by: Milon <milonpl.git@proton.me>

* Salvage Airlock (#36375)

* Salvage

* atmos a

* more muted colours

* Mapping Related to AI

* Fixed small naming inconsistency

* Revert "Fixed small naming inconsistency"

This reverts commit 985e1fd46a09e521c11dc345f470228e7907fbb9.

* Revert "Mapping Related to AI"

This reverts commit 5d5ae4feb819396c5c2a7413399ab5ce34f8683b.

* Revert "atmos a"

This reverts commit 529831e2584df27fa102ee1c970948fa3b6bab56.

* indent

---------

Co-authored-by: Milon <milonpl.git@proton.me>

* Automatic changelog update

* Departmental shelves whitelist expansion (Attempt №3) (#34292) (disabled)

* Expand-Shelves-Whitelist

Made departmental shelves hold a wider variety of items.

* Accidentally included "Packet" twice

* Automatic changelog update

* Replace GetEntitiesInTile with EntityLookupSystem equivalent (#36756)

* commit GET!!

* minor cleanup

* Automatic changelog update

* Unused dependency cleanup. (#36760)

* take 2! fight!!!

* final touches

* reeeeeee

* Fire protection for ERT engineering hardsuit (#34949)

* Automatic changelog update

* Nonlethal throwables crate (#35808)

* Automatic changelog update

* Use non-generic TryComp in `StationSpawningSystem` (#36769)

Use non-generic TryComp in StationSpawningSystem

* Add marker components for admin shenanigans (#36776)

* Automatic changelog update

* Restore `LimitedChargesComponent.MaxCharges` default value to 3 (#36778)

* Wizard Figure Voiceline Fix #36771 (#36779)

DA WIZARDgit add -A

* change MV cable outline (#36751)

* change MV cable outline

* zamn

* The Beverage Jug Can Now Look Open (#36070)

* GenJug-Changes

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

* Guh

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

* Support For the Rest

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

* New Sprites

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

* Newest Sprites

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

---------

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>

* Pirate Gear Tweaks. (#35986)

* Tweaked pirate gear to be in-line with similar items.

* Added attribution for flashlight sprites, made hardsuits Major Contraband

* Added empty versions of the pirate revolver and flintlock.

* Test fail fix hopefully?

* Test fail fix hopefully V2.0

* Test fail fix hopefully V3.0

* Test fail fix hopefully V4.0

---------

Co-authored-by: RedBookcase <Usualmoves@gmail.com>

* Automatic changelog update

* Markings overhaul (#35938)

* markings displacement setup

* ok i got it!

* fix map updating

* remove trackingLayers

* markings clean up and modernizize

* marking disabling displacements

* markings restriction

* dehihienize

* dehihiniezize 2

* aa

* nice

* Automatic changelog update

* Resprite main altars (#35685)

* resprite main altars

* updated meta.json

* Automatic changelog update

* Adds beanies to the WinterDrobe! (#32946)

* sprites

* messing with the ymls

* new sprites

* that's a lotta yaml

* make the sprites gooder

* color adjustment

* to the winterdrobe with you

* layering fix

* Automatic changelog update

* Santa hat with a foldable beard (#36510)

* Added foldable component to santa hat

* Modified sprites, modified YAML. YAML is cursed

* Changed santa hat description to mention the beard fold

* Removed HideLayerClothing since it doesnt work

* Changed the prefix from "beard" to "nobeard" to match with the fold/unfold verb

* Credits for sprite changes

---------

Co-authored-by: Lanedon <matth.galvez@gmail>

* Automatic changelog update

* Puddle Code Slipping Cleanup (#35845)

* Init Commit

* windows yelling at me to update commit

* working commit, need prediciton and more dehardcoding

* Project 0 warnings

* Working Commit (Near Final)

* ryder got confused commit

* I love Merge Conflicts :)

* Working commit, no prediction

* Forgot the yaml changes

* Comments and typos

* Apparently while the reduced launch mult of lube was initialized it was never used so I revered back to default

* Fixed an incorrect divisor

* bit of cleanup

* Prediciton fixed, and puddles now affect all entities

* FORGOT TO RENAME A VERY IMPORTANT VARIABLE OOPS

* Really big I forgor moment

* Even bigger I forgor moment

* four more merge conflicts to fix four more oopsies

* fixed actual divide by zero moment and also im very dumb

* Even bigger I forgor moment

* four more merge conflicts to fix four more oopsies

* fixed actual divide by zero moment and also im very dumb

* Fix all test fails

* code cleanup

* Webedit whitespace

* Code cleaup

* whitespace webedit

* whitespace webedit

* whitespace webedit

* whitespace removal

* Comments and cleanup

* Re-Added 20 warnings as per Ork's request

* Cleanups

* Spacing fix

* bugfixes and cleanup

* Small bugfix

* Actually dirty the slipComp for real

* Added Friction field to Reagent Prototype per design discussion

* Sliding system is kill

* The Bartender can now make Eggnog (#34065)

* Preliminary eggnog changes (egg in shaker crashes?)

* Fixed eggnog reagent name and description

* added - to flavor

* deleted a space

* Added eggnog glass sprite

* changed fill levels to match rsi

* Added two more fill levels to eggnog

* Removed fizziness, changed physical description, and fixed rsi

---------

Co-authored-by: uhbg <29674581+uhbg@users.noreply.github.com>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Automatic changelog update

* Require traitors to maroon their objective no matter what (#35825)

* jesus

* okay.

* OOPS

* ok

* ok

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* ok

* Update Resources/Prototypes/Objectives/paradoxClone.yml

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Resources/Prototypes/Objectives/base_objectives.yml

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* m

* ok

* ok

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Wizard Headset (#35732)

* wizardcomms

* wizheadset

* Addressed requested changes and axed wizard channel due to redundancy.

* oops overlooked this, dont tell anyone

* another mistake fixed

* removed wiz encryption key due to redundancy

* accidentally left some punctuation in a now unrelated meta.json

* Automatic changelog update

* Remove MK ULTRA ai name (#35726)

* Remove bad AI names

* Fine, I won't try to sneak this in here.

* Reorder electronics recipe file, add filter categories (#35713)

* electronics split

* split base recipe and category

* all but machines

* machine shuffle

* reorder

* delete unused recipes

* rename cargo to supply

* git weirdness

* git weirdness 2

* Automatic changelog update

* Cleanup warnings in `SharedPortalSystem` (#36747)

* Cleanup warnings in SharedPortalSystem

* Formatting while we're here

* Replace uses of !Any() with Count == 0

* AnyEntitiesIntersecting

* Binomial Number Selector for EntityTables (#36783)

* binomial dist

* lol initialize the int tho idiot

* xml docs my forgotten

* ditto

* Add more ruins (#36785)

* Fix NRE in GasTileOverlaySystem (#36793)

* Automatic changelog update

* Add RGA/RSI to Credits (#36704)

* Add RGA and RSI to Credits

* Move to thread + add directory field

* Further Allocation Tweaks (#36800)

* init

* fix lockboxes

* Automatic changelog update

* Add the medical HUDs to medical's loadouts (except chem) (#32847)

Added the medical HUD and eyepatch to the medical (CMO, doctor, paramed and intern) loadout to let them choose between. Also gives the option for the regular glasses.

* Automatic changelog update

* new salv ruins (#36798)

* hotplate, kitcken grille bugfixes (#34776)

* commit

* cleanup

* Automatic changelog update

* Solution drag and drop now checks if container is closed and drainable (#34683)

drainable fix

* Automatic changelog update

* fix some datasets (#36806)

* Add rehydratable mop bucket cube, refactor the rehydratable yml (#34586)

* Refactor rehydratable items

* Finish main refactor

* Add mop bucket cube

* Move cube sprite and item size to RehydratableAnimalCube

* Fix sprite attribution

* Make it follow the conventions

* Refactor wrapped cube, leave MonkeyCube tag only on the cube and the Syndie Sponge

* Fix DehydratedSpaceCarp inheritance overwriting needed components

* no need for this comment

* remove whitespace

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* indentation

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Restore lost description

* reorder stuff

* line

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Automatic changelog update

* Increase thief to player ratio (#36531)

* reduce max number of traitors, increase thief to player ratio

* revert traitor max back to 8

* Automatic changelog update

* Added a semi-functional genderfluid pin. (#35854)

* Added a semi-function GenderfluidPin

* Update pins.yml

fix bug

* Fix meta.json under the newly merged "fix as you go" policy

* Update pin description

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Automatic changelog update

* Station AI Name Identifier (#36801)

init

* Automatic changelog update

* Makes EventRole Ids properly set ID names. (#28958)

* Add id binding system

* Change so it activates when added too

* Add to eventhumanoid

* Add PDA binding, try to fix some things

* Still not fixed, PDA is working right

* Move to server, add on mind instead

* Implement suggestions

* Fix things

* Finish review stuff

* Messed up cluwne

* Remove after only changing id too

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Various sharedsystem spring cleaning (#36200)

* Various shared system warnings cleanup

* More shared system warnings cleanup

* Rearranging changes

* Using correct transform for unbuckle

* Small changes

* Revert buckle change

* Update Content.Shared/Ghost/SharedGhostSystem.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Fix some locale strings and make some code for them looks better (#32003)

* Fix a lot locale strings

add functions using
fix identity for meat spike and creaming

* comma

* fixes for fixes

* yeah

* fuck

* Automatic changelog update

* Remove non-functional ninja exemption from `SpawnAndDeleteEntityCountTest` (#36813)

Remove non-functional ninja exemption from SpawnAndDeleteEntityCountTest

* Firelock temperature and pressure warning lights (#28339)

* Add temperature and pressure lights to firelocks

* Replace sprites with new pressure and temperature light versions

* Remove obsolete deny and locked sprites

* Add SpriteSync for warning light animation synchronization

* Teal lights

* Partial animation implementation

* fixup! Teal lights

* Temperature lights

* Adjusted firelock light heights and added final warning light sprites

* Fix colors

* Testing colors

* Update light sprites

* updated sprites

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>

* Automatic changelog update

* Fix bots parenting, emotes (#29949)

* Bots overhaul

* fix

* change speech sound to pai

* purge a lot

* i forgor :trollface:

* adjust

* that aswell

* Automatic changelog update

* Fix identity grammar (#36817)

Fix identity

* Fix Animal Versions of Captain Uniform (#36804)

* scienceevasuit

* update money uniforms

* update meta.json files and hamster hats

* revert scienceevasuit

* revert accidental prisoner eva change

* Automatic changelog update

* Fix vox hair (#36816)

* Fix vox hair

* remove CL

* Tweak Security protection values (#30212)

* Tweak Hardsuits

* HoS/Ward Coats change

* Whoopsie wrong number

god why am i doing this its 1:33 AM and i made a silly mistake...

* Adress Review

Revert Warden hardsuit slowdown to 30% again
Decreased Security hardsuit heat protection down to 20%

* Automatic changelog update

* Added more salvage ruins (#36822)

* Metal foam grenade rework, small tweaks to grenade timers (#34579)

* Automatic changelog update

* dragons can now pry doors (#36811)

* Automatic changelog update

* Make funding allocation computer more configurable (#36790)

* Make funding allocation computer more configurable

* admin logging

* unused

* ccvar enabled

---------

Co-authored-by: ScarKy0 <scarky0@onet.eu>

* Automatic changelog update

* Fingerprint taking improvements (#31864)

* now using event to check access to fingerprint

* Opps actually commiting the changes

---------

Co-authored-by: YourUsername <you@example.com>
Co-authored-by: beck-thompson <beck314159@hotmail.com>

* Banana cream pie loc improvements (#36829)

* CAPITALIZE(THE($owner))

* Rename "thrower" to "thrown"; use THE($thrown)

* "the banana cream pie" -> "a banana cream pie"

* Simplify filter

* Automatic changelog update

* Command uniform (#32103)

* Added generic command jumpskirt, jumpsuit and cap, and made them available in the HoP's clothing printer.

* fixed generic command jumpskirt and jumpsuit.

* Updated generic command jumpskirt/-suit textures, added generic command beret.

* Fixed game-breaking bug in previous commit relating to the command beret.

* altered generic command soft cap/baseball cap sprites.

* Update Resources/Prototypes/Entities/Clothing/Head/hats.yml

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* Update Resources/Prototypes/Entities/Clothing/Uniforms/jumpskirts.yml

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* Update Resources/Prototypes/Entities/Clothing/Uniforms/jumpsuits.yml

Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>

* review

* whoopsie

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
Co-authored-by: Milon <milonpl.git@proton.me>

* Automatic changelog update

* downprice many cargo orders (#32375)

* atmos repricing

* emitter crate

* materials

* lasers

* revert gun prices

* Automatic changelog update

* Ashen hud item status slot fix (#31411)

* new patchMargin variable added, horizontals fixed

* All sides now work, system is fully integarated

---------

Co-authored-by: Zachary Yona <magicalusf@gmail.com>

* Ashtray Resprite and Fix (#31643)

* The meat and potatoes

Yup

* Stupid recycler

bruh

* guh

guh

* Update MinorAntagonists.xml (#36836)

* Simulate command in minutes for real (#36808)

* 60

* Fix warning CS0414 instances (#36832)

Fix warning cs0414 instances

* Nerf Firelock electronic prices (#33469)

* Nerf Firelock electronic prices

- make firelock electronics price half of the input cost to make one
(27) rounded up

* Why does firelock make glass?

- remove the Physical composition of glass from
FirelockElectronics as the input does not contain glass
and the output cannot contain half a steel and plastic

---------

Co-authored-by: Milon <milonpl.git@proton.me>

* Automatic changelog update

* Give Admins "Tails" (#36842)

One line yaml change

* Fix construction orientation being ignored for some objects (#36488)

* fixes

* removed empty "SnapToGrid"s and parent "completed"s

* Automatic changelog update

* elemental.yml & asteroid.yml cleanup (#36448)

* Moth-pockets (#34517)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Four new food crates for the ATS (#33286)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Cleanup: Move folders out of bureaucracy.rsi and paper.yml (#35108)

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Improve LocalizedDataset test to check for low Count (#36848)

* Improve LocalizedDataset test to check for low Count

* Fix missing entries for FigurinesFootsoldier

* Add 1 dragon name (#36846)

* this is a commit you cannot skip

* why do you have to add a count why

* Remove steel sheet hull fixing (#33443)

* Remove steel sheet hull fixing

It's unintuitive that it's wasteful, there's not really any systems to NOT make it wasteful, and it's a UX trap. No this is not "noob trap", no. It's an UX issue because if hundreds of people do it over and over again without noticing anything wrong, well, something fails to properly note that there's an issue with what they are doing. Aka user experience issue. Aka not a problem with the user but the design.

Also could be a shitty doafter action that makes you wonder if something's wrong

* Why was this testing using steel of all things

* Automatic changelog update

* cleanup + add names to some entities (#36856)

* Remove redundant fields from `MovementSpeedModifierComponent` (#36859)

Delete _baseWalkSpeedVV and _baseSprintSpeedVV

* Cleanup warnings in NinjaSuitSystem (#36861)

Fix warnings in NinjaSuitSystem

* Modernize `GhostComponent` & Ghost API (#36858)

* Move CanReturnToBody to system

* Move CanGhostInteract to system

* Cleanup redundant datafields and viewvariables

* Document datafields

* Document component

* Add SetTimeOfDeath Entity<T> overload, obsolete old version

* Document public methods

* Cleanup obsoleted method calls

* Cleanup warning in `EmptyAllContainersBehaviour` (#36860)

Fix warning in EmptyAllContainersBehaviour

* Cleanup warnings in `SharedCryostorageSystem` (#36863)

Fix warnings in SharedCryostorageSystem

* Cleanup warnings in `CableSystem.Placer` (#36868)

* Fix warnings in CableSystem.Placer

* Formatting

* Cleanup warnings in `PolymorphSystem.Map` (#36869)

Fix warnings in PolymorphSystem.Map

* Cleanup warnings in `WorldgenConfigSystem` (#36864)

Fix warnings in WorldgenConfigSystem

* Move guardian sounds to component (#36870)

* Cleanup warnings in `SpawnSalvageMissionJob` (#36866)

* DoMapInitialize and SetMapPaused

* GridTileToLocal

* Formatting

* Remove unused variables

* Update Content.Server/Salvage/SpawnSalvageMissionJob.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Fix warnings in `ServerDbManager` (#36871)

Fix warnings in ServerDbManager

* pAI Software Catalog (#36857)

* initial commit

* add the shop and make it work

* add existing pai actions to the software shop

* added power monitor app

* killed the power and crew monitor software, too powercreepy

* fix test failures

* fix more test failures

* fix merge conflicts

* code changes to conform with review

* fix unintentional submodule update

* submodule update

* remove unused currency prototype ref

---------

Co-authored-by: archrbx <punk.gear5260@fastmail.com>

* New Salvage Ruin - Hydro Outpost (#36826)

* Automatic changelog update

* Make toy sword less obvious (#34199)

* YAML fuckery

* Remove toy_sword.rsi

Not a webedit btw

* Automatic changelog update

* Adds shorts/pants to ClothesMate vending machine (#35361)

* Clothesmate shorts

* matches price of vend to the new contents

* Moths can eat pills (#35609)

* Automatic changelog update

* Xenoborgs part 1 (#36830)

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Updated Syndicate and Ammo Contraband (#35102)

Co-authored-by: RedBookcase <crazykid1590@gmail.com>

* Automatic changelog update

* Put items inside cakes! (#31015)

* First commit

* I'm silly

* Please be it

* Some more fixes

* Cleanup

* fine!

* removed = false

* review

---------

Co-authored-by: Milon <milonpl.git@proton.me>

* Removed syndicate surgery duffel, added advanced circular saw to Medical Doctor uplink. (#35915)

* Removed syndicate surgery duffel, added advanced circular saw to Medical Doctor uplink.

* Update Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: RedBookcase <Usualmoves@gmail.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

* unremove surgery duffel

* unfunny

* Automatic changelog update

* fix NoCargoOrderArbitrage fail (#36878)

whoopsie

* Cotton Grilled Cheese Sandwich (#36135)

* Working entity.

* New sprite by MadeOfHeartAndStone

* Removed deadspace, changed attribution in meta.json

* review

---------

Co-authored-by: Milon <milonpl.git@proton.me>

* Automatic changelog update

* Meat Patty (#34896)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Remove beaker from the MaterialArbitrageTest whitelist (#36876)

* Turnstiles (#36313)

* construction rotation fix

* Turnstiles

* renaming

* review-slarticodefast-1

* mild attempts to fix (sorry sloth)

* move some more shit

* Remove engine dependency

* grid agnostic

* remove debug string

* fix json

* Update Content.Shared/Movement/Pulling/Systems/PullingSystem.cs

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Update Content.Shared/Movement/Pulling/Systems/PullingSystem.cs

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* remove pass delay for mispredict reasons.

* most minor of changes

* Give directional indicator on examine

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Genpop Closets & IDs (#36392)

* Genpop IDs and Lockers

* placeholder generation, no ui yet.

* UI

* Fix time offset

* fix meta.jsons

* big speller

* Scarkyo review

* Add turnstile prototypes

* make IDs recyclable

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>

* Automatic changelog update

* Fix small misc. turnstile issues (#36893)

* Fix small misc. turnstile issues

* more missing things

* quieter

* New Spawners, Modified Spawners, new Service/Theatre Airlock, and new Colorful Light Crate (#36750)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Automatic changelog update

* Disable shadows for observer pointlight (#36897)

no shadows

* Fix QSI bringing people into paused maps (#36834)

* Automatic changelog update

* Fix storage ui hovering over the hotbar (#36770)

* Turnstiles lower volume + access reader (#36900)

fixes

* Fix disposal unit flush animation (#30677)

* Fix disposal unit flush animation

* Revert "Fix disposal unit flush animation"

This reverts commit a596ecfd5f5368f87ef52cfb27884a8e000185c6.

* control by setting layer visibility rather than overwriting

* restore changes

* Correct IdentityBlocker to include specific outer clothing (#33085)

* Make IdentityBlocker include outerclothing

* Modify Correct Bit

* Fix mask/eye cobo

* Automatic changelog update

* Change some posters to be rules-compliant (#32734)

* Initial commit

* Minor edit

* it's very hard to fit "disorder"

* Revert No ERP poster, fix spawner

* Attribution

* Update text

* Missed poster spawner

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Automatic changelog update

* Cyborg Rebalance (#34186)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Automatic changelog update

* Reptilians Can Eat Orange Creamsicles (#36890)

* Automatic changelog update

* Add Bloodstream to Goliaths (#33305)

* Automatic changelog update

* Nerf mining hardsuit's effectiveness against bullets and bombs. (#31450)

* Automatic changelog update

* Controls page guidebook rework 2025 Q1 (#36363)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Lower interdyne herbals TC cost (#36841)

* Automatic changelog update

* cleanup instruments yml (#32262)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Automatic changelog update

* [FIX] Rubber now uneatable (#34543)

* Releasing an under-pressure lockout is now a verb (#36910)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* fix changelog (#36915)

* Fix for ghosts being unable to follow the AI when it uses a holopad (#36355)

* Initial commit

* Added to-do

* Automatic changelog update

* Fix random maints room deleting whatever was already there (#36605)

* Fix donuts tags breaking the bounty (#36903)

* Automatic changelog update

* Make 10u of "Atomic Bomb" drink instead of 11u (#36921)

changed atomic bomb recipe

* Automatic changelog update

* PKA Modkits + Rebalance (#31247)

* Automatic changelog update

* Remove a redundant trycomp from TileAnomalySystem (#36924)

* remove a redundant check

* revert this space.

* Land mine armament (#33883)

* Land Mine is now armable, it will not explode unless armed.

* Land Mine is now armable, it will not explode unless armed.

* Explicitly have Armed as false

* SharedLandMineSystem.cs adds the "Arm"-verb in "Content.Shared" with the Arming logic being implemented in "Content.Server"

* Land Mines now blink only when armed.

* Added prediction components, moved logic to SharedLandMineSystem.cs and inherit it in client content.

* Accessing the datafield directly instead of using methods

* Mines are now armed by default with a unarmed prototype

* Land mine now shows if it is armed when examined and in range.

* Landmine is unarmed by default with an armed variant for mapping purposes.

* Removed properties that were already defined by inheritance.

* Access the bool directly from the component

* Add booleans to change if the Arm-verb is showed and if examining the mine shows the status.

* Added status message for unarmed mine, removed using PushGroup since only one string is displayed.

* Added properties to the explosive floor sign to ensure that it is armed, not showing neither status nor arm-verb.

* The prototypes work now as before with added unarmed versions. Sprite is now only one toggable layer.

* Make the craftable land mine unarmed.

* Refactored the arming mechanic into own component and system.

* Reverted the explosive wet floor sign to previous prototype and added the Armable component and ItemToggle to the landmines.

* Moved the examination strings from land-mines.ftl to armable.ftl.

* Removed unused property.

* Formatting and fixing imports

* Added prefixes to the ftl naming. Moved LocId from system to component

* Added documentation. Moved check for armable to HandleStepTriggerAttempt.
Moved the LocId to component.

* Removed the TryArming method. Added documentation.

* Removed unnecessary TryComp

* Simplified the logic for the trigger attempt

* HasComp instead of TryComp on logic

* EmoGarbage Review

---------

Co-authored-by: Franz - Josef Björck <kaiserbirch@proton.me>
Co-authored-by: EmoGarbage404 <retron404@gmail.com>

* Add Cotton Burgers (#36405)

* Adds cotton burgers

* Rephrased copyright

* Added an extra comment

* Adds CottonBurger to tags.yml, Not sure if i am supposed to do this or not.

* Reordered Cotton bun YAML, and fixed overwritten tags

* Merge issue fix?

* Add experiment plushie and remove rubber chicken from cotton burgers

* Minor comment change

---------

Co-authored-by: beck-thompson <beck314159@hotmail.com>

* hide light-switches from build menu (#34664)

* Automatic changelog update

* Fixed stinger grenade lag spikes (#36641)

* Fixed stinger lag spikes

* Simplify nullable checks

* More cleanup of projectile grenades

* Remove null default from ShootProjectile

* Sheet-meister 2000 Cloth recipe (#32676)

* Sheet-meister 2000 can now make rolls of cloth

* Small Cleanup

* resolve conflicts

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Automatic changelog update

* Clear MIDI masters properly to avoid replay freezes (#36809)

While trying to play a replay I noticed that the replay would freeze
when seeking in some cases. After some debugging, I discovered that two
MIDI renderers had each other as master, which caused an infinite loop
processing MIDI events.

I'm not entirely sure of the sequence of events that leads to this
during replay playback, but I did notice that MIDI render masters are
never set to null. This is in the best case just a memory leak, in the
worst case probably the source of the bug, so... I fixed that.

* Changed soundGunshot for Pulse Pistol and Pulse Carbine from laser_cannon to laser3 (#36952)

* Automatic changelog update

* The Atmos A Airlock (#36376)

* airlocks

* Update meta.json

Added my modification in the meta

* Changed the storage sizes of different swords. (#36564)

Co-authored-by: RedBookcase <Usualmoves@gmail.com>

* Automatic changelog update

* Fix autorecharge (#36955)

* Fix inflatable barriers finishing instantly if canceled! (#36937)

Fix

* Automatic changelog update

* Only sec glasses can show contraband: second attempt (#36412)

* Add base code for cheking contraband in hud

* Fix missing using in InventorySystem.Relay

* Fix errors and update HUD yml

* Add show contraband with component on entity

* fix component description

* Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>

* Update "if" for check if ent hasComp in contrabandSystem

* Remove << InventorySystem.Relay.cs

* Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/CCVar/CCVars.Game.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Fix partial class ShowContrabandSystem

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Contraband/ShowContrabandDetailsComponent.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Update Content.Shared/Inventory/InventorySystem.Relay.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Some update ShowContrabandSystem

* Try with record struct

* back again ti default class with EntityEventArgs

* Remove EntityEventArgs

* Finally use record struct

---------

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Automatic changelog update

* Resolve a warning in SharedAnomalySystem and quell some linter whining. (#36939)

* resolve a warning and deal with some linter whining.

* Update Content.Shared/Anomaly/SharedAnomalySystem.cs

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>

* Automatic changelog update

* Truncate lathe announcement lists (#36945)

* Automatic changelog update

* Descriptions for .30 Rifle (#36958)

Initial commit

* CMO Hardsuit: Zombification Resistance tweak (#36957)

initial commit

* Automatic changelog update

* Adds Parcel Wrap (#34471)

* Parcel Wrap

* fix TG sprite licenses
update attribution on modified `unwrapped` sprite to better conform to CC's guidance

* ContainerContainer test failure fix

* Just easy changes for now.

* Imagine building your code before pushing it for review

* The rest of the PR comments

* PR comments

* more comments + cargo orderability

* whitespace: deduplicated.

* use limitedcharges
replace mostly-duped client/server with if(onserver)

* cabinet perspective sprites

* web edit detected

fite me

* @ps3moira 's new sprites for me :)

* add a touch of attribution

* EmoGarbage Review

* Merge with master

* Merge with master

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>

* Automatic changelog update

* Ammo Mag + Speedloader Inhand Sprites (#34235)

* Added inhand visuals to (most) ammo magazines and speedloaders

* whoops mixed up a single inhand on the rifle mag

* Didn't realize rubber ammo got removed.

* added attributions

* adjusted inhand visuals to account for magazine types

* missed one :eye:👁️

---------

Co-authored-by: EmoGarbage404 <retron404@gmail.com>

* Automatic changelog update

* New Science Biosuit Locker Sprite (#36929)

* first commit, slightly broken

* fixed meta json

* reverse accidental cmo inclusion

* Automatic changelog update

* Remove legacy cargo shuttle code/prototypes (#36967)

* Automatic changelog update

* Paramedic suits adjustments (#36707)

* Changes

* meta

* Battery (SMES/substation) interface (#36386)

* Add ENERGYWATTHOURS() loc function

Takes in joules (energy), displays as watt-hours.

* Add simple OnOffButton control

* Re-add Inset style class

This was sloppily removed at some point?? Whatever, I need it.

* Add helper functions for setting title/guidebook IDs on FancyWindow

Reagent dispenser uses these, more in the next commits.

* Add BuiPredictionState helper

This enables me to implement coarse prediction manually in the battery UI.

Basically it's a local buffer of predicted inputs that can easily be replayed against future BUI states from the server.

* Add input coalescing infrastructure

I ran into the following problem: Robust's Slider control absolutely *spams* input events, to such a degree that it actually causes issues for the networking layer if directly passed through. For something like a slider, we just need to send the most recent value.

There is no good way for us to handle this in the control itself, as it *really* needs to happen in PreEngine. For simplicity reasons (for BUIs) I came to the conclusion it's best if it's there, as it's *before* any new states from the server can be applied. We can't just do this in Update() or something on the control as the timing just doesn't line up.

I made a content system, BuiPreTickUpdateSystem, that runs in the ModRunLevel.PreEngine phase to achieve this. It runs a method on a new IBuiPreTickUpdate interface on all open BUIs. They can then implement their own coalescing logic.

In the simplest case, this coalescing logic can just be "save the last value, and if we have any new value since the last update, send an input event." This is what the new InputCoalescer<T> type is for.

Adding new coalescing logic should be possible in the future, of course. It's all just small helpers.

* Battery interface

This adds a proper interface to batteries (SMES/substation). Players can turn IO on and off, and they can change charge and discharge rate. There's also a ton of numbers and stuff. It looks great.

This actually enables charge and discharge rates to be changed for these devices. The settings for both have been set between 5kW and 150kW.

* Oops, forgot to remove these style class defs.

* Automatic changelog update

* Use RMC mob collision values (#36851)

Use RMC movement values

General feedback was it's too slow to push through people but this still prevents stacking so.

* Automatic changelog update

* early merge fix AAAAAA validcheck

* Cherry Pick Round-start Solar Variation (#36825)

* Roundstart Variation for Solar Panels (#86)

* Added roundstart variation for solar panels

* Removed HV cable spawner since i don't want to bother with mapping them

* Solar Panel Variation Pass Fix (#96)

Added a second variation pass for regular solar assemblies, since otherwise they would spawn both it and the broken variety

* Reorganized everything to no longer be in the _Moffstation subdirectory

* Removed a forgotten tag for Moffstation

* Removed the moffstation namespace settings

* Update Content.Server/GameTicking/Rules/VariationPass/Components/SolarPanelReplaceVariationPassComponent.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

* Update Content.Server/GameTicking/Rules/VariationPass/Components/ReplacementMarkers/SolarPanelReplacementMarkerComponent.cs

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

---------

Co-authored-by: Tayrtahn <tayrtahn@gmail.com>

* disable solar panel variation

* put surgery borg module icons in _Shitmed

* the big fix

* abstract the right recipe

* goida

* no milk

* update coscult code

* update coscult objectives

* migrate SignCansScience away

* goida

* update engine maybe fix test

* GET OUT OF MY HEAD

* i give up

---------

Signed-off-by: Prole <172158352+Prole0@users.noreply.github.com>
Co-authored-by: Alice4267 <psycopompass14@gmail.com>
Co-authored-by: PJBot <pieterjan.briers+bot@gmail.com>
Co-authored-by: Pgriha <133212269+Pgriha@users.noreply.github.com>
Co-authored-by: Milon <milonpl.git@proton.me>
Co-authored-by: TakoDragon <69509841+BackeTako@users.noreply.github.com>
Co-authored-by: Hyper B <137433177+HyperB1@users.noreply.github.com>
Co-authored-by: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Co-authored-by: K-Dynamic <20566341+K-Dynamic@users.noreply.github.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Co-authored-by: YoungThug <ramialanbagy@gmail.com>
Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com>
Co-authored-by: Prole <172158352+Prole0@users.noreply.github.com>
Co-authored-by: RedBookcase <crazykid1590@gmail.com>
Co-authored-by: RedBookcase <Usualmoves@gmail.com>
Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
Co-authored-by: Booblesnoot42 <108703193+Booblesnoot42@users.noreply.github.com>
Co-authored-by: UBlueberry <161545003+UBlueberry@users.noreply.github.com>
Co-authored-by: Banedon <15725971+Lanedon@users.noreply.github.com>
Co-authored-by: Lanedon <matth.galvez@gmail>
Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: uhbg <uhbg@users.noreply.github.com>
Co-authored-by: uhbg <29674581+uhbg@users.noreply.github.com>
Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Co-authored-by: Jackson Langley <tripwiregamer@gmail.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: Entvari <195642967+Entvari@users.noreply.github.com>
Co-authored-by: dffdff2423 <dffdff2423@gmail.com>
Co-authored-by: āda <ss.adasts@gmail.com>
Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
Co-authored-by: Spessmann <156740760+Spessmann@users.noreply.github.com>
Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com>
Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Co-authored-by: Phooooooooooooooooooooooooooooooosphate <184853112+Phooooooooooooooooooooooooooooooosphate@users.noreply.github.com>
Co-authored-by: TytosB <54259736+TytosB@users.noreply.github.com>
Co-authored-by: Łukasz Lindert <lukasz.lindert@protonmail.com>
Co-authored-by: Hrosts <35345601+Hrosts@users.noreply.github.com>
Co-authored-by: T <theo75cg@gmail.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com>
Co-authored-by: J <billsmith116@gmail.com>
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Co-authored-by: EmoGarbage404 <retron404@gmail.com>
Co-authored-by: Ghagliiarghii <68826635+Ghagliiarghii@users.noreply.github.com>
Co-authored-by: Michael <107807667+Doc-Michael@users.noreply.github.com>
Co-authored-by: mubururu_ <139181059+muburu@users.noreply.github.com>
Co-authored-by: pathetic meowmeow <uhhadd@gmail.com>
Co-authored-by: ScarKy0 <scarky0@onet.eu>
Co-authored-by: godisdeadLOL <169250097+godisdeadLOL@users.noreply.github.com>
Co-authored-by: YourUsername <you@example.com>
Co-authored-by: beck-thompson <beck314159@hotmail.com>
Co-authored-by: Golden Can <greentopcan@gmail.com>
Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
Co-authored-by: Ilya246 <57039557+Ilya246@users.noreply.github.com>
Co-authored-by: Zachary Yona <58833995+Magicalus@users.noreply.github.com>
Co-authored-by: Zachary Yona <magicalusf@gmail.com>
Co-authored-by: Hanz <41141796+Hanzdegloker@users.noreply.github.com>
Co-authored-by: catlord <catlord0009@gmail.com>
Co-authored-by: poklj <compgeek223@gmail.com>
Co-authored-by: Vladislav Suchkov <20380250+murolem@users.noreply.github.com>
Co-authored-by: kosticia <kosticia46@gmail.com>
Co-authored-by: Smith <182301147+AgentSmithRadio@users.noreply.github.com>
Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Co-authored-by: T-Stalker <43253663+DogZeroX@users.noreply.github.com>
Co-authored-by: Saphire Lattice <lattice@saphi.re>
Co-authored-by: ArchRBX <5040911+ArchRBX@users.noreply.github.com>
Co-authored-by: archrbx <punk.gear5260@fastmail.com>
Co-authored-by: Southbridge <7013162+southbridge-fur@users.noreply.github.com>
Co-authored-by: No Elka <125199100+NoElkaTheGod@users.noreply.github.com>
Co-authored-by: PotRoastPiggy <121025443+PotRoastPiggy@users.noreply.github.com>
Co-authored-by: Samuka-C <47865393+Samuka-C@users.noreply.github.com>
Co-authored-by: Coolsurf6 <coolsurf24@yahoo.com.au>
Co-authored-by: beck-thompson <107373427+beck-thompson@users.noreply.github.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: SG6732 <151011904+SG6732@users.noreply.github.com>
Co-authored-by: themias <89101928+themias@users.noreply.github.com>
Co-authored-by: Preston Smith <92108534+thetolbean@users.noreply.github.com>
Co-authored-by: Nox <nebulousnox38@gmail.com>
Co-authored-by: Victor Shen <71985089+Vexerot@users.noreply.github.com>
Co-authored-by: Alzore <140123969+Blackern5000@users.noreply.github.com>
Co-authored-by: Kresny <krzeszny@gmail.com>
Co-authored-by: chromiumboy <50505512+chromiumboy@users.noreply.github.com>
Co-authored-by: Radezolid <snappednexus@gmail.com>
Co-authored-by: Kiri1674 <107365596+Kiri-Yoshikage@users.noreply.github.com>
Co-authored-by: kaiserbirch <150971100+kaiserbirch@users.noreply.github.com>
Co-authored-by: Franz - Josef Björck <kaiserbirch@proton.me>
Co-authored-by: Wolfkey-SomeoneElseTookMyUsername <wolfkey75@gmail.com>
Co-authored-by: TGRCDev <tgrc@tgrc.dev>
Co-authored-by: OnyxTheBrave <131422822+OnyxTheBrave@users.noreply.github.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Co-authored-by: SyaoranFox <99053675+SyaoranFox@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: qrwas <aleksandr.vernigora93@gmail.com>
Co-authored-by: UpAndLeaves <92269094+Alpha-Two@users.noreply.github.com>
Co-authored-by: Centronias <me@centronias.com>
Co-authored-by: Tiniest Shark <head.rebel@yahoo.com>
Co-authored-by: KingFroozy <140668342+KingFroozy@users.noreply.github.com>
2025-05-06 19:35:03 -04:00

1514 lines
63 KiB
C#

using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Chat;
using Content.Shared.CombatMode;
using Content.Shared.Database;
using Content.Shared.Ghost;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Input;
using Content.Shared.Interaction.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Physics;
using Content.Shared.Players.RateLimiting;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Strip;
using Content.Shared.Tag;
using Content.Shared.Timing;
using Content.Shared.UserInterface;
using Content.Shared.Verbs;
using Content.Shared.Wall;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Content.Shared.Interaction
{
/// <summary>
/// Governs interactions during clicking on entities
/// </summary>
[UsedImplicitly]
public abstract partial class SharedInteractionSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _broadphase = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedVerbSystem _verbSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly PullingSystem _pullSystem = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedUserInterfaceSystem _ui = default!;
[Dependency] private readonly SharedStrippableSystem _strippable = default!;
[Dependency] private readonly SharedPlayerRateLimitManager _rateLimit = default!;
[Dependency] private readonly ISharedChatManager _chat = default!;
private EntityQuery<IgnoreUIRangeComponent> _ignoreUiRangeQuery;
private EntityQuery<FixturesComponent> _fixtureQuery;
private EntityQuery<ItemComponent> _itemQuery;
private EntityQuery<PhysicsComponent> _physicsQuery;
private EntityQuery<HandsComponent> _handsQuery;
private EntityQuery<InteractionRelayComponent> _relayQuery;
private EntityQuery<CombatModeComponent> _combatQuery;
private EntityQuery<WallMountComponent> _wallMountQuery;
private EntityQuery<UseDelayComponent> _delayQuery;
private EntityQuery<ActivatableUIComponent> _uiQuery;
private const CollisionGroup InRangeUnobstructedMask = CollisionGroup.Impassable | CollisionGroup.InteractImpassable;
public const float InteractionRange = 1.5f;
public const float InteractionRangeSquared = InteractionRange * InteractionRange;
public const float MaxRaycastRange = 100f;
public const string RateLimitKey = "Interaction";
private static readonly ProtoId<TagPrototype> BypassInteractionRangeChecksTag = "BypassInteractionRangeChecks";
public delegate bool Ignored(EntityUid entity);
public override void Initialize()
{
_ignoreUiRangeQuery = GetEntityQuery<IgnoreUIRangeComponent>();
_fixtureQuery = GetEntityQuery<FixturesComponent>();
_itemQuery = GetEntityQuery<ItemComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();
_handsQuery = GetEntityQuery<HandsComponent>();
_relayQuery = GetEntityQuery<InteractionRelayComponent>();
_combatQuery = GetEntityQuery<CombatModeComponent>();
_wallMountQuery = GetEntityQuery<WallMountComponent>();
_delayQuery = GetEntityQuery<UseDelayComponent>();
_uiQuery = GetEntityQuery<ActivatableUIComponent>();
SubscribeLocalEvent<BoundUserInterfaceCheckRangeEvent>(HandleUserInterfaceRangeCheck);
// TODO make this a broadcast event subscription again when engine has updated.
SubscribeLocalEvent<UserInterfaceComponent, BoundUserInterfaceMessageAttempt>(OnBoundInterfaceInteractAttempt);
SubscribeAllEvent<InteractInventorySlotEvent>(HandleInteractInventorySlotEvent);
SubscribeLocalEvent<UnremoveableComponent, ContainerGettingRemovedAttemptEvent>(OnRemoveAttempt);
SubscribeLocalEvent<UnremoveableComponent, GotUnequippedEvent>(OnUnequip);
SubscribeLocalEvent<UnremoveableComponent, GotUnequippedHandEvent>(OnUnequipHand);
SubscribeLocalEvent<UnremoveableComponent, DroppedEvent>(OnDropped);
CommandBinds.Builder
.Bind(ContentKeyFunctions.AltActivateItemInWorld,
new PointerInputCmdHandler(HandleAltUseInteraction))
.Bind(EngineKeyFunctions.Use,
new PointerInputCmdHandler(HandleUseInteraction))
.Bind(ContentKeyFunctions.ActivateItemInWorld,
new PointerInputCmdHandler(HandleActivateItemInWorld))
.Bind(ContentKeyFunctions.TryPullObject,
new PointerInputCmdHandler(HandleTryPullObject))
.Register<SharedInteractionSystem>();
_rateLimit.Register(RateLimitKey,
new RateLimitRegistration(CCVars.InteractionRateLimitPeriod,
CCVars.InteractionRateLimitCount,
null,
CCVars.InteractionRateLimitAnnounceAdminsDelay,
RateLimitAlertAdmins)
);
InitializeBlocking();
}
private void RateLimitAlertAdmins(ICommonSession session)
{
_chat.SendAdminAlert(Loc.GetString("interaction-rate-limit-admin-announcement", ("player", session.Name)));
}
public override void Shutdown()
{
CommandBinds.Unregister<SharedInteractionSystem>();
base.Shutdown();
}
/// <summary>
/// Check that the user that is interacting with the BUI is capable of interacting and can access the entity.
/// </summary>
private void OnBoundInterfaceInteractAttempt(Entity<UserInterfaceComponent> ent, ref BoundUserInterfaceMessageAttempt ev)
{
_uiQuery.TryComp(ev.Target, out var aUiComp);
if (!_actionBlockerSystem.CanInteract(ev.Actor, ev.Target))
{
// We permit ghosts to open uis unless explicitly blocked
if (ev.Message is not OpenBoundInterfaceMessage
|| !HasComp<GhostComponent>(ev.Actor)
|| aUiComp?.BlockSpectators == true)
{
ev.Cancel();
return;
}
}
var range = _ui.GetUiRange(ev.Target, ev.UiKey);
// As long as range>0, the UI frame updates should have auto-closed the UI if it is out of range.
DebugTools.Assert(range <= 0 || UiRangeCheck(ev.Actor, ev.Target, range));
if (range <= 0 && !IsAccessible(ev.Actor, ev.Target))
{
ev.Cancel();
return;
}
if (aUiComp == null)
return;
if (aUiComp.SingleUser && aUiComp.CurrentSingleUser != null && aUiComp.CurrentSingleUser != ev.Actor)
{
ev.Cancel();
return;
}
if (aUiComp.RequiresComplex && !_actionBlockerSystem.CanComplexInteract(ev.Actor))
ev.Cancel();
}
private bool UiRangeCheck(Entity<TransformComponent?> user, Entity<TransformComponent?> target, float range)
{
if (!Resolve(target, ref target.Comp))
return false;
if (user.Owner == target.Owner)
return true;
// Fast check: if the user is the parent of the entity (e.g., holding it), we always assume that it is in range
if (target.Comp.ParentUid == user.Owner)
return true;
return InRangeAndAccessible(user, target, range) || _ignoreUiRangeQuery.HasComp(user);
}
/// <summary>
/// Prevents an item with the Unremovable component from being removed from a container by almost any means
/// </summary>
private void OnRemoveAttempt(EntityUid uid, UnremoveableComponent item, ContainerGettingRemovedAttemptEvent args)
{
args.Cancel();
}
/// <summary>
/// If item has DeleteOnDrop true then item will be deleted if removed from inventory, if it is false then item
/// loses Unremoveable when removed from inventory (gibbing).
/// </summary>
private void OnUnequip(EntityUid uid, UnremoveableComponent item, GotUnequippedEvent args)
{
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
else
PredictedQueueDel(uid);
}
private void OnUnequipHand(EntityUid uid, UnremoveableComponent item, GotUnequippedHandEvent args)
{
if (TerminatingOrDeleted(uid)) return; // DeltaV
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
else
PredictedQueueDel(uid);
}
private void OnDropped(EntityUid uid, UnremoveableComponent item, DroppedEvent args)
{
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
else
PredictedQueueDel(uid);
}
private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
if (!ValidateClientInput(session, coords, uid, out var userEntity))
{
Log.Info($"TryPullObject input validation failed");
return true;
}
//is this user trying to pull themself?
if (userEntity.Value == uid)
return false;
if (Deleted(uid))
return false;
if (!InRangeUnobstructed(userEntity.Value, uid, popup: true))
return false;
_pullSystem.TogglePull(uid, userEntity.Value);
return false;
}
/// <summary>
/// Handles the event were a client uses an item in their inventory or in their hands, either by
/// alt-clicking it or pressing 'E' while hovering over it.
/// </summary>
private void HandleInteractInventorySlotEvent(InteractInventorySlotEvent msg, EntitySessionEventArgs args)
{
var item = GetEntity(msg.ItemUid);
// client sanitization
if (!TryComp(item, out TransformComponent? itemXform) || !ValidateClientInput(args.SenderSession, itemXform.Coordinates, item, out var user))
{
Log.Info($"Inventory interaction validation failed. Session={args.SenderSession}");
return;
}
// We won't bother to check that the target item is ACTUALLY in an inventory slot. UserInteraction() and
// InteractionActivate() should check that the item is accessible. So.. if a user wants to lie about an
// in-reach item being used in a slot... that should have no impact. This is functionally the same as if
// they had somehow directly clicked on that item.
if (msg.AltInteract)
// Use 'UserInteraction' function - behaves as if the user alt-clicked the item in the world.
UserInteraction(user.Value, itemXform.Coordinates, item, msg.AltInteract);
else
// User used 'E'. We want to activate it, not simulate clicking on the item
InteractionActivate(user.Value, item);
}
public bool HandleAltUseInteraction(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
// client sanitization
if (!ValidateClientInput(session, coords, uid, out var user))
{
Log.Info($"Alt-use input validation failed");
return true;
}
UserInteraction(user.Value, coords, uid, altInteract: true, checkAccess: ShouldCheckAccess(user.Value));
return false;
}
public bool HandleUseInteraction(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
// client sanitization
if (!ValidateClientInput(session, coords, uid, out var userEntity))
{
Log.Info($"Use input validation failed");
return true;
}
UserInteraction(userEntity.Value, coords, !Deleted(uid) ? uid : null, checkAccess: ShouldCheckAccess(userEntity.Value));
return false;
}
private bool ShouldCheckAccess(EntityUid user)
{
// This is for Admin/mapping convenience. If ever there are other ghosts that can still interact, this check
// might need to be more selective.
return !_tagSystem.HasTag(user, BypassInteractionRangeChecksTag);
}
/// <summary>
/// Returns true if the specified entity should hand interact with the target instead of attacking
/// </summary>
/// <param name="user">The user interacting in combat mode</param>
/// <param name="target">The target of the interaction</param>
/// <returns></returns>
public bool CombatModeCanHandInteract(EntityUid user, EntityUid? target)
{
// Always allow attack in these cases
if (target == null || !_handsQuery.TryComp(user, out var hands) || hands.ActiveHand?.HeldEntity is not null)
return false;
// Only eat input if:
// - Target isn't an item
// - Target doesn't cancel should-interact event
// This is intended to allow items to be picked up in combat mode,
// but to also allow items to force attacks anyway (like mobs which are items, e.g. mice)
if (!_itemQuery.HasComp(target))
return false;
var combatEv = new CombatModeShouldHandInteractEvent();
RaiseLocalEvent(target.Value, ref combatEv);
if (combatEv.Cancelled)
return false;
return true;
}
/// <summary>
/// Resolves user interactions with objects.
/// </summary>
/// <remarks>
/// Checks Whether combat mode is enabled and whether the user can actually interact with the given entity.
/// </remarks>
/// <param name="altInteract">Whether to use default or alternative interactions (usually as a result of
/// alt+clicking). If combat mode is enabled, the alternative action is to perform the default non-combat
/// interaction. Having an item in the active hand also disables alternative interactions.</param>
public void UserInteraction(
EntityUid user,
EntityCoordinates coordinates,
EntityUid? target,
bool altInteract = false,
bool checkCanInteract = true,
bool checkAccess = true,
bool checkCanUse = true)
{
if (_relayQuery.TryComp(user, out var relay) && relay.RelayEntity is not null)
{
// TODO this needs to be handled better. This probably bypasses many complex can-interact checks in weird roundabout ways.
if (_actionBlockerSystem.CanInteract(user, target))
{
UserInteraction(relay.RelayEntity.Value,
coordinates,
target,
altInteract,
checkCanInteract,
checkAccess,
checkCanUse);
return;
}
}
if (target != null && Deleted(target.Value))
return;
if (!altInteract && _combatQuery.TryComp(user, out var combatMode) && combatMode.IsInCombatMode)
{
if (!CombatModeCanHandInteract(user, target))
return;
}
if (!ValidateInteractAndFace(user, coordinates))
return;
if (altInteract && target != null)
{
// Perform alternative interactions, using context menu verbs.
// These perform their own range, can-interact, and accessibility checks.
AltInteract(user, target.Value);
return;
}
if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, target))
return;
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
// Also checks if the item is accessible via some storage UI (e.g., open backpack)
if (checkAccess && target != null && !IsAccessible(user, target.Value))
return;
var inRangeUnobstructed = target == null
? !checkAccess || InRangeUnobstructed(user, coordinates)
: !checkAccess || InRangeUnobstructed(user, target.Value); // permits interactions with wall mounted entities
// empty-hand interactions
// combat mode hand interactions will always be true here -- since
// they check this earlier before returning in
if (!TryGetUsedEntity(user, out var used, checkCanUse))
{
if (inRangeUnobstructed && target != null)
InteractHand(user, target.Value);
return;
}
if (target == used)
{
UseInHandInteraction(user, target.Value, checkCanUse: false, checkCanInteract: false);
return;
}
if (inRangeUnobstructed && target != null)
{
InteractUsing(
user,
used.Value,
target.Value,
coordinates,
checkCanInteract: false,
checkCanUse: false);
return;
}
InteractUsingRanged(
user,
used.Value,
target,
coordinates,
inRangeUnobstructed);
}
private bool IsDeleted(EntityUid uid)
{
return TerminatingOrDeleted(uid) || EntityManager.IsQueuedForDeletion(uid);
}
private bool IsDeleted(EntityUid? uid)
{
//optional / null entities can pass this validation check. I.e., is-deleted returns false for null uids
return uid != null && IsDeleted(uid.Value);
}
public void InteractHand(EntityUid user, EntityUid target)
{
if (IsDeleted(user) || IsDeleted(target))
return;
var complexInteractions = _actionBlockerSystem.CanComplexInteract(user);
if (!complexInteractions)
{
InteractionActivate(user,
target,
checkCanInteract: false,
checkUseDelay: true,
checkAccess: false,
complexInteractions: complexInteractions,
checkDeletion: false);
return;
}
// allow for special logic before main interaction
var ev = new BeforeInteractHandEvent(target);
RaiseLocalEvent(user, ev);
if (ev.Handled)
{
_adminLogger.Add(LogType.InteractHand, LogImpact.Low, $"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target}, but it was handled by another system");
return;
}
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(target));
// all interactions should only happen when in range / unobstructed, so no range check is needed
var message = new InteractHandEvent(user, target);
RaiseLocalEvent(target, message, true);
_adminLogger.Add(LogType.InteractHand, LogImpact.Low, $"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target}");
DoContactInteraction(user, target, message);
if (message.Handled)
return;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(target));
// Else we run Activate.
InteractionActivate(user,
target,
checkCanInteract: false,
checkUseDelay: true,
checkAccess: false,
complexInteractions: complexInteractions,
checkDeletion: false);
}
public void InteractUsingRanged(EntityUid user, EntityUid used, EntityUid? target,
EntityCoordinates clickLocation, bool inRangeUnobstructed)
{
if (IsDeleted(user) || IsDeleted(used) || IsDeleted(target))
return;
if (target != null)
{
_adminLogger.Add(
LogType.InteractUsing,
LogImpact.Low,
$"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target} using {ToPrettyString(used):used}");
}
else
{
_adminLogger.Add(
LogType.InteractUsing,
LogImpact.Low,
$"{ToPrettyString(user):user} interacted with *nothing* using {ToPrettyString(used):used}");
}
if (RangedInteractDoBefore(user, used, target, clickLocation, inRangeUnobstructed, checkDeletion: false))
return;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used) && !IsDeleted(target));
if (target != null)
{
var rangedMsg = new RangedInteractEvent(user, used, target.Value, clickLocation);
RaiseLocalEvent(target.Value, rangedMsg, true);
// We contact the USED entity, but not the target.
DoContactInteraction(user, used, rangedMsg);
if (rangedMsg.Handled)
return;
}
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used) && !IsDeleted(target));
InteractDoAfter(user, used, target, clickLocation, inRangeUnobstructed, checkDeletion: false);
}
protected bool ValidateInteractAndFace(EntityUid user, EntityCoordinates coordinates)
{
// Verify user is on the same map as the entity they clicked on
if (_transform.GetMapId(coordinates) != Transform(user).MapID)
return false;
if (!HasComp<NoRotateOnInteractComponent>(user))
_rotateToFaceSystem.TryFaceCoordinates(user, _transform.ToMapCoordinates(coordinates).Position);
return true;
}
/// <summary>
/// Traces a ray from coords to otherCoords and returns the length
/// of the vector between coords and the ray's first hit.
/// </summary>
/// <param name="origin">Set of coordinates to use.</param>
/// <param name="other">Other set of coordinates to use.</param>
/// <param name="collisionMask">the mask to check for collisions</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <returns>Length of resulting ray.</returns>
public float UnobstructedDistance(
MapCoordinates origin,
MapCoordinates other,
int collisionMask = (int) InRangeUnobstructedMask,
Ignored? predicate = null)
{
var dir = other.Position - origin.Position;
if (dir.LengthSquared().Equals(0f))
return 0f;
predicate ??= _ => false;
var ray = new CollisionRay(origin.Position, dir.Normalized(), collisionMask);
var rayResults = _broadphase.IntersectRayWithPredicate(origin.MapId, ray, dir.Length(), predicate.Invoke, false).ToList();
if (rayResults.Count == 0)
return dir.Length();
return (rayResults[0].HitPos - origin.Position).Length();
}
/// <summary>
/// Checks that these coordinates are within a certain distance without any
/// entity that matches the collision mask obstructing them.
/// If the <paramref name="range"/> is zero or negative,
/// this method will only check if nothing obstructs the two sets
/// of coordinates.
/// </summary>
/// <param name="origin">Set of coordinates to use.</param>
/// <param name="other">Other set of coordinates to use.</param>
/// <param name="range">
/// Maximum distance between the two sets of coordinates.
/// </param>
/// <param name="collisionMask">The mask to check for collisions.</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <param name="checkAccess">Perform range checks</param>
/// <returns>
/// True if the two points are within a given range without being obstructed.
/// </returns>
public bool InRangeUnobstructed(
MapCoordinates origin,
MapCoordinates other,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null,
bool checkAccess = true)
{
// Have to be on same map regardless.
if (other.MapId != origin.MapId)
return false;
if (!checkAccess)
return true;
var dir = other.Position - origin.Position;
var length = dir.Length();
// If range specified also check it
if (range > 0f && length > range)
return false;
if (MathHelper.CloseTo(length, 0))
return true;
predicate ??= _ => false;
if (length > MaxRaycastRange)
{
Log.Warning("InRangeUnobstructed check performed over extreme range. Limiting CollisionRay size.");
length = MaxRaycastRange;
}
var ray = new CollisionRay(origin.Position, dir.Normalized(), (int) collisionMask);
var rayResults = _broadphase.IntersectRayWithPredicate(origin.MapId, ray, length, predicate.Invoke, false).ToList();
return rayResults.Count == 0;
}
public bool InRangeUnobstructed(
Entity<TransformComponent?> origin,
Entity<TransformComponent?> other,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null,
bool popup = false,
bool overlapCheck = true)
{
if (!Resolve(other, ref other.Comp))
return false;
var ev = new InRangeOverrideEvent(origin, other);
RaiseLocalEvent(origin, ref ev);
if (ev.Handled)
{
return ev.InRange;
}
return InRangeUnobstructed(origin,
other,
other.Comp.Coordinates,
other.Comp.LocalRotation,
range,
collisionMask,
predicate,
popup,
overlapCheck);
}
/// <summary>
/// Checks that two entities are within a certain distance without any
/// entity that matches the collision mask obstructing them.
/// If the <paramref name="range"/> is zero or negative,
/// this method will only check if nothing obstructs the two entities.
/// This function will also check whether the other entity is a wall-mounted entity. If it is, it will
/// automatically ignore some obstructions.
/// </summary>
/// <param name="origin">The first entity to use.</param>
/// <param name="other">Other entity to use.</param>
/// <param name="otherAngle">The local rotation to use for the other entity.</param>
/// <param name="range">
/// Maximum distance between the two entities.
/// </param>
/// <param name="collisionMask">The mask to check for collisions.</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <param name="popup">
/// Whether or not to popup a feedback message on the origin entity for
/// it to see.
/// </param>
/// <param name="otherCoordinates">The coordinates to use for the other entity.</param>
/// <returns>
/// True if the two points are within a given range without being obstructed.
/// </returns>
/// <param name="overlapCheck">If true, if the broadphase query returns an overlap (0f distance) this function will early out true with no raycast made.</param>
public bool InRangeUnobstructed(
Entity<TransformComponent?> origin,
Entity<TransformComponent?> other,
EntityCoordinates otherCoordinates,
Angle otherAngle,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null,
bool popup = false,
bool overlapCheck = true)
{
Ignored combinedPredicate = e => e == origin.Owner || (predicate?.Invoke(e) ?? false);
var inRange = true;
MapCoordinates originPos = default;
var targetPos = _transform.ToMapCoordinates(otherCoordinates);
Angle targetRot = default;
// So essentially:
// 1. If fixtures available check nearest point. We take in coordinates / angles because we might want to use a lag compensated position
// 2. Fall back to centre of body.
// Alternatively we could check centre distances first though
// that means we wouldn't be able to easily check overlap interactions.
if (range > 0f &&
_fixtureQuery.TryComp(origin, out var fixtureA) &&
// These fixture counts are stuff that has the component but no fixtures for <reasons> (e.g. buttons).
// At least until they get removed.
fixtureA.FixtureCount > 0 &&
_fixtureQuery.TryComp(other, out var fixtureB) &&
fixtureB.FixtureCount > 0 &&
Resolve(origin, ref origin.Comp))
{
var (worldPosA, worldRotA) = _transform.GetWorldPositionRotation(origin.Comp);
var xfA = new Transform(worldPosA, worldRotA);
var parentRotB = _transform.GetWorldRotation(otherCoordinates.EntityId);
var xfB = new Transform(targetPos.Position, parentRotB + otherAngle);
// Different map or the likes.
if (!_broadphase.TryGetNearest(
origin,
other,
out _,
out _,
out var distance,
xfA,
xfB,
fixtureA,
fixtureB))
{
inRange = false;
}
// Overlap, early out and no raycast.
else if (overlapCheck && distance.Equals(0f))
{
return true;
}
// Entity can bypass range checks.
else if (!ShouldCheckAccess(origin))
{
return true;
}
// Out of range so don't raycast.
else if (distance > range)
{
inRange = false;
}
else
{
// We'll still do the raycast from the centres but we'll bump the range as we know they're in range.
originPos = _transform.GetMapCoordinates(origin, xform: origin.Comp);
range = (originPos.Position - targetPos.Position).Length();
}
}
// No fixtures, e.g. wallmounts.
else
{
originPos = _transform.GetMapCoordinates(origin, origin);
var otherParent = (other.Comp ?? Transform(other)).ParentUid;
targetRot = otherParent.IsValid() ? Transform(otherParent).LocalRotation + otherAngle : otherAngle;
}
// Do a raycast to check if relevant
if (inRange)
{
var rayPredicate = GetPredicate(originPos, other, targetPos, targetRot, collisionMask, combinedPredicate);
inRange = InRangeUnobstructed(originPos, targetPos, range, collisionMask, rayPredicate, ShouldCheckAccess(origin));
}
if (!inRange && popup && _gameTiming.IsFirstTimePredicted)
{
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
_popupSystem.PopupClient(message, origin, origin);
}
return inRange;
}
public bool InRangeUnobstructed(
MapCoordinates origin,
EntityUid target,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null)
{
var transform = Transform(target);
var (position, rotation) = _transform.GetWorldPositionRotation(transform);
var mapPos = new MapCoordinates(position, transform.MapID);
var combinedPredicate = GetPredicate(origin, target, mapPos, rotation, collisionMask, predicate);
return InRangeUnobstructed(origin, mapPos, range, collisionMask, combinedPredicate);
}
/// <summary>
/// Gets the entities to ignore for an unobstructed raycast
/// </summary>
/// <example>
/// if the target entity is a wallmount we ignore all other entities on the tile.
/// </example>
private Ignored GetPredicate(
MapCoordinates origin,
EntityUid target,
MapCoordinates targetCoords,
Angle targetRotation,
CollisionGroup collisionMask,
Ignored? predicate = null)
{
HashSet<EntityUid> ignored = new();
if (_itemQuery.HasComp(target) && _physicsQuery.TryComp(target, out var physics) && physics.CanCollide)
{
// If the target is an item, we ignore any colliding entities. Currently done so that if items get stuck
// inside of walls, users can still pick them up.
ignored.UnionWith(_broadphase.GetEntitiesIntersectingBody(target, (int) collisionMask, false, physics)); // Note: This also bypasses items underneath doors, which may be problematic if it'd cause undesirable behavior.
}
else if (_wallMountQuery.TryComp(target, out var wallMount))
{
// wall-mount exemptions may be restricted to a specific angle range.da
bool ignoreAnchored;
if (wallMount.Arc >= Math.Tau)
ignoreAnchored = true;
else
{
var angle = Angle.FromWorldVec(origin.Position - targetCoords.Position);
var angleDelta = (wallMount.Direction + targetRotation - angle).Reduced().FlipPositive();
ignoreAnchored = angleDelta < wallMount.Arc / 2 || Math.Tau - angleDelta < wallMount.Arc / 2;
}
if (ignoreAnchored && _mapManager.TryFindGridAt(targetCoords, out _, out var grid))
ignored.UnionWith(grid.GetAnchoredEntities(targetCoords));
}
Ignored combinedPredicate = e => e == target || (predicate?.Invoke(e) ?? false) || ignored.Contains(e);
return combinedPredicate;
}
/// <summary>
/// Checks that an entity and a set of grid coordinates are within a certain
/// distance without any entity that matches the collision mask
/// obstructing them.
/// If the <paramref name="range"/> is zero or negative,
/// this method will only check if nothing obstructs the entity and component.
/// </summary>
/// <param name="origin">The entity to use.</param>
/// <param name="other">The grid coordinates to use.</param>
/// <param name="range">
/// Maximum distance between the two entity and set of grid coordinates.
/// </param>
/// <param name="collisionMask">The mask to check for collisions.</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <param name="popup">
/// Whether or not to popup a feedback message on the origin entity for
/// it to see.
/// </param>
/// <returns>
/// True if the two points are within a given range without being obstructed.
/// </returns>
public bool InRangeUnobstructed(
EntityUid origin,
EntityCoordinates other,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null,
bool popup = false)
{
return InRangeUnobstructed(origin, _transform.ToMapCoordinates(other), range, collisionMask, predicate, popup);
}
/// <summary>
/// Checks that an entity and a set of map coordinates are within a certain
/// distance without any entity that matches the collision mask
/// obstructing them.
/// If the <paramref name="range"/> is zero or negative,
/// this method will only check if nothing obstructs the entity and component.
/// </summary>
/// <param name="origin">The entity to use.</param>
/// <param name="other">The map coordinates to use.</param>
/// <param name="range">
/// Maximum distance between the two entity and set of map coordinates.
/// </param>
/// <param name="collisionMask">The mask to check for collisions.</param>
/// <param name="predicate">
/// A predicate to check whether to ignore an entity or not.
/// If it returns true, it will be ignored.
/// </param>
/// <param name="popup">
/// Whether or not to popup a feedback message on the origin entity for
/// it to see.
/// </param>
/// <returns>
/// True if the two points are within a given range without being obstructed.
/// </returns>
public bool InRangeUnobstructed(
EntityUid origin,
MapCoordinates other,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null,
bool popup = false)
{
Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false);
var originPosition = _transform.GetMapCoordinates(origin);
var inRange = InRangeUnobstructed(originPosition, other, range, collisionMask, combinedPredicate, ShouldCheckAccess(origin));
if (!inRange && popup && _gameTiming.IsFirstTimePredicted)
{
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
_popupSystem.PopupEntity(message, origin, origin);
}
return inRange;
}
public bool RangedInteractDoBefore(
EntityUid user,
EntityUid used,
EntityUid? target,
EntityCoordinates clickLocation,
bool canReach,
bool checkDeletion = true)
{
if (checkDeletion && (IsDeleted(user) || IsDeleted(used) || IsDeleted(target)))
return false;
var ev = new BeforeRangedInteractEvent(user, used, target, clickLocation, canReach);
RaiseLocalEvent(used, ev);
if (!ev.Handled)
return false;
// We contact the USED entity, but not the target.
DoContactInteraction(user, used, ev);
return ev.Handled;
}
/// <summary>
/// Uses an item/object on an entity
/// Finds components with the InteractUsing interface and calls their function
/// NOTE: Does not have an InRangeUnobstructed check
/// </summary>
/// <param name="user">User doing the interaction.</param>
/// <param name="used">Item being used on the <paramref name="target"/>.</param>
/// <param name="target">Entity getting interacted with by the <paramref name="user"/> using the
/// <paramref name="used"/> entity.</param>
/// <param name="clickLocation">The location that the <paramref name="user"/> clicked.</param>
/// <param name="checkCanInteract">Whether to check that the <paramref name="user"/> can interact with the
/// <paramref name="target"/>.</param>
/// <param name="checkCanUse">Whether to check that the <paramref name="user"/> can use the
/// <paramref name="used"/> entity.</param>
/// <returns>True if the interaction was handled. Otherwise, false.</returns>
public bool InteractUsing(
EntityUid user,
EntityUid used,
EntityUid target,
EntityCoordinates clickLocation,
bool checkCanInteract = true,
bool checkCanUse = true)
{
if (IsDeleted(user) || IsDeleted(used) || IsDeleted(target))
return false;
if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, target))
return false;
if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, used))
return false;
_adminLogger.Add(
LogType.InteractUsing,
LogImpact.Low,
$"{ToPrettyString(user):user} interacted with {ToPrettyString(target):target} using {ToPrettyString(used):used}");
if (RangedInteractDoBefore(user, used, target, clickLocation, canReach: true, checkDeletion: false))
return true;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used) && !IsDeleted(target));
// all interactions should only happen when in range / unobstructed, so no range check is needed
var interactUsingEvent = new InteractUsingEvent(user, used, target, clickLocation);
RaiseLocalEvent(target, interactUsingEvent, true);
DoContactInteraction(user, used, interactUsingEvent);
DoContactInteraction(user, target, interactUsingEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
if (interactUsingEvent.Handled)
return true;
if (InteractDoAfter(user, used, target, clickLocation, canReach: true, checkDeletion: false))
return true;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used) && !IsDeleted(target));
return false;
}
/// <summary>
/// Used when clicking on an entity resulted in no other interaction. Used for low-priority interactions.
/// </summary>
/// <param name="user"><inheritdoc cref="InteractUsing"/></param>
/// <param name="used"><inheritdoc cref="InteractUsing"/></param>
/// <param name="target"><inheritdoc cref="InteractUsing"/></param>
/// <param name="clickLocation"><inheritdoc cref="InteractUsing"/></param>
/// <param name="canReach">Whether the <paramref name="user"/> is in range of the <paramref name="target"/>.
/// </param>
/// <returns>True if the interaction was handled. Otherwise, false.</returns>
public bool InteractDoAfter(EntityUid user, EntityUid used, EntityUid? target, EntityCoordinates clickLocation, bool canReach, bool checkDeletion = true)
{
if (target is { Valid: false })
target = null;
if (checkDeletion && (IsDeleted(user) || IsDeleted(used) || IsDeleted(target)))
return false;
var afterInteractEvent = new AfterInteractEvent(user, used, target, clickLocation, canReach);
RaiseLocalEvent(used, afterInteractEvent);
DoContactInteraction(user, used, afterInteractEvent);
if (canReach)
{
DoContactInteraction(user, target, afterInteractEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
}
if (afterInteractEvent.Handled)
return true;
if (target == null)
return false;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used) && !IsDeleted(target));
var afterInteractUsingEvent = new AfterInteractUsingEvent(user, used, target, clickLocation, canReach);
RaiseLocalEvent(target.Value, afterInteractUsingEvent);
DoContactInteraction(user, used, afterInteractUsingEvent);
if (canReach)
{
DoContactInteraction(user, target, afterInteractUsingEvent);
// Contact interactions are currently only used for forensics, so we don't raise used -> target
}
return afterInteractUsingEvent.Handled;
}
#region ActivateItemInWorld
private bool HandleActivateItemInWorld(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
{
if (!ValidateClientInput(session, coords, uid, out var user))
{
Log.Info($"ActivateItemInWorld input validation failed");
return false;
}
if (Deleted(uid))
return false;
InteractionActivate(user.Value, uid, checkAccess: ShouldCheckAccess(user.Value));
return false;
}
/// <summary>
/// Raises <see cref="ActivateInWorldEvent"/> events and activates the IActivate behavior of an object.
/// </summary>
/// <remarks>
/// Does not check the can-use action blocker. In activations interacts can target entities outside of the users
/// hands.
/// </remarks>
public bool InteractionActivate(
EntityUid user,
EntityUid used,
bool checkCanInteract = true,
bool checkUseDelay = true,
bool checkAccess = true,
bool? complexInteractions = null,
bool checkDeletion = true)
{
if (checkDeletion && (IsDeleted(user) || IsDeleted(used)))
return false;
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used));
_delayQuery.TryComp(used, out var delayComponent);
if (checkUseDelay && delayComponent != null && _useDelay.IsDelayed((used, delayComponent)))
return false;
if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, used))
return false;
if (checkAccess && !InRangeUnobstructed(user, used))
return false;
// Check if interacted entity is in the same container, the direct child, or direct parent of the user.
// This is bypassed IF the interaction happened through an item slot (e.g., backpack UI)
if (checkAccess && !IsAccessible(user, used))
return false;
complexInteractions ??= _actionBlockerSystem.CanComplexInteract(user);
var activateMsg = new ActivateInWorldEvent(user, used, complexInteractions.Value);
RaiseLocalEvent(used, activateMsg, true);
if (activateMsg.Handled)
{
DoContactInteraction(user, used);
if (!activateMsg.WasLogged)
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
if (delayComponent != null)
_useDelay.TryResetDelay(used, component: delayComponent);
return true;
}
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used));
var userEv = new UserActivateInWorldEvent(user, used, complexInteractions.Value);
RaiseLocalEvent(user, userEv, true);
if (!userEv.Handled)
return false;
DoContactInteraction(user, used);
// Still need to call this even without checkUseDelay in case this gets relayed from Activate.
if (delayComponent != null)
_useDelay.TryResetDelay(used, component: delayComponent);
_adminLogger.Add(LogType.InteractActivate, LogImpact.Low, $"{ToPrettyString(user):user} activated {ToPrettyString(used):used}");
return true;
}
#endregion
#region Hands
#region Use
/// <summary>
/// Raises UseInHandEvents and activates the IUse behaviors of an entity
/// Does not check accessibility or range, for obvious reasons
/// </summary>
/// <returns>True if the interaction was handled. False otherwise</returns>
public bool UseInHandInteraction(
EntityUid user,
EntityUid used,
bool checkCanUse = true,
bool checkCanInteract = true,
bool checkUseDelay = true)
{
if (IsDeleted(user) || IsDeleted(used))
return false;
_delayQuery.TryComp(used, out var delayComponent);
if (checkUseDelay && delayComponent != null && _useDelay.IsDelayed((used, delayComponent)))
return true; // if the item is on cooldown, we consider this handled.
if (checkCanInteract && !_actionBlockerSystem.CanInteract(user, used))
return false;
if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, used))
return false;
var useMsg = new UseInHandEvent(user);
RaiseLocalEvent(used, useMsg, true);
if (useMsg.Handled)
{
DoContactInteraction(user, used, useMsg);
if (delayComponent != null && useMsg.ApplyDelay)
_useDelay.TryResetDelay((used, delayComponent));
return true;
}
DebugTools.Assert(!IsDeleted(user) && !IsDeleted(used));
// else, default to activating the item
return InteractionActivate(user, used, false, false, false, checkDeletion: false);
}
/// <summary>
/// Alternative interactions on an entity.
/// </summary>
/// <remarks>
/// Uses the context menu verb list, and acts out the highest priority alternative interaction verb.
/// </remarks>
/// <returns>True if the interaction was handled, false otherwise.</returns>
public bool AltInteract(EntityUid user, EntityUid target)
{
// Get list of alt-interact verbs
var verbs = _verbSystem.GetLocalVerbs(target, user, typeof(AlternativeVerb));
if (verbs.Count == 0)
return false;
_verbSystem.ExecuteVerb(verbs.First(), user, target);
return true;
}
#endregion
public void DroppedInteraction(EntityUid user, EntityUid item)
{
if (IsDeleted(user) || IsDeleted(item))
return;
var dropMsg = new DroppedEvent(user);
RaiseLocalEvent(item, dropMsg, true);
// If the dropper is rotated then use their targetrelativerotation as the drop rotation
var rotation = Angle.Zero;
if (TryComp<InputMoverComponent>(user, out var mover))
{
rotation = mover.TargetRelativeRotation;
}
Transform(item).LocalRotation = rotation;
}
#endregion
/// <summary>
/// Check if a user can access a target (stored in the same containers) and is in range without obstructions.
/// </summary>
public bool InRangeAndAccessible(
Entity<TransformComponent?> user,
Entity<TransformComponent?> target,
float range = InteractionRange,
CollisionGroup collisionMask = InRangeUnobstructedMask,
Ignored? predicate = null)
{
if (user == target)
return true;
if (!Resolve(user, ref user.Comp))
return false;
if (!Resolve(target, ref target.Comp))
return false;
return IsAccessible(user, target) && InRangeUnobstructed(user, target, range, collisionMask, predicate);
}
/// <summary>
/// Check if a user can access a target or if they are stored in different containers.
/// </summary>
public bool IsAccessible(Entity<TransformComponent?> user, Entity<TransformComponent?> target)
{
var ev = new AccessibleOverrideEvent(user, target);
RaiseLocalEvent(user, ref ev);
if (ev.Handled)
return ev.Accessible;
if (_containerSystem.IsInSameOrParentContainer(user, target, out _, out var container))
return true;
return container != null && CanAccessViaStorage(user, target, container);
}
/// <summary>
/// If a target is in range, but not in the same container as the user, it may be inside of a backpack. This
/// checks if the user can access the item in these situations.
/// </summary>
public bool CanAccessViaStorage(EntityUid user, EntityUid target)
{
if (!_containerSystem.TryGetContainingContainer((target, null, null), out var container))
return false;
return CanAccessViaStorage(user, target, container);
}
/// <inheritdoc cref="CanAccessViaStorage(Robust.Shared.GameObjects.EntityUid,Robust.Shared.GameObjects.EntityUid)"/>
public bool CanAccessViaStorage(EntityUid user, EntityUid target, BaseContainer container)
{
if (StorageComponent.ContainerId != container.ID)
return false;
// we don't check if the user can access the storage entity itself. This should be handed by the UI system.
return _ui.IsUiOpen(container.Owner, StorageComponent.StorageUiKey.Key, user);
}
/// <summary>
/// Checks whether an entity currently equipped by another player is accessible to some user. This shouldn't
/// be used as a general interaction check, as these kinda of interactions should generally trigger a
/// do-after and a warning for the other player.
/// </summary>
public bool CanAccessEquipment(EntityUid user, EntityUid target)
{
if (Deleted(target))
return false;
if (!_containerSystem.TryGetContainingContainer(target, out var container))
return false;
var wearer = container.Owner;
if (!_inventory.TryGetSlot(wearer, container.ID, out var slotDef))
return false;
if (wearer == user)
return true;
if (_strippable.IsStripHidden(slotDef, user))
return false;
return InRangeUnobstructed(user, wearer) && _containerSystem.IsInSameOrParentContainer(user, wearer);
}
protected bool ValidateClientInput(
ICommonSession? session,
EntityCoordinates coords,
EntityUid uid,
[NotNullWhen(true)] out EntityUid? userEntity)
{
userEntity = null;
if (!coords.IsValid(EntityManager))
{
Log.Info($"Invalid Coordinates: client={session}, coords={coords}");
return false;
}
if (IsClientSide(uid))
{
Log.Warning($"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
return false;
}
userEntity = session?.AttachedEntity;
if (userEntity == null || !userEntity.Value.Valid)
{
Log.Warning($"Client sent interaction with no attached entity. Session={session}");
return false;
}
if (!Exists(userEntity))
{
Log.Warning($"Client attempted interaction with a non-existent attached entity. Session={session}, entity={userEntity}");
return false;
}
return _rateLimit.CountAction(session!, RateLimitKey) == RateLimitStatus.Allowed;
}
/// <summary>
/// Simple convenience function to raise contact events (disease, forensics, etc).
/// </summary>
public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityEventArgs? args = null)
{
if (uidB == null || args?.Handled == false)
return;
if (uidA == uidB.Value)
return;
if (!TryComp(uidA, out MetaDataComponent? metaA) || metaA.EntityPaused)
return;
if (!TryComp(uidB, out MetaDataComponent? metaB) || metaB.EntityPaused)
return ;
// TODO Struct event
var ev = new ContactInteractionEvent(uidB.Value);
RaiseLocalEvent(uidA, ev);
ev.Other = uidA;
RaiseLocalEvent(uidB.Value, ev);
}
private void HandleUserInterfaceRangeCheck(ref BoundUserInterfaceCheckRangeEvent ev)
{
if (ev.Result == BoundUserInterfaceRangeResult.Fail)
return;
ev.Result = UiRangeCheck(ev.Actor!, ev.Target, ev.Data.InteractionRange)
? BoundUserInterfaceRangeResult.Pass
: BoundUserInterfaceRangeResult.Fail;
}
/// <summary>
/// Gets the entity that is currently being "used" for the interaction.
/// In most cases, this refers to the entity in the character's active hand.
/// </summary>
/// <returns>If there is an entity being used.</returns>
public bool TryGetUsedEntity(EntityUid user, [NotNullWhen(true)] out EntityUid? used, bool checkCanUse = true)
{
var ev = new GetUsedEntityEvent(user);
RaiseLocalEvent(user, ref ev);
used = ev.Used;
if (!ev.Handled)
return false;
// Can the user use the held entity?
if (checkCanUse && !_actionBlockerSystem.CanUseHeldEntity(user, ev.Used!.Value))
{
used = null;
return false;
}
return ev.Handled;
}
[Obsolete("Use ActionBlockerSystem")]
public bool SupportsComplexInteractions(EntityUid user)
{
return _actionBlockerSystem.CanComplexInteract(user);
}
}
/// <summary>
/// Raised when a player attempts to activate an item in an inventory slot or hand slot
/// </summary>
[Serializable, NetSerializable]
public sealed class InteractInventorySlotEvent : EntityEventArgs
{
/// <summary>
/// Entity that was interacted with.
/// </summary>
public NetEntity ItemUid { get; }
/// <summary>
/// Whether the interaction used the alt-modifier to trigger alternative interactions.
/// </summary>
public bool AltInteract { get; }
public InteractInventorySlotEvent(NetEntity itemUid, bool altInteract = false)
{
ItemUid = itemUid;
AltInteract = altInteract;
}
}
/// <summary>
/// Raised directed by-ref on an entity to determine what item will be used in interactions.
/// </summary>
[ByRefEvent]
public record struct GetUsedEntityEvent(EntityUid User)
{
public EntityUid User = User;
public EntityUid? Used = null;
public bool Handled => Used != null;
};
/// <summary>
/// Raised directed by-ref on an item to determine if hand interactions should go through.
/// Defaults to allowing hand interactions to go through. Cancel to force the item to be attacked instead.
/// </summary>
/// <param name="Cancelled">Whether the hand interaction should be cancelled.</param>
[ByRefEvent]
public record struct CombatModeShouldHandInteractEvent(bool Cancelled = false);
/// <summary>
/// Override event raised directed on the user to say the target is accessible.
/// </summary>
/// <param name="User"></param>
/// <param name="Target"></param>
[ByRefEvent]
public record struct AccessibleOverrideEvent(EntityUid User, EntityUid Target)
{
public readonly EntityUid User = User;
public readonly EntityUid Target = Target;
public bool Handled;
public bool Accessible = false;
}
/// <summary>
/// Override event raised directed on a user to check InRangeUnoccluded AND InRangeUnobstructed to the target if you require custom logic.
/// </summary>
[ByRefEvent]
public record struct InRangeOverrideEvent(EntityUid User, EntityUid Target)
{
public readonly EntityUid User = User;
public readonly EntityUid Target = Target;
public bool Handled;
public bool InRange = false;
}
}