Skip to content

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 InteractionContext

Constructors

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

NameTypeDescription
interactableUnityEngine.GameObjectThe GameObject being interacted with.
interactableTransformUnityEngine.TransformThe Transform of the interactable object.
interactorUnityEngine.GameObjectThe GameObject performing the interaction.
interactorTransformUnityEngine.TransformThe Transform of the interactor.
hitSystem.Nullable{UnityEngine.RaycastHit}Optional raycast hit information; null for programmatic interactions.
maxDistanceSystem.SingleThe 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? Hit

Interactable

The GameObject being interacted with (e.g., an item or NPC).

public readonly GameObject Interactable

InteractableTransform

The Transform of the interactable for position/rotation queries.

public readonly Transform InteractableTransform

Interactor

The GameObject performing the interaction (e.g., the Player).

public readonly GameObject Interactor

InteractorTransform

The Transform of the interactor for position/rotation queries.

public readonly Transform InteractorTransform

MaxDistance

The maximum distance allowed for this interaction. Useful for validating action availability based on proximity.

public readonly float MaxDistance