IParagonSubsystem

Marker interface for IParagonBehaviour implementations that use the component subsystem. Provides type-safe access to a ParagonSubsystem<TBehaviour> via a default interface method that casts from the base Subsystem property.

Definition

Namespace: Paragon Assembly: Paragon.dll

public interface IParagonSubsystem<TBehaviour> : IParagonBehaviour
    where TBehaviour : class, IParagonSubsystem<TBehaviour>

Extends: IParagonBehaviour Type Constraint: TBehaviour : class, IParagonSubsystem<TBehaviour> (CRTP / self-referencing)

Remarks

This interface uses the Curiously Recurring Template Pattern (CRTP)TBehaviour must be the implementing class itself. This enables type-safe component management throughout the subsystem hierarchy:

IParagonSubsystem<Enemy>     ← Enemy implements this
  └── ParagonSubsystem<Enemy>  ← strongly typed container
       └── IParagonComponent<Enemy>  ← components know their owner type

Self-Referencing Constraint

The constraint where TBehaviour : class, IParagonSubsystem<TBehaviour> means TBehaviour must implement this very interface with itself as the type parameter. This ensures the type chain is consistent from subsystem to components.

Default Interface Method

The Subsystem property is implemented as a default interface method that casts from the base IParagonBehaviour.Subsystem:

This avoids requiring implementors to add an extra property — they only need the base IParagonBehaviour.Subsystem property (already provided by ParagonBehaviour).

Quick Lookup

Goal
How

Get typed subsystem

behaviour.Subsystem (returns ParagonSubsystem<T>)

Add a component

Use extension: behaviour.AddSubcomponent(component)

Get a component

Use extension: behaviour.GetSubcomponent<TBehaviour, TComponent>()

Mark a class as subsystem-enabled

Implement IParagonSubsystem<TSelf>

Properties

Subsystem

Returns the behaviour's subsystem cast to the strongly-typed ParagonSubsystem<TBehaviour>.

circle-exclamation

Implementation Requirements

When implementing IParagonSubsystem<TBehaviour>, you MUST:

  1. Implement all IParagonBehaviour requirements (subsystem, debug)

  2. Use the implementing class itself as TBehaviour (CRTP pattern)

  3. Ensure the underlying Subsystem property returns a ParagonSubsystem<TBehaviour> instance

Examples

Defining a Subsystem-Enabled Behaviour

Adding Components

See Also

Last updated