#include "transform_node.h"
#include "utils/typeclass_helpers.h"

START_REFLECT(TransformNode);
REFLECT_TYPECLASS(TransformNode, SceneNodeEntity);
REFLECT_TYPECLASS(TransformNode, Transformable);
REFLECT_TYPECLASS(TransformNode, Drop);
END_REFLECT(TransformNode);

impl_Drop_for(TransformNode,
    DestroyTransformNode
)
impl_Transformable_for(TransformNode,
    TransformNodeGetTransform,
    TransformNodeGetGlobalTransform
)
impl_SceneNodeEntity_defaults(TransformNode);
impl_SceneNodeEntity_for(TransformNode,
    TransformNode_default_enter_tree,
    TransformNode_default_exit_tree,
    TransformNode_default_tick
)

SceneNode *CreateTransformNode() {
    TransformNode *self = new(TransformNode);
    self->global_transform = TransformIdentity();
    self->transform = TransformIdentity();
    return CreateSceneNode(TransformNode_as_SceneNodeEntity(self));
}

void DestroyTransformNode(TransformNode *self) {
    free(self);
}

Transform *TransformNodeGetTransform(TransformNode *self) {
    return &self->transform;
}

Transform *TransformNodeGetGlobalTransform(TransformNode *self) {
    return &self->global_transform;
}
