HAxis sos

This commit is contained in:
guus
2018-08-11 16:46:35 +02:00
commit 510654f8a1
480 changed files with 54126 additions and 0 deletions

View File

@@ -0,0 +1,241 @@
// Project Lab - NHTV Igad
#include "UnrealProject.h"
#include "UnrealNetwork.h"
#include "AbilityIndicator.h"
// Sets default values
AAbilityIndicator::AAbilityIndicator()
{
PrimaryActorTick.bCanEverTick = true;
m_followActor = nullptr;
m_duration = 0.0f;
bReplicates = true;
}
AFillingAbilityIndicator::AFillingAbilityIndicator()
{
}
void AAbilityIndicator::BeginPlay()
{
FVector pos;
FRotator rot;
if (m_followActor)
{
pos = m_followActor->GetActorLocation();
rot = m_followActor->GetActorRotation() + m_rotationOffset;
}
else
{
pos = GetActorLocation();
rot = GetActorRotation() + m_rotationOffset;
}
m_outlineDecal = GetWorld()->SpawnActor<ADecalActor>(pos, rot);
m_outlineDecal->SetDecalMaterial(outlineMat);
m_outlineMat = m_outlineDecal->CreateDynamicMaterialInstance();
m_outlineMat->SetTextureParameterValue(FName("OutlineTexture"), outlineTexture);
m_outlineDecal->SetActorScale3D(m_scale);
m_outlineDecal->AddActorLocalOffset(-m_offset);
m_outlineDecal->SetLifeSpan(m_duration);
m_outlineMat->SetVectorParameterValue("TeamColor", m_color);
Super::BeginPlay();
}
void AAbilityIndicator::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
// m_outlineDecal->Destroy();
if (IsValid(m_outlineDecal))
m_outlineDecal->Destroy();
Super::EndPlay(EndPlayReason);
}
void AFillingAbilityIndicator::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
// m_fillDecal->Destroy();
if (IsValid(m_fillDecal))
m_fillDecal->Destroy();
Super::EndPlay(EndPlayReason);
}
void AFillingAbilityIndicator::BeginPlay()
{
Super::BeginPlay();
FVector pos ;
FRotator rot;
if (m_followActor)
{
pos = m_followActor->GetActorLocation();
rot = m_followActor->GetActorRotation() + m_rotationOffset;
}
else
{
pos = GetActorLocation();
rot = GetActorRotation() + m_rotationOffset;
}
m_fillDecal = GetWorld()->SpawnActor<ADecalActor>(pos, rot);
m_fillDecal->SetDecalMaterial(fillMat);
m_fillMat = m_fillDecal->CreateDynamicMaterialInstance();
m_fillMat->SetTextureParameterValue(FName("FillTexture"), fillTexture);
m_fillDecal->SetActorScale3D(m_scale);
m_fillDecal->AddActorLocalOffset(-m_offset);
m_fillDecal->SetLifeSpan(m_duration);
}
void AAbilityIndicator::CalculatePosition_Implementation()
{
if (Role != ROLE_Authority)
return;
if (IsValid(m_followActor))
{
FTransform newtrans = m_followActor->GetTransform();
SetActorTransform(newtrans);
}
}
void AAbilityIndicator::ForceDestroy()
{
if (Role != ROLE_Authority)
return;
m_lifeTime = m_duration;
m_duration += 0.1f;
}
void AAbilityIndicator::Init(float duration, FVector offset, FRotator rotationOffset, FVector scale, bool center, AActor* followActor, FLinearColor color)
{
m_duration = duration;
m_followActor = followActor;
m_offset = offset;
m_rotationOffset = rotationOffset;
m_scale = scale;
m_color = color;
m_center = center;
}
void AAbilityIndicator::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
CalculatePosition();
SetDecalLocations();
if (m_duration > 0.0f) // Only use timer if duration was set
{
m_lifeTime += DeltaTime;
if (m_lifeTime >= m_duration)
{
if (Role == ROLE_Authority)
{
Destroy();
}
}
}
}
void AAbilityIndicator::SetDecalLocations()
{
if (Role != ROLE_Authority)
return;
if (IsValid(m_followActor))
{
if (m_center)
{
m_outlineDecal->SetActorLocation(m_followActor->GetActorLocation());
}
else if (IsValid(m_followActor))
{
m_outlineDecal->SetActorLocation(m_followActor->GetActorLocation());
m_outlineDecal->AddActorLocalOffset(-m_offset);
}
}
else
{
if (m_center)
{
m_outlineDecal->SetActorLocation(GetActorLocation());
}
else
{
m_outlineDecal->SetActorLocation(GetActorLocation());
m_outlineDecal->AddActorLocalOffset(-m_offset);
}
}
}
void AFillingAbilityIndicator::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (m_duration > 0.0f) // Only use timer if duration was set
{
if (m_fillMat != nullptr)
m_fillMat->SetScalarParameterValue(FName("AlphaMultiplier"), m_lifeTime / m_duration);
if (m_lifeTime >= m_duration)
{
if (Role == ROLE_Authority)
{
}
}
}
}
void AAbilityIndicator::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_followActor, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_duration, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_scale, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_offset, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_rotationOffset, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_color, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AAbilityIndicator, m_center, COND_InitialOnly);
}
void AAbilityIndicator::SetOffset(FVector offset)
{
m_offset = offset;
}
void AAbilityIndicator::SetRotationOffset(FRotator rotationOffset)
{
m_rotationOffset = rotationOffset;
}
void AFillingAbilityIndicator::SetDecalLocations()
{
Super::SetDecalLocations();
if (IsValid(m_followActor))
{
if (m_center)
{
m_fillDecal->SetActorLocation(m_followActor->GetActorLocation());
}
else if (IsValid(m_followActor))
{
m_fillDecal->SetActorLocation(m_followActor->GetActorLocation());
m_fillDecal->AddActorLocalOffset(-m_offset);
}
}
else
{
if (m_center)
{
m_fillDecal->SetActorLocation(GetActorLocation());
}
else
{
m_fillDecal->SetActorLocation(GetActorLocation());
m_fillDecal->AddActorLocalOffset(-m_offset);
}
}
}

