// Fill out your copyright notice in the Description page of Project Settings. #include "CppAnimation.h" CppAnimation::CppAnimation() { } CppAnimation::~CppAnimation() { } CppAnimation::CppAnimation(UUserWidget* owner, UWidgetAnimation* animation, TArray* modes, TEnumAsByte* lastMode, int32* priority) : WidgetOwner(owner), WidgetAnimation(animation), AnimModes(*modes), lastMode(*lastMode), priorityIndex(*priority) { } void CppAnimation::PlayAnimationMode(TEnumAsByte* mode, int32* priority) { if (!CanMode(mode)) return; if (!CanPlayAnimation(mode)) return; if (priorityIndex > *priority) return; lastMode = *mode; WidgetOwner->PlayAnimation(WidgetAnimation, 0.0f, 1, GetDirection(mode), 1.0f, false); } TEnumAsByte CppAnimation::GetDirection(TEnumAsByte* mode) { for (auto anim : AnimModes) { if (anim.mode == *mode) return anim.direction; } return EUMGSequencePlayMode::Type::Forward; } bool CppAnimation::CanMode(TEnumAsByte* mode) { bool canMode = false; for (int32 i = 0; i < AnimModes.Num(); ++i) { if (AnimModes[i].mode == *mode) { canMode = true; } } return canMode; } bool CppAnimation::CanPlayAnimation(TEnumAsByte* mode) { if (!CanMode(mode)) return false; return lastMode != *mode; }