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 : Interaction

Inheritance: 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:

  1. Possessor — obtained from the interactor's Possessable component via GetPossessor(). This means the interactor must itself be possessed (the interacting body is possessed by something, and that something becomes the new possessor).

  2. Possessable — obtained directly from the interactable's Possessable component.

circle-info

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

Goal
How

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:

  1. Get Possessor from Interactor.gameObject.GetComponent<Possessable>().GetPossessor()

  2. Get Possessable from Interactable.GetComponent<Possessable>()

  3. If releaseAllPossessions is true, call possessor.ReleaseAll()

  4. Call possessor.Possess(possessable)

Returns: Task.CompletedTask (synchronous).

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Configuring in InteractionTable

To make an NPC possessable via interaction:

  1. Add an Interactable component to the NPC

  2. Add a Possessable component to the NPC

  3. In the InteractionTable, add an InteractionContext with:

    • Interaction: PossessInteraction

    • Trigger: appropriate trigger (e.g., ClickTrigger)

    • Conditions: as needed (e.g., proximity check)

Setting releaseAllPossessions via Variable

See Also

Last updated