Download

How do you organize Blueprint properties assertions?

I know that things like this are of personal preference, but I would like suggestions on how you guys do it.
I have done it this way, but it does not seem “right” to me ( although this avoids tests for each case ) :



void APlayer::BeginPlay()
{
    Super::BeginPlay();

    ValidateProperties();
}

void APlayer::ValidateProperties()
{
    ensureMsgf(NormalFlipbook, TEXT("NormalFlipbook is NULL."));
    ensureMsgf(RunningFlipbook, TEXT("RunningFlipbook is NULL."));
    ensureMsgf(JumpingFlipbook, TEXT("JumpingFlipbook is NULL."));
    ...
}

I could do it that way too, but the code would look bigger ( but I would use if it’s a “convention” ) :


switch (PlayerState)
    {
    case EPlayerState::Normal:
        if (ensureMsgf(NormalFlipbook, TEXT("NormalFlipbook is NULL.")))
        {
            PlayerFlipbook->SetFlipbook(NormalFlipbook);
        }
        break;
    case EPlayerState::Running:
        if (ensureMsgf(RunningFlipbook, TEXT("RunningFlipbook is NULL.")))
        {
            PlayerFlipbook->SetFlipbook(RunningFlipbook);
        }
        break;
        ...
    }

I’m on my first project using Unreal, if you have any comments about this or even suggestion you’re welcome!
Thank you!