void UKismetArrayLibrary::GenericArray_Append(void* TargetArray, const UArrayProperty* TargetArrayProp, void* SourceArray, const UArrayProperty* SourceArrayProperty) { if(TargetArray && SourceArray) { FScriptArrayHelper TargetArrayHelper(TargetArrayProp, TargetArray); FScriptArrayHelper SourceArrayHelper(SourceArrayProperty, SourceArray); if(SourceArrayHelper.Num() > 0) { UProperty* InnerProp = TargetArrayProp->Inner; int32 StartIdx = TargetArrayHelper.AddValues(SourceArrayHelper.Num()); for(int32 x = 0; x < SourceArrayHelper.Num(); ++x, ++StartIdx) { InnerProp->CopySingleValueToScriptVM(TargetArrayHelper.GetRawPtr(StartIdx), SourceArrayHelper.GetRawPtr(x)); } } } }
void UKismetArrayLibrary::GenericArray_Insert(void* TargetArray, const UArrayProperty* ArrayProp, const void* NewItem, int32 Index) { if( TargetArray ) { FScriptArrayHelper ArrayHelper(ArrayProp, TargetArray); UProperty* InnerProp = ArrayProp->Inner; if (ArrayHelper.IsValidIndex(Index) || (Index >= 0 && Index <= ArrayHelper.Num()) ) { ArrayHelper.InsertValues(Index, 1); InnerProp->CopySingleValueToScriptVM(ArrayHelper.GetRawPtr(Index), NewItem); } else { FFrame::KismetExecutionMessage(*FString::Printf(TEXT("Attempted to insert an item into array %s out of bounds [%d/%d]!"), *ArrayProp->GetName(), Index, GetLastIndex(ArrayHelper)), ELogVerbosity::Warning); } } }
void UKismetArrayLibrary::GenericArray_Set(void* TargetArray, const UArrayProperty* ArrayProp, int32 Index, const void* NewItem, bool bSizeToFit) { if( TargetArray ) { FScriptArrayHelper ArrayHelper(ArrayProp, TargetArray); UProperty* InnerProp = ArrayProp->Inner; // Expand the array, if desired if (!ArrayHelper.IsValidIndex(Index) && bSizeToFit && (Index >= 0)) { ArrayHelper.ExpandForIndex(Index); } if (ArrayHelper.IsValidIndex(Index)) { InnerProp->CopySingleValueToScriptVM(ArrayHelper.GetRawPtr(Index), NewItem); } else { FFrame::KismetExecutionMessage(*FString::Printf(TEXT("Attempted to set an invalid index on array %s [%d/%d]!"), *ArrayProp->GetName(), Index, GetLastIndex(ArrayHelper)), ELogVerbosity::Warning); } } }