View File

@@ -0,0 +1,101 @@
// Project Lab - NHTV Igad
#pragma once
#include "GameFramework/Actor.h"
#include "NetworkCharacter.h"
#include "TeamData.h"
#include "DealDamageProxy.h"
#include "AbilityIndicator.generated.h"
UCLASS()
class UNREALPROJECT_API AAbilityIndicator : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AAbilityIndicator();
UFUNCTION()
void Init(float duration, FVector offset, FRotator rotationOffset, FVector scale, bool center, AActor* followActor = nullptr, FLinearColor color = FLinearColor(1,1,1,1));
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Tick(float DeltaSeconds) override;
UFUNCTION(BlueprintNativeEvent)
void CalculatePosition();
UFUNCTION(BluePrintCallable, category = "AbilityIndicators")
void ForceDestroy();
UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
UMaterial* outlineMat;
UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
UTexture2D* outlineTexture;
UPROPERTY(BlueprintReadWrite, Replicated, ReplicatedUsing = CalculatePosition, meta = (ExposeOnSpawn), category = "AbilityIndicators")
AActor* m_followActor;
void SetOffset(FVector offset);
void SetRotationOffset(FRotator rotationOffset);
UPROPERTY(EditDefaultsOnly)
UTeamData* teamData;
protected:
UPROPERTY()
UMaterialInstanceDynamic* m_outlineMat;
virtual void SetDecalLocations();
UPROPERTY()
ADecalActor* m_outlineDecal;
UPROPERTY(Replicated)
bool m_center;
UPROPERTY(Replicated)
float m_duration;
UPROPERTY(Replicated)
FLinearColor m_color;
UPROPERTY(Replicated)
FVector m_offset;
UPROPERTY(Replicated)
FRotator m_rotationOffset;
UPROPERTY(Replicated)
FVector m_scale;
UPROPERTY()
float m_lifeTime;
};
UCLASS()
class UNREALPROJECT_API AFillingAbilityIndicator : public AAbilityIndicator
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AFillingAbilityIndicator();
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Tick(float DeltaSeconds) override;
UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
UMaterial* fillMat;
UPROPERTY(EditDefaultsOnly, category = "AbilityIndicators")
UTexture2D* fillTexture;
private:
virtual void SetDecalLocations() override;
UPROPERTY()
UMaterialInstanceDynamic* m_fillMat;
UPROPERTY()
ADecalActor* m_fillDecal;
};

View File

