CharacterComponent

Abstract base class for all modular components attached to a Character. Extends ParagonComponent<Character> to provide a strongly-typed Character accessor and integrate with the subsystem composition lifecycle.

Definition

Namespace: Paragon.Townskeep.CharacterSystem Assembly: Townskeep.dll

[Serializable]
public abstract class CharacterComponent : ParagonComponent<Character>

Inheritance: ParagonComponent<Character> → CharacterComponent

Remarks

CharacterComponent is the Townskeep-specific specialization of ParagonComponent<Character>. All character subsystems (motor, controller, camera, animator, interactor, inventory, network) derive from this class.

Lifecycle

Components are discovered and registered automatically when Character.Awake() calls InitializeSubsystem(). The lifecycle is:

  1. Discovery — The subsystem scans the GameObject hierarchy for all IParagonComponent<Character> instances

  2. OnAdded — Each component receives its owner (Character) reference, stored in owner

  3. Initialize / OnInitialize — Called once; override OnInitialize() for setup that depends on the owner

  4. Tick — Called every frame from Character.Update() with Time.deltaTime

  5. Destroy — Called from Character.OnDestroy() to clean up resources

Accessing the Owner

The Character property provides a typed reference to the owning character. This is a convenience alias for the owner field inherited from ParagonComponent<Character>.

Quick Lookup

Goal
How

Access the owning character

this.Character

Override initialization

protected override void OnInitialize()

Override per-frame update

protected override void Tick(float dt)

Override debug drawing

public override void OnDebug()

Properties

Property
Type
Description

Character

Character

The owning character entity (alias for owner)

Extension Points

Optional Overrides

Method
Inherited From
Purpose

OnInitialize()

ParagonComponent<T>

Setup logic after the owner is assigned. Access other components here.

Tick(float dt)

ParagonComponent<T>

Per-frame update driven by Character.Update()

OnAdded(Character)

ParagonComponent<T>

Called when this component is added to a character

OnRemoved(Character)

ParagonComponent<T>

Called when this component is removed from a character

OnDebug()

ParagonObject

Debug visualization (e.g., Gizmos, DrawLine)

Implementation Requirements

When subclassing CharacterComponent, you MUST:

  1. Mark the class with [Serializable] for Unity serialization

  2. Ensure the component is attached to the Character's GameObject hierarchy (so it is discovered by InitializeSubsystem())

You SHOULD:

  • Override OnInitialize() to cache references to sibling components (e.g., Character.Motor)

  • Override Tick(float dt) for per-frame logic

  • Override OnDebug() for visual debugging

You SHOULD NOT:

  • Access Character before OnInitialize() — the owner field is not set until OnAdded() runs

  • Use Awake() or Start() for initialization — use OnInitialize() instead so that the owner reference is guaranteed to be set

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Creating a Custom Character Component

Accessing Sibling Components

See Also

Last updated