PossessInteraction
Concrete Interaction that triggers possession of the interactable's entity. When executed, the interactor's possessor takes control of the interactable's possessable, optionally releasing all current possessions first.
Definition
Namespace: Paragon.Townskeep.PossessionSystem Assembly: Townskeep.dll
public class PossessInteraction : InteractionInheritance: Action → Interaction → PossessInteraction
Remarks
PossessInteraction bridges the Interaction System with the Possession System. It is configured as an entry in an InteractionTable on possessable entities, allowing players or AI to trigger possession via the standard interaction pipeline.
The interaction resolves the possessor and possessable through component lookups:
Possessor — obtained from the interactor's
Possessablecomponent viaGetPossessor(). This means the interactor must itself be possessed (the interacting body is possessed by something, and that something becomes the new possessor).Possessable — obtained directly from the interactable's
Possessablecomponent.
This interaction completes synchronously (Task.CompletedTask). Possession is instant — any transition animations should be handled by PossessAction instances configured on the Possessor and Possessable components.
Quick Lookup
Enable possession via interaction
Add PossessInteraction to target's InteractionTable
Release previous possessions
Set releaseAllPossessions = true (default)
Keep existing possessions
Set releaseAllPossessions = false
Fields
releaseAllPossessions
Whether to release all current possessions before possessing the new target. Exposed as an Action Variable for external configuration.
Default: true
Methods
OnExecute (override)
Resolves the possessor/possessable pair and executes possession.
Pipeline:
Get
PossessorfromInteractor.gameObject.GetComponent<Possessable>().GetPossessor()Get
PossessablefromInteractable.GetComponent<Possessable>()If
releaseAllPossessionsistrue, callpossessor.ReleaseAll()Call
possessor.Possess(possessable)
Returns: Task.CompletedTask (synchronous).
Common Pitfalls
Interactor must be a possessed entity The interaction resolves the possessor via Interactor.gameObject.GetComponent<Possessable>().GetPossessor(). If the interactor's GameObject does not have a Possessable component, or if that Possessable is not currently possessed, this will throw a NullReferenceException.
Interactable must have Possessable The target Interactable must have a Possessable component on the same GameObject. Without it, GetComponent<Possessable>() returns null.
ReleaseAll fires before Possess When releaseAllPossessions is true, all current possessions are released (triggering their release actions and events) before the new possession begins. Ordering matters if release actions affect state that the possess action depends on.
Examples
Configuring in InteractionTable
To make an NPC possessable via interaction:
Add an
Interactablecomponent to the NPCAdd a
Possessablecomponent to the NPCIn the
InteractionTable, add anInteractionContextwith:Interaction:
PossessInteractionTrigger: appropriate trigger (e.g.,
ClickTrigger)Conditions: as needed (e.g., proximity check)
Setting releaseAllPossessions via Variable
See Also
Interaction — base class for interaction logic
PossessAction — actions fired during possess/release transitions
Possessor — component that takes control
Possessable — component that can be controlled
Last updated