Add spell interactable door

This commit is contained in:
2025-05-15 00:28:56 -04:00
parent bcca018acd
commit b072b71a9e
12 changed files with 108 additions and 8 deletions
@@ -288,6 +288,16 @@ void ALumiCharacter::AddSpellTemplateToTable(const FString& Name)
HideTrainWidget();
}
void ALumiCharacter::OnSpellCast_Implementation(const FString& SpellName)
{
UE_LOG(
LogLumiCharacter,
Log,
TEXT("ALumiCharacter::OnSpellCast_Implementation() Spell: %s"),
*SpellName
);
}
bool ALumiCharacter::GetPlayerController(APlayerController*& LumiController) const
{
LumiController = Cast<APlayerController>(this->Controller);
@@ -323,6 +333,8 @@ void ALumiCharacter::CastSpell()
{
bHasMatch = true;
UE_LOG(LogLumiCharacter, Log, TEXT("ALumiCharacter::CastSpell() Spell: %s"), *Result.Name);
OnSpellCast(Result.Name);
}
// TODO: Handle Spell Casting
@@ -201,6 +201,10 @@ protected:
virtual void
BeginPlay() override;
UFUNCTION(BlueprintNativeEvent, Category = "Spell")
void
OnSpellCast(const FString& SpellName);
private:
bool
GetPlayerController(APlayerController*& LumiController) const;
@@ -0,0 +1,27 @@
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "SpellInteractable.generated.h"
UINTERFACE(MinimalAPI, Blueprintable)
class USpellInteractable : public UInterface
{
GENERATED_BODY()
};
/**
* Interface for objects that can be interacted with by spells.
*/
class WIZARDINGCENTRAL_API ISpellInteractable
{
GENERATED_BODY()
public:
/**
* Called when the spell is cast on the object.
* @param SpellName The name of the spell that was cast.
*/
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Spell")
void OnSpellCast(const FString& SpellName);
};
@@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SpellInteractableActor.h"
// Sets default values
ASpellInteractableActor::ASpellInteractableActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ASpellInteractableActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ASpellInteractableActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
@@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "SpellInteractable.h"
#include "GameFramework/Actor.h"
#include "SpellInteractableActor.generated.h"
UCLASS()
class WIZARDINGCENTRAL_API ASpellInteractableActor : public AActor,
public ISpellInteractable
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASpellInteractableActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};