@@ -0,0 +1,166 @@
// Project Lab - NHTV Igad
#include "UnrealProject.h"
#include "NetworkCharacter.h"
#include "Effect.h"
#include "DefaultGameInstance.h"
#include "Prefs.h"
AEffect::AEffect()
{
// 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;
//RootComponent = m_particleComponent = CreateDefaultSubobject<UParticleSystemComponent>("PSys");
m_followActor = nullptr;
m_duration = 0.0f;
deactivateParticlesBefore = 0;
bReplicates = true;
}
void AEffect::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME_CONDITION(AEffect, m_followActor, COND_InitialOnly);
DOREPLIFETIME_CONDITION(AEffect, m_duration, COND_InitialOnly);
}
void AEffect::BeginPlay()
{
m_particleSystems = GetComponentsByClass(UParticleSystemComponent::StaticClass());
m_rootParticleSystem = Cast<UParticleSystemComponent>(RootComponent);
m_rootAudio = Cast<UAudioComponent>(RootComponent);
// Bind root component finished actions
if(m_rootParticleSystem)
{
if(m_duration == 0.0f)
m_rootParticleSystem->bAutoDestroy = true;
float WarmupTimeRemember = m_rootParticleSystem->Template->WarmupTime;
m_rootParticleSystem->Template->WarmupTime = m_lifeTime;
m_rootParticleSystem->ActivateSystem();
m_rootParticleSystem->Template->WarmupTime = WarmupTimeRemember;
m_rootParticleSystem->OnSystemFinished.AddDynamic(this, &AEffect::OnRootParticleSystemFinished);
}
else if(m_rootAudio)
{
m_rootAudio->OnAudioFinished.AddDynamic(this, &AEffect::OnRootAudioFinished);
}
else
{
GWWARNING(L"Effect root is not a particles system or an audio component [" + GetName() + L"]");
}
Super::BeginPlay();
TArray<UActorComponent*> audioComponents = GetComponentsByClass(UAudioComponent::StaticClass());
float volume = Cast<UDefaultGameInstance>(GetGameInstance())->GetPrefs()->sfxVolume;
for (int32 i = 0; i < audioComponents.Num(); i++)
{
Cast<UAudioComponent>(audioComponents[i])->SetVolumeMultiplier(volume);
}
if (IsValid(m_followActor))
{
ANetworkCharacter* networkcharacter = Cast<ANetworkCharacter>(m_followActor);
if(networkcharacter)
networkcharacter->RegisterEffect(this);
}
}
void AEffect::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
if (IsValid(m_followActor))
{
ANetworkCharacter* networkcharacter = Cast<ANetworkCharacter>(m_followActor);
if (networkcharacter)
networkcharacter->UnRegisterEffect(this);
}
}
void AEffect::OnRootParticleSystemFinished(UParticleSystemComponent*)
{
if(m_duration == 0.0f) // Only auto-destroy if duration was not set
Destroy();
}
void AEffect::OnRootAudioFinished()
{
if(m_duration == 0.0f) // Only auto-destroy if duration was not set
Destroy();
}
AActor* AEffect::GetFollower() const
{
return m_followActor;
}
void AEffect::DeactivateParticles()
{
for(int32 i = 0; i < m_particleSystems.Num(); i++)
{
Cast<UParticleSystemComponent>(m_particleSystems[i])->DeactivateSystem();
}
deactivateParticlesBefore = 0.0f;
}
void AEffect::CalculatePosition_Implementation()
{
if (m_followActor)
{
SetActorLocation(m_followActor->GetActorLocation());
SetActorRotation(m_followActor->GetActorRotation());
}
}
void AEffect::BeginEffect_Implementation()
{
}
void AEffect::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
CalculatePosition();
m_lifeTime += DeltaTime;
if(m_duration > 0.0f) // Only use timer if duration was set
{
if(deactivateParticlesBefore > 0.0f)
{
if((m_lifeTime + deactivateParticlesBefore) >= m_duration)
{
DeactivateParticles();
}
}
if(m_lifeTime >= m_duration)
{
Destroy();
}
}
if (m_follow && !IsValid(m_followActor))
DeactivateParticles();
}
void AEffect::Init(float duration, AActor* followActor, bool clientSideOnly)
{
if(clientSideOnly)
bReplicates = false;
m_duration = duration;
m_followActor = followActor;
BeginEffect();
m_follow = IsValid(followActor);
}
void AEffect::End_Implementation()
{
//check(Role == ROLE_Authority);
if(deactivateParticlesBefore > 0.0f)
{
m_duration = deactivateParticlesBefore;
m_lifeTime = 0.0f;
DeactivateParticles();
check(m_duration > 0.0f);
}
else
{
Destroy();
}
}
void ATargetedEffect::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(ATargetedEffect, target);
}

