Class SharedInteractionSystem
Handles BlockMovementComponent, which prevents various kinds of movement and interactions when attached to an entity.
Namespace: Content.Shared.Interaction
Assembly: Content.Shared.dll
Syntax
public abstract class SharedInteractionSystem : EntitySystem
Fields
| Improve this Doc View SourceInteractionRange
Declaration
public const float InteractionRange = null
Field Value
Type | Description |
---|---|
System.Single |
InteractionRangeSquared
Declaration
public const float InteractionRangeSquared = null
Field Value
Type | Description |
---|---|
System.Single |
MaxRaycastRange
Declaration
public const float MaxRaycastRange = null
Field Value
Type | Description |
---|---|
System.Single |
Methods
| Improve this Doc View SourceAltInteract(EntityUid, EntityUid)
Alternative interactions on an entity.
Declaration
public bool AltInteract(EntityUid user, EntityUid target)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | target |
Returns
Type | Description |
---|---|
System.Boolean | True if the interaction was handled, false otherwise. |
Remarks
Uses the context menu verb list, and acts out the highest priority alternative interaction verb.
CanAccessEquipment(EntityUid, EntityUid)
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.
Declaration
public bool CanAccessEquipment(EntityUid user, EntityUid target)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | target |
Returns
Type | Description |
---|---|
System.Boolean |
CanAccessViaStorage(EntityUid, EntityUid)
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.
Declaration
public abstract bool CanAccessViaStorage(EntityUid user, EntityUid target)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | target |
Returns
Type | Description |
---|---|
System.Boolean |
CombatModeCanHandInteract(EntityUid, Nullable<EntityUid>)
Returns true if the specified entity should hand interact with the target instead of attacking
Declaration
public bool CombatModeCanHandInteract(EntityUid user, EntityUid? target)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | The user interacting in combat mode |
System.Nullable<EntityUid> | target | The target of the interaction |
Returns
Type | Description |
---|---|
System.Boolean |
DoContactInteraction(EntityUid, Nullable<EntityUid>, Nullable<HandledEntityEventArgs>)
Simple convenience function to raise contact events (disease, forensics, etc).
Declaration
public void DoContactInteraction(EntityUid uidA, EntityUid? uidB, HandledEntityEventArgs? args = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uidA | |
System.Nullable<EntityUid> | uidB | |
System.Nullable<HandledEntityEventArgs> | args |
DroppedInteraction(EntityUid, EntityUid)
Declaration
public void DroppedInteraction(EntityUid user, EntityUid item)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | item |
HandleAltUseInteraction(ICommonSession, EntityCoordinates, EntityUid)
Declaration
public bool HandleAltUseInteraction(ICommonSession session, EntityCoordinates coords, EntityUid uid)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Players.ICommonSession | session | |
Robust.Shared.Map.EntityCoordinates | coords | |
EntityUid | uid |
Returns
Type | Description |
---|---|
System.Boolean |
HandleUseInteraction(ICommonSession, EntityCoordinates, EntityUid)
Declaration
public bool HandleUseInteraction(ICommonSession session, EntityCoordinates coords, EntityUid uid)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Players.ICommonSession | session | |
Robust.Shared.Map.EntityCoordinates | coords | |
EntityUid | uid |
Returns
Type | Description |
---|---|
System.Boolean |
Initialize()
Declaration
public override void Initialize()
InitializeBlocking()
Declaration
public void InitializeBlocking()
InRangeUnobstructed(EntityUid, EntityUid, EntityCoordinates, Angle, Single, CollisionGroup, SharedInteractionSystem.Ignored, Boolean)
Checks that two entities are within a certain distance without any
entity that matches the collision mask obstructing them.
If the 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.
Declaration
public bool InRangeUnobstructed(EntityUid origin, EntityUid other, EntityCoordinates otherCoordinates, Angle otherAngle, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null, bool popup = false)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | origin | The first entity to use. |
EntityUid | other | Other entity to use. |
Robust.Shared.Map.EntityCoordinates | otherCoordinates | The coordinates to use for the other entity. |
Angle | otherAngle | The local rotation to use for the other entity. |
System.Single | range | Maximum distance between the two entities. |
CollisionGroup | collisionMask | The mask to check for collisions. |
SharedInteractionSystem.Ignored | predicate | A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored. |
System.Boolean | popup | Whether or not to popup a feedback message on the origin entity for it to see. |
Returns
Type | Description |
---|---|
System.Boolean | True if the two points are within a given range without being obstructed. |
InRangeUnobstructed(EntityUid, EntityUid, Single, CollisionGroup, SharedInteractionSystem.Ignored, Boolean)
Declaration
public bool InRangeUnobstructed(EntityUid origin, EntityUid other, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null, bool popup = false)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | origin | |
EntityUid | other | |
System.Single | range | |
CollisionGroup | collisionMask | |
SharedInteractionSystem.Ignored | predicate | |
System.Boolean | popup |
Returns
Type | Description |
---|---|
System.Boolean |
InRangeUnobstructed(EntityUid, EntityCoordinates, Single, CollisionGroup, SharedInteractionSystem.Ignored, Boolean)
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 range
is zero or negative,
this method will only check if nothing obstructs the entity and component.
Declaration
public bool InRangeUnobstructed(EntityUid origin, EntityCoordinates other, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null, bool popup = false)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | origin | The entity to use. |
Robust.Shared.Map.EntityCoordinates | other | The grid coordinates to use. |
System.Single | range | Maximum distance between the two entity and set of grid coordinates. |
CollisionGroup | collisionMask | The mask to check for collisions. |
SharedInteractionSystem.Ignored | predicate | A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored. |
System.Boolean | popup | Whether or not to popup a feedback message on the origin entity for it to see. |
Returns
Type | Description |
---|---|
System.Boolean | True if the two points are within a given range without being obstructed. |
InRangeUnobstructed(EntityUid, MapCoordinates, Single, CollisionGroup, SharedInteractionSystem.Ignored, Boolean)
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 range
is zero or negative,
this method will only check if nothing obstructs the entity and component.
Declaration
public bool InRangeUnobstructed(EntityUid origin, MapCoordinates other, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null, bool popup = false)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | origin | The entity to use. |
Robust.Shared.Map.MapCoordinates | other | The map coordinates to use. |
System.Single | range | Maximum distance between the two entity and set of map coordinates. |
CollisionGroup | collisionMask | The mask to check for collisions. |
SharedInteractionSystem.Ignored | predicate | A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored. |
System.Boolean | popup | Whether or not to popup a feedback message on the origin entity for it to see. |
Returns
Type | Description |
---|---|
System.Boolean | True if the two points are within a given range without being obstructed. |
InRangeUnobstructed(MapCoordinates, EntityUid, Single, CollisionGroup, SharedInteractionSystem.Ignored)
Declaration
public bool InRangeUnobstructed(MapCoordinates origin, EntityUid target, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Map.MapCoordinates | origin | |
EntityUid | target | |
System.Single | range | |
CollisionGroup | collisionMask | |
SharedInteractionSystem.Ignored | predicate |
Returns
Type | Description |
---|---|
System.Boolean |
InRangeUnobstructed(MapCoordinates, MapCoordinates, Single, CollisionGroup, SharedInteractionSystem.Ignored, Boolean)
Checks that these coordinates are within a certain distance without any
entity that matches the collision mask obstructing them.
If the range
is zero or negative,
this method will only check if nothing obstructs the two sets
of coordinates.
Declaration
public bool InRangeUnobstructed(MapCoordinates origin, MapCoordinates other, float range = null, CollisionGroup collisionMask = default(CollisionGroup), SharedInteractionSystem.Ignored predicate = null, bool checkAccess = true)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Map.MapCoordinates | origin | Set of coordinates to use. |
Robust.Shared.Map.MapCoordinates | other | Other set of coordinates to use. |
System.Single | range | Maximum distance between the two sets of coordinates. |
CollisionGroup | collisionMask | The mask to check for collisions. |
SharedInteractionSystem.Ignored | predicate | A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored. |
System.Boolean | checkAccess | Perform range checks |
Returns
Type | Description |
---|---|
System.Boolean | True if the two points are within a given range without being obstructed. |
InteractDoAfter(EntityUid, EntityUid, Nullable<EntityUid>, EntityCoordinates, Boolean)
Used when clicking on an entity resulted in no other interaction. Used for low-priority interactions.
Declaration
public void InteractDoAfter(EntityUid user, EntityUid used, EntityUid? target, EntityCoordinates clickLocation, bool canReach)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
System.Nullable<EntityUid> | target | |
Robust.Shared.Map.EntityCoordinates | clickLocation | |
System.Boolean | canReach |
InteractHand(EntityUid, EntityUid)
Declaration
public void InteractHand(EntityUid user, EntityUid target)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | target |
InteractionActivate(EntityUid, EntityUid, Boolean, Boolean, Boolean)
Raises ActivateInWorldEvent events and activates the IActivate behavior of an object.
Declaration
public bool InteractionActivate(EntityUid user, EntityUid used, bool checkCanInteract = true, bool checkUseDelay = true, bool checkAccess = true)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
System.Boolean | checkCanInteract | |
System.Boolean | checkUseDelay | |
System.Boolean | checkAccess |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Does not check the can-use action blocker. In activations interacts can target entities outside of the users hands.
InteractUsing(EntityUid, EntityUid, EntityUid, EntityCoordinates, Boolean, Boolean)
Uses a item/object on an entity Finds components with the InteractUsing interface and calls their function NOTE: Does not have an InRangeUnobstructed check
Declaration
public void InteractUsing(EntityUid user, EntityUid used, EntityUid target, EntityCoordinates clickLocation, bool checkCanInteract = true, bool checkCanUse = true)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
EntityUid | target | |
Robust.Shared.Map.EntityCoordinates | clickLocation | |
System.Boolean | checkCanInteract | |
System.Boolean | checkCanUse |
InteractUsingRanged(EntityUid, EntityUid, Nullable<EntityUid>, EntityCoordinates, Boolean)
Declaration
public void InteractUsingRanged(EntityUid user, EntityUid used, EntityUid? target, EntityCoordinates clickLocation, bool inRangeUnobstructed)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
System.Nullable<EntityUid> | target | |
Robust.Shared.Map.EntityCoordinates | clickLocation | |
System.Boolean | inRangeUnobstructed |
RangedInteractDoBefore(EntityUid, EntityUid, Nullable<EntityUid>, EntityCoordinates, Boolean)
Declaration
public bool RangedInteractDoBefore(EntityUid user, EntityUid used, EntityUid? target, EntityCoordinates clickLocation, bool canReach)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
System.Nullable<EntityUid> | target | |
Robust.Shared.Map.EntityCoordinates | clickLocation | |
System.Boolean | canReach |
Returns
Type | Description |
---|---|
System.Boolean |
RollClumsy(ClumsyComponent, Single)
Declaration
public bool RollClumsy(ClumsyComponent component, float chance)
Parameters
Type | Name | Description |
---|---|---|
ClumsyComponent | component | |
System.Single | chance |
Returns
Type | Description |
---|---|
System.Boolean |
SetRelay(EntityUid, Nullable<EntityUid>, InteractionRelayComponent)
Declaration
public void SetRelay(EntityUid uid, EntityUid? relayEntity, InteractionRelayComponent component = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | uid | |
System.Nullable<EntityUid> | relayEntity | |
InteractionRelayComponent | component |
Shutdown()
Declaration
public override void Shutdown()
ThrownInteraction(EntityUid, EntityUid)
Calls Thrown on all components that implement the IThrown interface on an entity that has been thrown.
Declaration
public void ThrownInteraction(EntityUid user, EntityUid thrown)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | thrown |
TryRollClumsy(EntityUid, Single, ClumsyComponent)
Rolls a probability chance for a "bad action" if the target entity is clumsy.
Declaration
public bool TryRollClumsy(EntityUid entity, float chance, ClumsyComponent component = null)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | entity | The entity that the clumsy check is happening for. |
System.Single | chance | The chance that a "bad action" happens if the user is clumsy, between 0 and 1 inclusive. |
ClumsyComponent | component |
Returns
Type | Description |
---|---|
System.Boolean | True if a "bad action" happened, false if the normal action should happen. |
UnobstructedDistance(MapCoordinates, MapCoordinates, Int32, SharedInteractionSystem.Ignored)
Traces a ray from coords to otherCoords and returns the length of the vector between coords and the ray's first hit.
Declaration
public float UnobstructedDistance(MapCoordinates origin, MapCoordinates other, int collisionMask = null, SharedInteractionSystem.Ignored predicate = null)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Map.MapCoordinates | origin | Set of coordinates to use. |
Robust.Shared.Map.MapCoordinates | other | Other set of coordinates to use. |
System.Int32 | collisionMask | the mask to check for collisions |
SharedInteractionSystem.Ignored | predicate | A predicate to check whether to ignore an entity or not. If it returns true, it will be ignored. |
Returns
Type | Description |
---|---|
System.Single | Length of resulting ray. |
UseInHandInteraction(EntityUid, EntityUid, Boolean, Boolean, Boolean)
Raises UseInHandEvents and activates the IUse behaviors of an entity Does not check accessibility or range, for obvious reasons
Declaration
public bool UseInHandInteraction(EntityUid user, EntityUid used, bool checkCanUse = true, bool checkCanInteract = true, bool checkUseDelay = true)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
EntityUid | used | |
System.Boolean | checkCanUse | |
System.Boolean | checkCanInteract | |
System.Boolean | checkUseDelay |
Returns
Type | Description |
---|---|
System.Boolean | True if the interaction was handled. False otherwise |
UserInteraction(EntityUid, EntityCoordinates, Nullable<EntityUid>, Boolean, Boolean, Boolean, Boolean)
Resolves user interactions with objects.
Declaration
public void UserInteraction(EntityUid user, EntityCoordinates coordinates, EntityUid? target, bool altInteract = false, bool checkCanInteract = true, bool checkAccess = true, bool checkCanUse = true)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
Robust.Shared.Map.EntityCoordinates | coordinates | |
System.Nullable<EntityUid> | target | |
System.Boolean | 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. |
System.Boolean | checkCanInteract | |
System.Boolean | checkAccess | |
System.Boolean | checkCanUse |
Remarks
Checks Whether combat mode is enabled and whether the user can actually interact with the given entity.
ValidateClientInput(ICommonSession, EntityCoordinates, EntityUid, out Nullable<EntityUid>)
Declaration
protected bool ValidateClientInput(ICommonSession session, EntityCoordinates coords, EntityUid uid, out EntityUid? userEntity)
Parameters
Type | Name | Description |
---|---|---|
Robust.Shared.Players.ICommonSession | session | |
Robust.Shared.Map.EntityCoordinates | coords | |
EntityUid | uid | |
System.Nullable<EntityUid> | userEntity |
Returns
Type | Description |
---|---|
System.Boolean |
ValidateInteractAndFace(EntityUid, EntityCoordinates)
Declaration
protected bool ValidateInteractAndFace(EntityUid user, EntityCoordinates coordinates)
Parameters
Type | Name | Description |
---|---|---|
EntityUid | user | |
Robust.Shared.Map.EntityCoordinates | coordinates |
Returns
Type | Description |
---|---|
System.Boolean |