-
Notifications
You must be signed in to change notification settings - Fork 3
Interactables and interactions
Chris Sprance edited this page Dec 23, 2024
·
1 revision
- Enter component area
- ComponentArea runs a CanInteractWithQuery when the entity enters the area
- Pass =
Interactor(CanInteractWith, Interactable)
added to Interactor (AKA Entity that entered) - Fail - Nothing happens
- Pass =
- InteractionSystem
- Query:
Interactor(CanInteractWith, *)
- Process
- Run through all interactors that can interact with stuff
- If an input is pressed that matches the use key
- Relationship added to Interactable(BeingInteractedWith, Interactor)
- Query:
- InteractableSystem
- Query:
Interactable(BeingInteractedWith, *)
- Process:
- For each interactable:
- interactors = Get relationship targets (interactors) for
Interactable(BeingInteractedWith, *)
- action = Get the Interactable component from the entity and get the action from the component
- run the action with the correct params and optional meta
- action(interactable, interactors, meta)
- if the action suceeded or failed log it out (action returns a bool on success/fail)
- interactors = Get relationship targets (interactors) for
- Reset the interaction state
- For each interactable:
- Query:
- ComponentArea runs a CanInteractWithQuery when the entity enters the area
- Interactor - The Entity that can interact with stuff.
- Interactable - The entity that can be interacted with.
- Interaction/Interact - The process of an entity being in an area that allows it to interact if the entity matches against a query initiating the interaction then having an action run
- Action - The function that is run when an interactable is interacted with
- CanInteractQuery - A Query that defines if an Interactor can Interact with an Interactable. If the entity does not pass the query they can not initiate the interaction
- Interactor(CanInteractWith, Interactable)
- Applied to the Interactor when they enter the area and mass the CanInteractWithQuery
- Interactable(BeingInteractedWith, Interactor)
- Applied to the interactable when it is being interacted with
Managed the objects that are interactable validating and performing the action defined on the interactable component of the entity
Managed the interaction between the entity that can interact and the
- C_Door
- C_Interactable
- Action - OpenDoorInteraction
- Input Action - "f"
- C_AnimationPlayer
- SQ_IsPlayer
- SQ_IsInteractor
- C_Interactor
All this interaction does is add a single component C_PlayAnimation.new('open_door') to the door entity and the animation system will pick it up and play the animation. Then all you have to do to make doors is create a scene with the above setup and animate an open_door animation and you have reusable door interactions