UExample::UExample() { FString BaseName(TEXT("Example")); FRandomStream Rand; for (int i = 0; i < 10; i++) { FString StructName = BaseName + FString::FromInt(i); ExampleMap.Add(*StructName); ExampleMap[*StructName].Var1 = Rand.FRand(); ExampleMap[*StructName].Var2 = Rand.FRand(); ExampleMap[*StructName].Var3 = Rand.FRand(); ExampleMap[*StructName].Var4 = Rand.FRand(); } }
void ASpellDeck::Shuffle() { int64 DateInSeconds = FDateTime::Now().ToUnixTimestamp(); FRandomStream SRand = FRandomStream(); SRand.Initialize(DateInSeconds); int32 j; for (int32 i = spellDeck.Num() - 1; i > 0; i--) { j = FMath::FloorToInt(SRand.FRand()*(i + 1)); UActionCard* temp = spellDeck[i]; spellDeck[i] = spellDeck[j]; spellDeck[j] = temp; } }
float UKismetMathLibrary::RandomFloatFromStream(const FRandomStream& Stream) { return Stream.FRand(); }