void UGameplayTask::InitTask(IGameplayTaskOwnerInterface& InTaskOwner, uint8 InPriority)
{
	Priority = InPriority;
	TaskOwner = InTaskOwner;
	UGameplayTasksComponent* GTComponent = InTaskOwner.GetGameplayTasksComponent(*this);
	TasksComponent = GTComponent;

	bOwnedByTasksComponent = (TaskOwner == GTComponent);
	
	TaskState = EGameplayTaskState::AwaitingActivation;

	if (bClaimRequiredResources)
	{
		ClaimedResources.AddSet(RequiredResources);
	}

	InTaskOwner.OnTaskInitialized(*this);
	if (bOwnedByTasksComponent == false && GTComponent != nullptr)
	{
		GTComponent->OnTaskInitialized(*this);
	}
}
void UGameplayTask::InitTask(IGameplayTaskOwnerInterface& InTaskOwner, uint8 InPriority)
{
    Priority = InPriority;
    TaskOwner = InTaskOwner;
    TaskState = EGameplayTaskState::AwaitingActivation;

    if (bClaimRequiredResources)
    {
        ClaimedResources.AddSet(RequiredResources);
    }

    // call owner.OnGameplayTaskInitialized before accessing owner.GetGameplayTasksComponent, this is required for child tasks
    InTaskOwner.OnGameplayTaskInitialized(*this);

    UGameplayTasksComponent* GTComponent = InTaskOwner.GetGameplayTasksComponent(*this);
    TasksComponent = GTComponent;
    bOwnedByTasksComponent = (TaskOwner == GTComponent);

    // make sure that task component knows about new task
    if (GTComponent && !bOwnedByTasksComponent)
    {
        GTComponent->OnGameplayTaskInitialized(*this);
    }
}