1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| UFUNCTION(BlueprintCallable,CustomThunk,meta = (CustomStructureParam = "OutRow", BlueprintInternalUseOnly="true")) static bool TryGetTableRowData(UPARAM(meta=(GetOptions = "GetAllTableStructs"))FName StructName,FName RowName, FTableRowBase& OutRow){return false;}; static bool Generic_TryGetTableRowData(FName StructName, FName RowName, void* OutRowPtr); DECLARE_FUNCTION(execTryGetTableRowData) { P_GET_PROPERTY(FNameProperty, StructName); P_GET_PROPERTY(FNameProperty, RowName); Stack.MostRecentProperty = nullptr; Stack.StepCompiledIn<FStructProperty>(NULL); void* OutRowPtr = Stack.MostRecentPropertyAddress; P_FINISH; bool bSuccess = false; FStructProperty* StructProp = CastField<FStructProperty>(Stack.MostRecentProperty); UDataTable* Table = UDataTableUtility::FindTableByStructName(StructName); if (!Table) { FBlueprintExceptionInfo ExceptionInfo( EBlueprintExceptionType::AccessViolation, NSLOCTEXT("TryGetTableRowData", "MissingStructInput", "Failed to resolve the table input. Be sure the DataTable is valid.") ); FBlueprintCoreDelegates::ThrowScriptException(P_THIS, Stack, ExceptionInfo); } else if(StructProp && OutRowPtr) { UScriptStruct* OutputType = StructProp->Struct; const UScriptStruct* TableType = Table->GetRowStruct(); const bool bCompatible = (OutputType == TableType) || (OutputType->IsChildOf(TableType) && FStructUtils::TheSameLayout(OutputType, TableType)); if (bCompatible) { P_NATIVE_BEGIN; bSuccess = Generic_TryGetTableRowData(StructName, RowName, OutRowPtr); P_NATIVE_END; } else { FBlueprintExceptionInfo ExceptionInfo( EBlueprintExceptionType::AccessViolation, NSLOCTEXT("TryGetTableRowData", "IncompatibleProperty", "Incompatible output parameter; the data table's type is not the same as the return type.") ); FBlueprintCoreDelegates::ThrowScriptException(P_THIS, Stack, ExceptionInfo); } } else { FBlueprintExceptionInfo ExceptionInfo( EBlueprintExceptionType::AccessViolation, NSLOCTEXT("TryGetTableRowData", "MissingOutputProperty", "Failed to resolve the output parameter for GetDataTableRow.") ); FBlueprintCoreDelegates::ThrowScriptException(P_THIS, Stack, ExceptionInfo); } *(bool*)RESULT_PARAM = bSuccess; }
|