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:
Discovery — The subsystem scans the GameObject hierarchy for all
IParagonComponent<Character>instancesOnAdded — Each component receives its owner (
Character) reference, stored inownerInitialize / OnInitialize — Called once; override
OnInitialize()for setup that depends on the ownerTick — Called every frame from
Character.Update()withTime.deltaTimeDestroy — 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
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
Character
Character
The owning character entity (alias for owner)
Extension Points
Optional Overrides
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:
Mark the class with
[Serializable]for Unity serializationEnsure 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 logicOverride
OnDebug()for visual debugging
You SHOULD NOT:
Access
CharacterbeforeOnInitialize()— theownerfield is not set untilOnAdded()runsUse
Awake()orStart()for initialization — useOnInitialize()instead so that the owner reference is guaranteed to be set
Common Pitfalls
Accessing sibling components too early In OnInitialize(), you can safely call Character.Motor, Character.Controller, etc. However, the initialization order of sibling components is not guaranteed. If your component depends on another component being fully initialized, consider deferring that logic to Tick() or using lazy initialization.
Forgetting [Serializable] CharacterComponent is serialized by Unity via Odin. Missing [Serializable] will cause the component's fields to not appear in the Inspector and not survive domain reloads.
Examples
Creating a Custom Character Component
Accessing Sibling Components
See Also
Character — the owning entity that discovers and ticks components
CharacterController — concrete component: command facade
CharacterMotor — concrete component: physics movement
Component Overview — inheritance hierarchy
Last updated