haxis/Source/UnrealProject/Creatures/MinionAnimInstance.h

67 lines
2.7 KiB
C++

// Project Lab - NHTV Igad
#pragma once
#include "Animation/AnimInstance.h"
#include "MinionAnimInstance.generated.h"
// Enum that shows in what state the Animation Instance is in.
UENUM(BlueprintType)
enum class EMinionAnimState : uint8
{
MAS_Idle UMETA(DisplayName = "Idle"),
MAS_Pointing UMETA(DisplayName = "Pointing"),
MAS_Attacking UMETA(DisplayName = "Attacking"),
MAS_Casting UMETA(DisplayName = "Casting"),
MAS_Guarding UMETA(DisplayName = "Guarding"),
MAS_Staggered UMETA(DisplayName = "Staggered"),
MAS_Stunned UMETA(DisplayName = "Stunned"),
MAS_Killed UMETA(DisplayName = "Killed"),
MAS_Specific UMETA(DisplayName = "Specific")
};
// Delegate declaration for when the Animation Instance changes its state from within.
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAnimationStateChanged, EMinionAnimState, newState);
/**
* Animation instance that handles all state changing, variable gathering and notifying the AI class.
*/
UCLASS()
class UNREALPROJECT_API UMinionAnimInstance : public UAnimInstance
{
GENERATED_BODY()
public:
UMinionAnimInstance(const FObjectInitializer& init);
virtual void NativeInitializeAnimation() override;
virtual void NativeUpdateAnimation(float deltaSeconds) override;
// Function to get the animation state of the animation instance.
EMinionAnimState GetAnimationState();
// Helper function for checking if the minion is in a certain state.
bool IsInAnimationState(const EMinionAnimState minionStateCheck);
// Function that changes the state of the minion. Does not trigger OnAnimationStateChanged.
UFUNCTION(BlueprintCallable, Category = "Animation State")
void ChangeAnimationStateTo(EMinionAnimState newState);
// Function that changes the state of the minion. Triggers OnAnimationStateChanged.
// Made specifically for use in the Animation Blueprint.
UFUNCTION(BlueprintCallable, Category = "Animation State")
void BPChangeAnimationStateTo(EMinionAnimState newState);
// Delegate for when the state of the minion changes.
UPROPERTY(BlueprintAssignable, Category = "Animation State")
FOnAnimationStateChanged OnAnimationStateChanged;
UFUNCTION()
void PlaySpecificAnimationByInt(int32 animationToPlay);
protected: // Member variables are protected.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Animation State")
EMinionAnimState m_animationState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Animation State")
float m_movementSpeed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Animation State")
FVector m_movementDirectionRelative;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Animation State")
int32 m_specificAnimationIndex;
};