Add campfire persistence state

This commit is contained in:
2026-05-17 19:09:55 -07:00
parent c60b975294
commit 7291c4844b
8 changed files with 171 additions and 2 deletions
@@ -1,6 +1,7 @@
// Copyright Pacificao. All Rights Reserved.
#include "AgrarianPersistentActorComponent.h"
#include "AgrarianPersistentStateProvider.h"
UAgrarianPersistentActorComponent::UAgrarianPersistentActorComponent()
{
@@ -14,6 +15,13 @@ bool UAgrarianPersistentActorComponent::IsSaveable() const
FAgrarianSavedWorldActor UAgrarianPersistentActorComponent::CaptureSaveState() const
{
if (const AActor* Owner = GetOwner(); Owner && Owner->Implements<UAgrarianPersistentStateProvider>())
{
IAgrarianPersistentStateProvider::Execute_CapturePersistentState(
const_cast<AActor*>(Owner),
const_cast<UAgrarianPersistentActorComponent*>(this));
}
FAgrarianSavedWorldActor SavedActor;
SavedActor.ActorTypeId = ActorTypeId;
SavedActor.StringState = StringState;
@@ -41,4 +49,9 @@ void UAgrarianPersistentActorComponent::ApplySaveState(const FAgrarianSavedWorld
{
GetOwner()->SetActorTransform(SavedActor.Transform);
}
if (AActor* Owner = GetOwner(); Owner && Owner->Implements<UAgrarianPersistentStateProvider>())
{
IAgrarianPersistentStateProvider::Execute_ApplyPersistentState(Owner, this);
}
}