Add campfire cooking placeholder

This commit is contained in:
2026-05-17 18:50:59 -07:00
parent c61b226f47
commit 0ac4bec3cf
7 changed files with 135 additions and 3 deletions
+23
View File
@@ -36,6 +36,11 @@ void AAgrarianCampfire::Tick(float DeltaSeconds)
SetLit(false);
}
if (CanCook())
{
CookingProgressSeconds = FMath::Min(CookingSecondsRequired, CookingProgressSeconds + DeltaSeconds);
}
WarmNearbyCharacters(DeltaSeconds);
}
}
@@ -45,6 +50,9 @@ void AAgrarianCampfire::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Ou
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AAgrarianCampfire, bLit);
DOREPLIFETIME(AAgrarianCampfire, FuelSeconds);
DOREPLIFETIME(AAgrarianCampfire, bCookingPlaceholderEnabled);
DOREPLIFETIME(AAgrarianCampfire, CookingSecondsRequired);
DOREPLIFETIME(AAgrarianCampfire, CookingProgressSeconds);
}
FText AAgrarianCampfire::GetInteractionText_Implementation(const AAgrarianGameCharacter* Interactor) const
@@ -96,6 +104,21 @@ void AAgrarianCampfire::Extinguish()
}
}
bool AAgrarianCampfire::CanCook() const
{
return bLit && bCookingPlaceholderEnabled && CookingSecondsRequired > 0.0f;
}
float AAgrarianCampfire::GetCookingProgressRatio() const
{
if (CookingSecondsRequired <= 0.0f)
{
return 0.0f;
}
return FMath::Clamp(CookingProgressSeconds / CookingSecondsRequired, 0.0f, 1.0f);
}
void AAgrarianCampfire::OnRep_FireState()
{
UpdateVisualState();