View File

@@ -0,0 +1,74 @@
// Project Lab - NHTV Igad
#pragma once
#include "GameFramework/Actor.h"
#include "Effect.generated.h"
UCLASS()
class UNREALPROJECT_API AEffect : public AActor
{
GENERATED_BODY()
public:
AEffect();
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Tick( float DeltaSeconds ) override;
UFUNCTION()
void Init(float duration, AActor* followActor = nullptr, bool clientSideOnly = false);
UFUNCTION(BlueprintNativeEvent)
void BeginEffect();
// Destroys this particle system + waits for deactivateParticlesBefore seconds after deactivating particle systems
UFUNCTION(BlueprintCallable, NetMulticast, Reliable, Category="Effect")
void End();
// Event fired when end is called
UFUNCTION(BlueprintImplementableEvent)
void OnEnd();
// Function used to update the position of this effect
UFUNCTION(BlueprintNativeEvent)
void CalculatePosition();
UFUNCTION()
void OnRootParticleSystemFinished(UParticleSystemComponent* sys);
UFUNCTION()
void OnRootAudioFinished();
UFUNCTION(BlueprintCallable, Category="Effect")
AActor* GetFollower() const;
// Time before the end of the duration in which the particle system is deactivated
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category="Particles")
float deactivateParticlesBefore;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Effect", meta = (ExposeOnSpawn))
float m_lifeTime;
private:
void DeactivateParticles();
TArray<UActorComponent*> m_particleSystems;
UParticleSystemComponent* m_rootParticleSystem;
UAudioComponent* m_rootAudio;
UPROPERTY(Replicated, ReplicatedUsing = CalculatePosition)
AActor* m_followActor;
UPROPERTY(Replicated)
float m_duration;
bool m_follow;
};
UCLASS()
class ATargetedEffect : public AEffect
{
GENERATED_BODY()
public:
UPROPERTY(Replicated, BlueprintReadOnly)
FVector target;
};

View File

