Skip to content

Chaos player improvements #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion Source/GameBaseFramework/Private/Chaos/GBFChaosCachePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,41 @@ void AGBFChaosCachePlayer::AddNewObservedComponentFromCacheCollectionIndex( UPri

auto & new_observed_component = AddNewObservedComponent( observed_component );
new_observed_component.CacheName = caches[ collection_index ]->GetFName();
BeginEvaluate();
}

void AGBFChaosCachePlayer::AddNewObservedComponentsFromCacheCollection( UPrimitiveComponent * observed_component )
{
if ( !ensureMsgf( observed_component != nullptr, TEXT( "Observed component is not valid!" ) ) )
{
return;
}

if ( !ensureMsgf( CacheCollection != nullptr, TEXT( "CacheCollection is not valid!" ) ) )
{
return;
}

auto & caches = CacheCollection->GetCaches();

for ( auto & cache : caches )
{
auto & new_observed_component = AddNewObservedComponent( observed_component );
new_observed_component.CacheName = cache->GetFName();
}
}

void AGBFChaosCachePlayer::TriggerComponentByCacheCollectionIndex( const int32 collection_index )
{
auto & caches = CacheCollection->GetCaches();

if ( !ensureMsgf( caches.IsValidIndex( collection_index ), TEXT( "Index %i is not a valid index in cache collection %s" ), collection_index, *CacheCollection.GetFName().ToString() ) )
{
return;
}

const auto cache_name = caches[ collection_index ]->GetFName();

TriggerComponentByCache( cache_name );
}

void AGBFChaosCachePlayer::ResetObservedComponents()
Expand All @@ -33,6 +67,11 @@ void AGBFChaosCachePlayer::ResetObservedComponents()
BeginEvaluate();
}

void AGBFChaosCachePlayer::K2_BeginEvaluate()
{
BeginEvaluate();
}

void AGBFChaosCachePlayer::BeginPlay()
{
Super::BeginPlay();
Expand Down
9 changes: 9 additions & 0 deletions Source/GameBaseFramework/Public/Chaos/GBFChaosCachePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@ class GAMEBASEFRAMEWORK_API AGBFChaosCachePlayer : public AChaosCachePlayer
UFUNCTION( BlueprintCallable )
void AddNewObservedComponentFromCacheCollectionIndex( UPrimitiveComponent * observed_component, int32 collection_index );

UFUNCTION( BlueprintCallable )
void AddNewObservedComponentsFromCacheCollection( UPrimitiveComponent * observed_component );

UFUNCTION( BlueprintCallable )
void TriggerComponentByCacheCollectionIndex( int32 collection_index );

UFUNCTION( BlueprintCallable )
void ResetObservedComponents();

UFUNCTION( BlueprintCallable, DisplayName = "BeginEvaluate" )
void K2_BeginEvaluate();

void BeginPlay() override;
};