InteractionContext
Namespace: FireSoftworks.Interaction
Assembly: FireSoftworks.Interaction
Type: Struct
Immutable data structure passed to action validators and execution methods. Contains contextual information about the interaction (interactor, target, environment). This struct is read-only to ensure consistency across the interaction pipeline.
public readonly struct InteractionContextConstructors
InteractionContext(GameObject, Transform, GameObject, Transform, RaycastHit?, float)
Creates a new InteractionContext with the given parameters.
public InteractionContext(GameObject interactable, Transform interactableTransform, GameObject interactor, Transform interactorTransform, RaycastHit? hit, float maxDistance)Parameters
| Name | Type | Description |
|---|---|---|
interactable | UnityEngine.GameObject | The GameObject being interacted with. |
interactableTransform | UnityEngine.Transform | The Transform of the interactable object. |
interactor | UnityEngine.GameObject | The GameObject performing the interaction. |
interactorTransform | UnityEngine.Transform | The Transform of the interactor. |
hit | System.Nullable{UnityEngine.RaycastHit} | Optional raycast hit information; null for programmatic interactions. |
maxDistance | System.Single | The maximum allowed interaction distance. |
Fields
Hit
Optional raycast hit information if the interaction was detected via raycast. Can be null if the interaction was triggered programmatically.
public readonly RaycastHit? HitInteractable
The GameObject being interacted with (e.g., an item or NPC).
public readonly GameObject InteractableInteractableTransform
The Transform of the interactable for position/rotation queries.
public readonly Transform InteractableTransformInteractor
The GameObject performing the interaction (e.g., the Player).
public readonly GameObject InteractorInteractorTransform
The Transform of the interactor for position/rotation queries.
public readonly Transform InteractorTransformMaxDistance
The maximum distance allowed for this interaction. Useful for validating action availability based on proximity.
public readonly float MaxDistance