@@ -0,0 +1,185 @@
// Project Lab - NHTV Igad
#include "UnrealProject.h"
#include "DefaultGameInstance.h"
#include "Prefs.h"
#include "ItemBase.h"
#include "Effect.h"
#include "AbilityIndicator.h"
#include "NetworkCharacter.h"
#include "NetworkPlayer.h"
#include "EffectFunctionLibrary.h"
AEffect* UEffectFunctionLibrary::CreateEffect(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
class AActor* followObject, float startTime, float durationOverride, bool clientSideOnly)
{
UWorld* world = GEngine->GetWorldFromContextObject(worldContextObject);
if(!effectClass)
{
GWERROR(L"Can't create effect, class not set");
return nullptr;
}
if(!world)
{
GWERROR(L"Can't create effect, world not set");
return nullptr;
}
if(!world->GetAuthGameMode())
return nullptr; // Only server can spawn replicated effects
FTransform spawnTransform = FTransform::Identity;
if(followObject)
{
spawnTransform = followObject->GetTransform();
}
else
{
AActor* spawnActor = Cast<AActor>(worldContextObject);
if(spawnActor)
spawnTransform = spawnActor->GetTransform();
}
spawnTransform.SetScale3D(FVector(1.0f, 1.0f, 1.0f)); // Reset scale, only inherit parent position + rotation
AEffect* pfx = world->SpawnActorDeferred<AEffect>(effectClass, spawnTransform);
if(!pfx)
return nullptr;
pfx->m_lifeTime = startTime;
pfx->Init(durationOverride, followObject, clientSideOnly);
UGameplayStatics::FinishSpawningActor(pfx, spawnTransform);
return pfx;
}
AEffect* UEffectFunctionLibrary::CreateEffectAt(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
const FTransform& transform, float startTime, float durationOverride, bool clientSideOnly)
{
UWorld* world = GEngine->GetWorldFromContextObject(worldContextObject);
if (!effectClass)
{
GWERROR(L"Can't create effect, class not set");
return nullptr;
}
if (!world)
{
GWERROR(L"Can't create effect, world not set");
return nullptr;
}
if (!world->GetAuthGameMode())
return nullptr; // Only server can spawn replicated effects
AEffect* pfx = world->SpawnActorDeferred<AEffect>(effectClass, transform);
check(pfx);
pfx->m_lifeTime = startTime;
pfx->Init(durationOverride, nullptr, clientSideOnly);
UGameplayStatics::FinishSpawningActor(pfx, transform);
return pfx;
}
AEffect* UEffectFunctionLibrary::CreateEffectAttached(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
const FTransform& transform, USceneComponent* InParent, FName InSocketName, EAttachLocation::Type AttachLocationType, float startTime, float durationOverride, bool clientSideOnly)
{
UWorld* world = GEngine->GetWorldFromContextObject(worldContextObject);
if (!effectClass)
{
GWERROR(L"Can't create effect, class not set");
return nullptr;
}
if (!world)
{
GWERROR(L"Can't create effect, world not set");
return nullptr;
}
if (!world->GetAuthGameMode())
return nullptr; // Only server can spawn replicated effects
AEffect* pfx = world->SpawnActorDeferred<AEffect>(effectClass, transform);
check(pfx);
pfx->m_lifeTime = startTime;
pfx->Init(durationOverride, nullptr, clientSideOnly);
UGameplayStatics::FinishSpawningActor(pfx, transform);
pfx->AttachRootComponentTo(InParent, InSocketName, AttachLocationType);
return pfx;
}
AAbilityIndicator * UEffectFunctionLibrary::CreateAbilityIndicator(TSubclassOf<class AAbilityIndicator> AAbilityIndicatorClass, ANetworkCharacter* spawner, AActor* followObject, FVector scale, float durationOverride, bool center)
{
if (!spawner)
{
FWERROR(L"Can't create abilityIndicator, spawner not set");
return nullptr;
}
//transforming from cm to m duo to 4.11
FVector newscale = scale * 0.01f;
UWorld* world = spawner->GetWorld();
FTransform spawnTransform = spawner->GetTransform();
AAbilityIndicator* pai = world->SpawnActorDeferred<AAbilityIndicator>(AAbilityIndicatorClass, spawnTransform);
check(pai);
if (center)
pai->Init(durationOverride, FVector(0, 0.0, 0), FRotator(0, 90, 0), newscale * 0.5f, center, followObject, pai->teamData->GetTeamColor(spawner->GetTeam()));
else
pai->Init(durationOverride, FVector(0, scale.Y, 0) + FVector(0,100,0), FRotator(0, 90, 0), newscale * 0.5f, center, followObject, pai->teamData->GetTeamColor(spawner->GetTeam()));
UGameplayStatics::FinishSpawningActor(pai, spawnTransform);
return pai;
}
AAbilityIndicator * UEffectFunctionLibrary::CreateAbilityIndicatorAt(TSubclassOf<class AAbilityIndicator> AAbilityIndicatorClass, ANetworkCharacter * spawner, const FTransform& transform, FVector scale, float durationOverride, bool center)
{
if (!spawner)
{
FWERROR(L"Can't create abilityIndicator, spawner not set");
return nullptr;
}
FVector newscale = scale * 0.01f;
UWorld* world = spawner->GetWorld();
FTransform spawnTransform = transform;
AAbilityIndicator* pai = world->SpawnActorDeferred<AAbilityIndicator>(AAbilityIndicatorClass, spawnTransform);
check(pai);
if (center)
pai->Init(durationOverride, FVector(0, 0.0, 0), FRotator(0, 90, 0), newscale * 0.5f, center, nullptr, pai->teamData->GetTeamColor(spawner->GetTeam()));
else
pai->Init(durationOverride, FVector(0, scale.Y * 0.5f, 0), FRotator(0, 90, 0), newscale * 0.5f, center, nullptr, pai->teamData->GetTeamColor(spawner->GetTeam()));
UGameplayStatics::FinishSpawningActor(pai, spawnTransform);
return pai;
}
void UEffectFunctionLibrary::PlaySoundEffect2D(UObject* worldContextObject, USoundBase* sound)
{
UWorld* world = GEngine->GetWorldFromContextObject(worldContextObject);
float volume = Cast<UDefaultGameInstance>(world->GetGameInstance())->GetPrefs()->sfxVolume;
UGameplayStatics::PlaySound2D(worldContextObject, sound, volume);
}
void UEffectFunctionLibrary::DuplicateAppearance(ACharacterBase* from, ACharacterBase* to)
{
if (from == nullptr)
{
FWARNING("from == nullptr");
return;
}
USkeletalMeshComponent* fromMesh = from->GetMesh();
if (fromMesh == nullptr)
{
FWARNING("from->mesh == nullptr");
return;
}
if (to == nullptr)
{
FWARNING("to == nullptr");
return;
}
// Copy equiped items
TArray<TSubclassOf<AItemBase>> itemsToSpawn;
for(auto i : from->GetEquipedItems())
{
itemsToSpawn.Add(i->GetClass());
}
to->EquipItems(itemsToSpawn);
// Copy CUstomization
to->SetCustomizations(from->GetCharacterCustomization());
to->playerName = from->playerName;
return;
}

