From f8a86846b21b7f143a9235a974ea0ceb555423b0 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Thu, 11 Jan 2024 03:30:17 +0000 Subject: [PATCH] Implemented AMyVICharacter --- .../Source/EndlessVendetta/MyVICharacter.cpp | 49 +++++++++++++++++++ .../Source/EndlessVendetta/MyVICharacter.h | 35 +++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 EndlessVendetta/Source/EndlessVendetta/MyVICharacter.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/MyVICharacter.h diff --git a/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.cpp new file mode 100644 index 00000000..2f688de5 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.cpp @@ -0,0 +1,49 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MyVICharacter.h" +#include "GAS/VIAbilitySystemComponent.h" +#include "Pawn/VIPawnVaultComponent.h" +#include "MotionWarpingComponent.h" + + +AMyVICharacter::AMyVICharacter(const FObjectInitializer& OI) + : Super(OI) +{ + VaultComponent = CreateDefaultSubobject(TEXT("PawnVaulting")); + MotionWarpingComponent = CreateDefaultSubobject(TEXT("MotionWarping")); +} + +void AMyVICharacter::BeginPlay() +{ + Super::BeginPlay(); + + // Init simulated proxy + if (AbilitySystem && GetLocalRole() == ROLE_SimulatedProxy) + { + // Will never have a valid controller + AbilitySystem->InitAbilityActorInfo(this, this); + } +} + +void AMyVICharacter::PossessedBy(AController* NewController) +{ + Super::PossessedBy(NewController); + + // Init authority/standalone + if (AbilitySystem) + { + AbilitySystem->InitAbilityActorInfo(this, this); + } +} + +void AMyVICharacter::OnRep_Controller() +{ + Super::OnRep_Controller(); + + // Init local client + if (AbilitySystem) + { + AbilitySystem->InitAbilityActorInfo(this, this); + } +} \ No newline at end of file diff --git a/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.h b/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.h new file mode 100644 index 00000000..11dd1a29 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/MyVICharacter.h @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "MyVICharacterAbilityBase.h" +#include "MyVICharacter.generated.h" + +/** + * + */ +UCLASS() +class ENDLESSVENDETTA_API AMyVICharacter : public AMyVICharacterAbilityBase +{ + GENERATED_BODY() + +public: + UPROPERTY(EditDefaultsOnly, Category = Vault) + FVIAnimSet VaultAnimSet; + + UPROPERTY(EditDefaultsOnly, Category = Vault) + FVITraceSettings VaultTraceSettings; + + AMyVICharacter(const FObjectInitializer& OI); + + virtual void BeginPlay() override; + virtual void PossessedBy(AController* NewController) override; + virtual void OnRep_Controller() override; + + virtual UVIPawnVaultComponent* GetPawnVaultComponent_Implementation() const override { return VaultComponent; } + virtual UMotionWarpingComponent* GetMotionWarpingComponent_Implementation() const override { return MotionWarpingComponent; } + + virtual FVIAnimSet GetVaultAnimSet_Implementation() const override { return VaultAnimSet; } + virtual FVITraceSettings GetVaultTraceSettings_Implementation() const override { return VaultTraceSettings; } +};