Component
- Namespace: Turian.Engine.Core
- Source File: Component.cs
Base class for all components that can be attached to nodes in the scene graph.
Properties
IsActive
(bool) { get; set } = true: Gets or sets a value indicating whether this component is active.
IsDestroyed
(bool) { get; set }: Whether the component was destroyed (detached from its node). A reference to it reads as missing: it is saved as null and never resolved to.
Node
(Node?) { get; set }: Gets the node this component is attached to.
IsAttached
(bool): Gets a value indicating whether this component is currently attached to a node.
IsAwake
(bool) { get; set }: Gets a value indicating whether this component has been awoken.
IsStarted
(bool) { get; set }: Gets a value indicating whether this component has started.
Public Methods
Setup
public void Setup(Node node)
Attaches this component to a node and runs Awake if not yet awoken.
Parameters:
node(Node)
Detach
public void Detach()
Detaches this component from its parent node.
EnsureStarted
public void EnsureStarted()
Ensures OnStart runs exactly once, deferred to the first frame.
OnAwake
public virtual void OnAwake()
Called once on first attachment, even if inactive. Runs before the first update.
OnEnable
public virtual void OnEnable()
Called when the component becomes active. Also called after Awake if active.
OnStart
public virtual void OnStart()
Called once before the first OnUpdate, deferred to first frame.
OnUpdate
public virtual void OnUpdate(float deltaTime)
Called every frame while active.
Parameters:
deltaTime(float)
OnLateUpdate
public virtual void OnLateUpdate(float deltaTime)
Called every frame after all OnUpdate calls.
Parameters:
deltaTime(float)
OnFixedUpdate
public virtual void OnFixedUpdate(float fixedDeltaTime)
Called at a fixed timestep, for physics.
Parameters:
fixedDeltaTime(float)
OnDisable
public virtual void OnDisable()
Called when the component becomes inactive.
OnDestroy
public virtual void OnDestroy()
Called when the component is permanently removed or the node is destroyed.
OnAttached
public virtual void OnAttached()
Called after the component is attached to a node.
OnDetached
public virtual void OnDetached()
Called before the component is detached from its node.
AllowsMultiple
public static bool AllowsMultiple(Type componentType)
Checks if multiple instances of the specified component type are allowed on a single node.
Parameters:
componentType(Type)
Returns: bool
GetRequiredComponents
public static IEnumerable<Type> GetRequiredComponents(Type componentType)
Gets the required component types for the specified component type.
Parameters:
componentType(Type)
Returns: IEnumerable<Type>