ComponentInterface

Namespace:

namespace Lenga\Engine\Interfaces;

Base marker interface for all Lenga components. RendererInterface and TransformInterface extend this interface. Engine systems that operate on any component can type-hint against ComponentInterface to accept the full range of component types.

You rarely need to implement this interface directly. Behaviour already satisfies it. It is mostly useful when writing reusable gameplay helpers that accept any component reference.

Example

use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Interfaces\ComponentInterface;

/**
 * Utility that logs information about any component attached to a game object.
 */
function debugComponent(ComponentInterface $component): void
{
    echo get_class($component) . PHP_EOL;
}

class DebugHelper extends Behaviour
{
    public function start(): void
    {
        // Pass any component to the utility
        debugComponent($this->getComponent(Rigidbody3D::class));
    }
}