package com.dropbear.components;

import com.dropbear.EucalyptusCoreLoader;

/**
 * JNI bridge for Kotlin-defined ECS components.
 *
 * <p>The Rust side implements each {@code native} method. The component lifecycle
 * (onAttach / update / onDetach) is driven by Rust calling back into the JVM's
 * ComponentManager (generated by magna-carta for JVM targets); this class covers
 * the Kotlin → Rust direction only.
 */
public class ComponentNative {
    static {
        new EucalyptusCoreLoader().ensureLoaded();
    }

    /**
     * Returns {@code true} if the entity identified by {@code entityId} has a
     * {@code KotlinComponent} entry keyed by {@code fqcn} in the Rust world.
     */
    public static native boolean hasKotlinComponent(long worldPtr, long entityId, String fqcn);

    /**
     * Registers a Kotlin component type with Rust's {@code ComponentRegistry} so that it is
     * serialisable, inspectable in the editor, and dispatchable.
     *
     * <p>Call this once per type at startup, typically from the generated
     * {@code ComponentManager.registerAll()}.
     *
     * @param category    may be null or empty
     * @param description may be null or empty
     */
    public static native void registerKotlinComponent(
            long worldPtr,
            String fqcn,
            String typeName,
            String category,
            String description);
}
