Some minor touchups to FlxAnimationStep

This commit is contained in:
2023-09-20 01:40:58 -04:00
parent 1d8bdfc7bf
commit 0b5fc799ac
3 changed files with 61 additions and 7 deletions

Binary file not shown.

View File

@@ -86,10 +86,51 @@ FString UlxAnimationStepLibrary::AnimationStepDebugString(const FlxAnimationStep
}
void UlxAnimationStepLibrary::UnpackAnimationStep(const FlxAnimationStep& step,
const FString& prefix, UObject* into, bool preclear) {
step.Unpack(prefix, into, preclear);
const FString& prefix, UObject* into) {
step.Unpack(prefix, into, true);
};
static FlxAnimationField FindAnimationField(const FlxAnimationStep& step, const FString& name) {
std::string_view body((const char*)(step.Body.GetData()), step.Body.Num());
FTCHARToUTF8 utf8name(name);
std::string_view uname(utf8name.Get(), utf8name.Length());
FlxAnimationStepDecoder decoder(body);
FlxAnimationField result;
while (!decoder.AtEOF()) {
result = decoder.ReadField();
if (result.Name == uname) {
return result;
}
}
result.Type = ElxAnimValueType::INVALID;
return result;
}
FVector UlxAnimationStepLibrary::AnimationStepGetVector(const FlxAnimationStep& step, const FString& name) {
FlxAnimationField field = FindAnimationField(step, name);
if (field.Type != ElxAnimValueType::XYZ) return FVector(0, 0, 0);
return FVector(field.X, field.Y, field.Z);
}
double UlxAnimationStepLibrary::AnimationStepGetFloat(const FlxAnimationStep& step, const FString& name) {
FlxAnimationField field = FindAnimationField(step, name);
if (field.Type != ElxAnimValueType::NUMBER) return 0.0;
return field.X;
}
#pragma optimize("", off)
FString UlxAnimationStepLibrary::AnimationStepGetString(const FlxAnimationStep& step, const FString& name) {
FlxAnimationField field = FindAnimationField(step, name);
if (field.Type != ElxAnimValueType::STRING) return TEXT("");
return FString(field.S.size(), (const UTF8CHAR*)(field.S.data()));
}
bool UlxAnimationStepLibrary::AnimationStepGetBool(const FlxAnimationStep& step, const FString& name) {
FlxAnimationField field = FindAnimationField(step, name);
if (field.Type != ElxAnimValueType::BOOLEAN) return false;
return field.X == 1.0;
}
FlxAnimationStepView FlxAnimQueueDecoder::ReadStep() {
FlxAnimationStepView result;
result.Hash = Decoder.read_uint64();

View File

@@ -111,12 +111,25 @@ class INTEGRATION_API UlxAnimationStepLibrary : public UObject
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Tangibles)
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static FString AnimationStepDebugString(const FlxAnimationStep& step);
UFUNCTION(BlueprintCallable, Category = Tangibles)
UFUNCTION(BlueprintCallable, Category = Luprex)
static void UnpackAnimationStep(const FlxAnimationStep& step,
const FString& prefix, UObject* into, bool preclear = true);
const FString& VariableNamePrefix, UObject* into);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static FVector AnimationStepGetVector(const FlxAnimationStep& step, const FString& name);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static double AnimationStepGetFloat(const FlxAnimationStep& step, const FString& name);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static FString AnimationStepGetString(const FlxAnimationStep& step, const FString& name);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static bool AnimationStepGetBool(const FlxAnimationStep& step, const FString& name);
};
////////////////////////////////////////////////