checkComponentValidity

Why ?

Useful for adding your own check to enable calling to component functions.

Return values :

true = functions can be call

false = functions can not be call

When ?

This function is call before all update functions because if in one of update function, one of your condition is not true, all gonna stop until the same condition is true.

Prototype

// .hpp
bool checkComponentValidity() override;

//.cpp
bool KapEngine::MyGame::MyComponent::checkComponentValidity() {
    if (...) {
        //my component should not start
        return false;
    }
    //my component can start
    return true;
}

Check other component

Do you want check if your GameObject contains other components ?

A function already exists for that. Do not rewrite something useless.

// In your constructor component
addRequireComponent("ComponentName");

You can add several component if your component need other components.

Last updated