Ejemplo n.º 1
0
void UBTDecorator_TimeLimit::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray<FString>& Values) const
{
	Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values);

	FBTAuxiliaryMemory* DecoratorMemory = GetSpecialNodeMemory<FBTAuxiliaryMemory>(NodeMemory);
	if (OwnerComp.GetWorld())
	{
		const float TimeLeft = DecoratorMemory->NextTickRemainingTime > 0 ? DecoratorMemory->NextTickRemainingTime : 0;
		Values.Add(FString::Printf(TEXT("%s in %ss"),
			*UBehaviorTreeTypes::DescribeNodeResult(EBTNodeResult::Failed),
			*FString::SanitizeFloat(TimeLeft)));
	}
}
Ejemplo n.º 2
0
bool UBTDecorator_TagCooldown::HasCooldownFinished(const UBehaviorTreeComponent& OwnerComp) const
{
	const float TagCooldownEndTime = OwnerComp.GetTagCooldownEndTime(CooldownTag);

	if (TagCooldownEndTime == 0.f)
	{
		// special case, we don't have an end time yet for this cooldown tag
		return true;
	}

	const float TimePassed = (OwnerComp.GetWorld()->GetTimeSeconds() - TagCooldownEndTime);

	return TimePassed >= CooldownDuration;
}
Ejemplo n.º 3
0
void UBTDecorator_TagCooldown::DescribeRuntimeValues(const UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTDescriptionVerbosity::Type Verbosity, TArray<FString>& Values) const
{
	Super::DescribeRuntimeValues(OwnerComp, NodeMemory, Verbosity, Values);
	
	const float TagCooldownEndTime = OwnerComp.GetTagCooldownEndTime(CooldownTag);

	// if the tag cooldown end time is 0.f then it hasn't been set yet.
	if (TagCooldownEndTime > 0.f)
	{
		const float TimePassed = (OwnerComp.GetWorld()->GetTimeSeconds() - TagCooldownEndTime);

		if (TimePassed < CooldownDuration)
		{
			Values.Add(FString::Printf(TEXT("%s in %ss"),
				(FlowAbortMode == EBTFlowAbortMode::None) ? TEXT("unlock") : TEXT("restart"),
				*FString::SanitizeFloat(CooldownDuration - TimePassed)));
		}
	}
}