View File

@@ -0,0 +1,42 @@
// Project Lab - NHTV Igad
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "EffectFunctionLibrary.generated.h"
/**
*
*/
UCLASS()
class UNREALPROJECT_API UEffectFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Effect", meta = (WorldContext="worldContextObject"))
static class AEffect* CreateEffect(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
class AActor* followObject = nullptr, float startTime = 0.0f, float durationOverride = 0.0f, bool clientSideOnly = false);
UFUNCTION(BlueprintCallable, Category = "Effect", meta = (WorldContext = "worldContextObject"))
static class AEffect* CreateEffectAt(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
const FTransform& transform, float startTime = 0.0f, float durationOverride = 0.0f, bool clientSideOnly = false);
UFUNCTION(BlueprintCallable, Category = "Effect", meta = (WorldContext = "worldContextObject"))
static class AEffect* CreateEffectAttached(UObject* worldContextObject, TSubclassOf<class AEffect> effectClass,
const FTransform& transform, USceneComponent* InParent, FName InSocketName, EAttachLocation::Type AttachLocationType, float startTime = 0.0f, float durationOverride = 0.0f, bool clientSideOnly = false);
UFUNCTION(BlueprintCallable, Category = "Effect")
static class AAbilityIndicator* CreateAbilityIndicator(TSubclassOf<class AAbilityIndicator> AAbilityIndicatorClass,
class ANetworkCharacter* spawner, class AActor* followObject, FVector scale, float durationOverride = 0.0f, bool center = true);
UFUNCTION(BlueprintCallable, Category = "Effect")
static class AAbilityIndicator* CreateAbilityIndicatorAt(TSubclassOf<class AAbilityIndicator> AAbilityIndicatorClass, ANetworkCharacter * spawner, const FTransform& transform, FVector scale, float durationOverride, bool center);
UFUNCTION(BlueprintCallable, Category = "Effect", meta = (WorldContext="worldContextObject"))
static void PlaySoundEffect2D(UObject* worldContextObject, USoundBase* sound);
//from is the character who's skeleton is cloned, to is who gets the cloned skeleton
UFUNCTION(BlueprintCallable, Category = "Effect")
static void DuplicateAppearance(class ACharacterBase* from, class ACharacterBase* to);
};

View File

@@ -0,0 +1,20 @@
// Project Lab - NHTV Igad
#include "UnrealProject.h"
#include "TeamData.h"
FLinearColor UTeamData::GetTeamColor(int32 team)
{
for (FTeamDataStruct it : teamColors)
{
if (it.team == team)
{
return it.color;
}
}
return FLinearColor(1, 1, 1, 1);
}

View File

@@ -0,0 +1,36 @@
// Project Lab - NHTV Igad
#pragma once
#include "Engine/DataAsset.h"
#include "TeamData.generated.h"
/**
*
*/
USTRUCT()
struct UNREALPROJECT_API FTeamDataStruct
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly)
int32 team;
UPROPERTY(EditDefaultsOnly)
FLinearColor color;
};
UCLASS(BlueprintType)
class UNREALPROJECT_API UTeamData : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly)
TArray<FTeamDataStruct> teamColors;
UFUNCTION(BlueprintCallable, Category="Team Data")
FLinearColor GetTeamColor(int32 team);
};