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 IParagonComponentRemarks
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
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
Get the owning behaviour
component.Owner
Initialize the component
component.Initialize()
Update per frame
component.Tick(deltaTime)
Implement a component
Subclass ParagonComponent<T>
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.
behaviour
IParagonBehaviour
The behaviour this component is being added to
OnRemoved
Called when this component is removed from a behaviour's subsystem.
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.
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:
Implement
Owner,OnAdded(TBehaviour),OnRemoved(TBehaviour), andInitialize()Ensure
TBehaviourimplementsIParagonSubsystem<TBehaviour>(the self-referencing constraint)
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
OnAdded casts without checking The default interface method IParagonComponent.OnAdded(IParagonBehaviour) casts directly to TBehaviour via (TBehaviour)behaviour. If a component is added to the wrong behaviour type, this will throw InvalidCastException.
Components are keyed by concrete type ParagonSubsystem stores components in a Dictionary<Type, IParagonComponent> keyed by component.GetType(). This means only one instance per concrete type can exist in a subsystem. Adding a second component of the same type will throw.
See Also
ParagonComponent<TBehaviour> — abstract base class that implements this interface
IParagonBehaviour — owner interface
IParagonSubsystem<TBehaviour> — the
TBehaviourconstraint requirementParagonSubsystem — container that manages components
Interfaces Overview — interface hierarchy overview
Last updated