Class Interactor
Allows interaction with InteractableObjects. Inherit from this class to implement custom interaction behaviors.
Use InteractionHandler and InteractabilityChecker attributes to mark methods responsible for implementations.
Details see InteractionHandlerAttribute and InteractabilityCheckerAttribute.
Use RegisterInteractorAttribute to register marked methods as interaction handlers and interactability checkers for this interactor.
Unregistered interactor will not be able to perform interactions even if handlers and checkers are defined.
Each interactor can only have 1 implementation of interation handling and interactability checker with 1 type of InteractableObject. Interactors without any interaction handlers are allowed but will not be able do interactions.
Inherited Members
Namespace: LobsterFramework.Interaction
Assembly: LobsterFramework.dll
Syntax
[RequireComponent(typeof(Collider2D))]
public abstract class Interactor : MonoBehaviour
Methods
| Improve this Doc View SourceCheckInteractability(IInteractable)
Check the interactablity between the interactor and the object using the corresponding checker, if no checker is defined, return default value where no interaction is available
Declaration
public InteractionPrompt CheckInteractability(IInteractable interactableObject)
Parameters
Type | Name | Description |
---|---|---|
IInteractable | interactableObject | The object to be queried |
Returns
Type | Description |
---|---|
InteractionPrompt | The interactability of this object |
GetInteractablesInRange(List<IInteractable>)
Get all of the interatables in range of this interactor. Note that this does not guarantee that they can be interacted with. Use CheckInteractability to check for this info.
Declaration
public void GetInteractablesInRange(List<IInteractable> objects)
Parameters
Type | Name | Description |
---|---|---|
List<IInteractable> | objects |
Interact(IInteractable, InteractionType)
Attempts to interact with the interactable
Declaration
public void Interact(IInteractable interactable, InteractionType interactionType)
Parameters
Type | Name | Description |
---|---|---|
IInteractable | interactable | The object to interact with |
InteractionType | interactionType | The type of the interaction |
Events
| Improve this Doc View SourceOnInteractableAdded
Called when an interactable gets in range
Declaration
public event Action<IInteractable> OnInteractableAdded
Event Type
Type | Description |
---|---|
Action<IInteractable> |
OnInteractableRemoved
Called when an interactable goes out of range
Declaration
public event Action<IInteractable> OnInteractableRemoved
Event Type
Type | Description |
---|---|
Action<IInteractable> |