IParagonComponent

Interface for modular components that attach to IParagonBehaviour instances via the ParagonSubsystem. Defines the lifecycle contract — initialization, add/remove callbacks, per-frame ticking, and destruction. Also includes a generic variant IParagonComponent<TBehaviour> for type-safe owner access.

Definition

Namespace: Paragon Assembly: Paragon.dll

public interface IParagonComponent

Remarks

IParagonComponent is the contract for the composition-over-inheritance pattern in Paragon. Instead of building deep inheritance hierarchies, game code creates lightweight components that are added to a behaviour's subsystem at runtime or serialization time.

Lifecycle

Phase
Method
Called When

Added

OnAdded(IParagonBehaviour)

Component is added to a subsystem via AddComponent()

Initialized

Initialize()

Subsystem initializes all components (typically during Awake or Start)

Ticking

Tick(float dt)

Each frame update (if the behaviour drives ticking)

Removed

OnRemoved(IParagonBehaviour)

Component is removed from the subsystem

Destroyed

Destroy()

Component is being permanently destroyed

Default Interface Methods

Tick() and Destroy() have empty default implementations, making them optional to implement. Initialize(), OnAdded(), and OnRemoved() must be explicitly implemented.

Quick Lookup

Goal
How

Get the owning behaviour

component.Owner

Initialize the component

component.Initialize()

Update per frame

component.Tick(deltaTime)

Implement a component

Properties

Owner

The IParagonBehaviour that this component is attached to.

Methods

Initialize

Called when the subsystem initializes all its components.

OnAdded

Called when this component is added to a behaviour's subsystem.

Parameter
Type
Description

behaviour

IParagonBehaviour

The behaviour this component is being added to

OnRemoved

Called when this component is removed from a behaviour's subsystem.

Parameter
Type
Description

behaviour

IParagonBehaviour

The behaviour this component is being removed from

Tick

Per-frame update tick. Has an empty default implementation — override only if the component needs per-frame logic.

Parameter
Type
Description

dt

float

Delta time since last tick

Destroy

Called when the component is being permanently destroyed. Has an empty default implementation.


Implementation Requirements

When implementing IParagonComponent<TBehaviour>, you MUST:

  1. Implement Owner, OnAdded(TBehaviour), OnRemoved(TBehaviour), and Initialize()

  2. Ensure TBehaviour implements IParagonSubsystem<TBehaviour> (the self-referencing constraint)

circle-info

In practice, always subclass ParagonComponent<TBehaviour> rather than implementing this interface directly. It handles owner assignment in OnAdded/OnRemoved, provides virtual lifecycle hooks, and integrates with the debug system.

IParagonComponent<TBehaviour>

Type-safe variant that provides strongly-typed owner access and callbacks. Uses default interface methods to bridge the non-generic IParagonComponent methods to the typed versions.

Definition

Extends: IParagonComponent Type Constraint: TBehaviour : class, IParagonSubsystem<TBehaviour>

Remarks

This generic variant re-declares Owner, OnAdded(), and OnRemoved() with TBehaviour instead of IParagonBehaviour. The non-generic members are implemented via default interface methods that cast and delegate:

This means implementors only need to implement the typed versions — the non-generic interface is satisfied automatically.

Properties

Owner

The strongly-typed owner behaviour.

Methods

OnAdded

Type-safe callback when added to the owner.

OnRemoved

Type-safe callback when removed from the owner.

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated