From 2c7bf0fb53ab8f737dd24d6a349a1981e5b38b24 Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Fri, 11 Mar 2022 20:45:14 -0500 Subject: [PATCH] Create new character class --- .../Animations/NewProtag_AnimBP.uasset | 3 + .../Protagonist/BP_NewProtag.uasset | 3 + .../Protagonist/BP_Protagonist.uasset | 4 +- .../Core/GameModes/BP_TestGameMode.uasset | 4 +- SwordNGun/Content/Maps/MovementTest.umap | 2 +- .../Private/Characters/SNGCharacterBase.cpp | Bin 6587 -> 6280 bytes .../SNGCharacterBase_DEPRECATED.cpp | 265 ++++++++++++++++++ .../SNGCharacterMovementComponent.cpp | 12 +- .../Weapons/SNGInstantRangedWeapon.cpp | 4 +- .../Private/Weapons/SNGMeleeWeaponBase.cpp | 4 +- .../Public/Characters/SNGCharacterBase.h | Bin 5327 -> 2174 bytes .../Characters/SNGCharacterBase_DEPRECATED.h | 174 ++++++++++++ .../Public/Characters/SNGEnemyBase.h | 4 +- .../Public/Characters/SNGProtagonist.h | 4 +- .../SNGCharacterMovementComponent.h | 6 +- 15 files changed, 466 insertions(+), 23 deletions(-) create mode 100644 SwordNGun/Content/Characters/Protagonist/Animations/NewProtag_AnimBP.uasset create mode 100644 SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset create mode 100644 SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase_DEPRECATED.cpp create mode 100644 SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase_DEPRECATED.h diff --git a/SwordNGun/Content/Characters/Protagonist/Animations/NewProtag_AnimBP.uasset b/SwordNGun/Content/Characters/Protagonist/Animations/NewProtag_AnimBP.uasset new file mode 100644 index 0000000..245c0b8 --- /dev/null +++ b/SwordNGun/Content/Characters/Protagonist/Animations/NewProtag_AnimBP.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2afc51cc43713c9c0b199224b19b02a8cb70745ec2bc4318383a0d4681912d58 +size 798845 diff --git a/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset new file mode 100644 index 0000000..495786a --- /dev/null +++ b/SwordNGun/Content/Characters/Protagonist/BP_NewProtag.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9243affa8259717c04da6bdd8ff7270bf0104e828d739fa31016e903a45fe8b4 +size 118953 diff --git a/SwordNGun/Content/Characters/Protagonist/BP_Protagonist.uasset b/SwordNGun/Content/Characters/Protagonist/BP_Protagonist.uasset index 1542da7..a1c581c 100644 --- a/SwordNGun/Content/Characters/Protagonist/BP_Protagonist.uasset +++ b/SwordNGun/Content/Characters/Protagonist/BP_Protagonist.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0bd518d9e5ac0d902498ac86db052d5dbe04cc86a511297d51649b621efa9498 -size 211647 +oid sha256:2717da35d9ce4517ee1e4ca8d66335c3546a53be67ea20382123c744e7885e63 +size 209596 diff --git a/SwordNGun/Content/Core/GameModes/BP_TestGameMode.uasset b/SwordNGun/Content/Core/GameModes/BP_TestGameMode.uasset index 4f91467..7652b31 100644 --- a/SwordNGun/Content/Core/GameModes/BP_TestGameMode.uasset +++ b/SwordNGun/Content/Core/GameModes/BP_TestGameMode.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7df2e2c7ef841e470ac63273c83a37235caee2d89d1cd1c35cb82f21dbe5c577 -size 18685 +oid sha256:f8271a597c08b1f383e260f699ac637e759a2edfb0802a06874c5ab1140fe154 +size 18459 diff --git a/SwordNGun/Content/Maps/MovementTest.umap b/SwordNGun/Content/Maps/MovementTest.umap index 6cd4f17..a7a39be 100644 --- a/SwordNGun/Content/Maps/MovementTest.umap +++ b/SwordNGun/Content/Maps/MovementTest.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ec67582a7d62404f5176696a932bab2ce08d14c18fbf1aea9fd0db4249dec2f +oid sha256:956fdf8e2e0fa6920cc4b70fb88a4166cab3d7bcb0e513dcedac5ba13497cd9b size 949560 diff --git a/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp b/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase.cpp index 384ab61cccc8ebe62cf78e3cb320e1b505ee6fc3..a35452fce517409fa466f919de53ecf580613f2e 100644 GIT binary patch literal 6280 zcmeI0+in|G6o%KWk$8tukcxwd1HGd_k&}|Nv}vOp3S6PYhs4B*Eqjs>DjujW34H(F zv$JPBjy<-+9kT4qVeNJN*D3$}y=j}4*uITyV82_(T9$HuXt&&ttj+ZkzPom9SNz@P z>CoceEdQ{?xwW`!!du;c>%TQSUn*9jH>Cd}^QEe?M~+E$hR#&56X;;C*f< za6WN5bhsL$+o8QhdimWJbYo67IJGv1?}=SPDbAa4ig&W+5_<+{+u@t$xJ}n^l3p5$ z;}Bi0v8Kb_Bu&(?I?so!-h=xMQe=d8){rS(B^Fg}J}x z^w{Z^!Y_ZfhuoA%y@BG?$sU2C=$U{GkH$mvO5v0^Y;-v*-wKyETnjTD-s((qEw zvkFvoFeem@os=DWhn685Uh%xg^PZF4vp$uXR3()Cc#QSPf*T z;&|&4EIfCpNr=FtY`q;o+j5@ob9Dr5%P!D$ojX+;`SXtJu0xe1Hn>adS598@S7%j= zQtn3CRggH~RM)+elpgvj1AK-hS**I;D;LD21$WWu%w5L6&EG5g9R3M^JA70#g_lMa zd(~F)R&Be($EvX68Ek0~P1TSq`!Ta8yh-ePc%{$^@!vXr@?{P0&CgYTdYjW7xTpNi z!;(kPe9pqk5!(L3Z=LE}MVmE;1aCt%{Wt7+h7#pX6AM!85K2PztJ?vd9Pqqc2iG%y zRhM;2{-~quBjuK8h^K0-5Ycy%Bwuwv&!@#^5m~A#=SUMaQqU@ykIQr4ahAUxm#=)@ z=QEwF$EWbDD5>X`W8+UQip<$OCowsjx`@Wvv{i6eB?BTNy^jLkia65@F)E=gj}LW& zzC&urrbReSq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zbVm;Our{Fx6^7SQ64=kdgAA%?_I~Cs?3^9I(?qB1^6jvG3y>p5uplb>FVq|>zJT_$ zGT{sdyoEl$XNNiK9x!TEnV%W~I1KNm339`3k>11Qq~eJR;C|J8kgJrw3%?r)3#Us0 zmWrnkfYk$z0^2{yB6bT*amo`9E=(!KxbZ`p#%wCh(n_o0@47*UQ%_+ZMY4X^$@wWR z(}jd<>Dvf4H1+R%yQ@u&($!;~Y@ig^@!ak`;y}$%Q#;QD|_ zUqdq3?c)6pk(#S?7nne2M-=LcR6!qqC)?H;>sM|AaYpA)+U zizhvMmdg#QszlvSx4T$ZxjO3v6I6bBf$3i@KSFbBc~nH?wo>f;qC6rnoPbitNV*)K z1xHas)%sam;-*po3IRMrSO@7^CCTG>r?R7W=uRv}^emtsEg$}lxZ(`CU8=XFX&QD} zCH892QxHUt9JMG`b^17CBfjO2V#sqTG7Y3yFjLTeZR`03S84h*P=y3-GFB;ouB`%^M9Hd37}Rxel^UN5Pze>)(P7SNqttAb z*+H|_`9Gx1>K3s2W^LNXv!kUp>lJQWb1QA`igl2`Uvbyhy_8nMknYel8AO=_rKs*` z8dide8!u#f>`mna&*3O})XxI=3IYU0bL_&sz`rm0x5Y2dbe5pl)ia_^(rk&>F>Uh9 zOqu3`hGM!pOPF74Y^@AW;B9sMV7w-*=Qp_aenOP_Q3WMGn(5qkeQaoJm~q`r&6C_ST`Go9UDymEGqTHcFw5Lx|kU!?3W{ z(67;2l}3z>8uTye0cfa(D92%FxEx5$SVs?gH1@P(YTZ-;*_39z3mL74M-xDV9^e zdX#Sqxe9iuzzH@~T%_Mt(cYV8ABbGTK<1(&Vgf&c|IzNyER{|dzic$4sY;y=8+utCQF4f7dzCEeEP=O1;_x}$kcZ$mZ diff --git a/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase_DEPRECATED.cpp b/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase_DEPRECATED.cpp new file mode 100644 index 0000000..a785209 --- /dev/null +++ b/SwordNGun/Source/SwordNGun/Private/Characters/SNGCharacterBase_DEPRECATED.cpp @@ -0,0 +1,265 @@ +// Project Sword & Gun Copyright © 2021 Kevin Poretti + + +#include "Characters/SNGCharacterBase_DEPRECATED.h" + +#include "Components/CapsuleComponent.h" +#include "GameFramework/PawnMovementComponent.h" +#include "Kismet/KismetMathLibrary.h" +#include "SwordNGun/SwordNGun.h" + +// Sets default values +ASNGCharacterBase_DEPRECATED::ASNGCharacterBase_DEPRECATED(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer.SetDefaultSubobjectClass(ACharacter::CharacterMovementComponentName)) +{ + // By default calls Tick() every frame. + PrimaryActorTick.bCanEverTick = true; + + StateMachineComponent = CreateDefaultSubobject(TEXT("StateMachineComponent")); + HealthComponent = CreateDefaultSubobject(TEXT("HealthComponent")); + + GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_RANGED_WEAPON, ECR_Ignore); + GetCapsuleComponent()->SetCollisionResponseToChannel(COLLISION_MELEE_WEAPON, ECR_Ignore); + + EnableAllActions(); + + AController* MyController = GetController(); + if(MyController) + { + GetController()->SetIgnoreMoveInput(false); + } +} + +void ASNGCharacterBase_DEPRECATED::SetupRotateTowardsTarget(FRotator TargetRotation, float DegreesPerSecond, float MaxRotation) +{ + RotateTimeElapsed = 0.0f; + InitialRot = GetActorRotation(); + this->TargetRot = TargetRotation; + DegPerSecond = DegreesPerSecond; + this->MaxRot = MaxRotation; + + RotateTime = FMath::Min(FMath::Abs(TargetRotation.Yaw - InitialRot.Yaw), MaxRotation) / DegreesPerSecond; +} + +void ASNGCharacterBase_DEPRECATED::RotateTowardsTarget(float DeltaTime) +{ + if(RotateTimeElapsed < RotateTime) + { + SetActorRotation(UKismetMathLibrary::RInterpTo_Constant(GetActorRotation(), TargetRot, + DeltaTime, DegPerSecond)); + + RotateTimeElapsed += DeltaTime; + } +} + +void ASNGCharacterBase_DEPRECATED::SetIgnoreMovementInput(bool IsIgnored) +{ + AController* MyController = GetController(); + if(MyController) + { + GetController()->SetIgnoreMoveInput(IsIgnored); + } +} + +void ASNGCharacterBase_DEPRECATED::DisableAllActions() +{ + bCanMove = false; + bCanJump = false; + bCanDodge = false; + bCanAttack = false; +} + +void ASNGCharacterBase_DEPRECATED::EnableAllActions() +{ + bCanMove = true; + bCanJump = true; + bCanDodge = true; + bCanAttack = true; +} + +void ASNGCharacterBase_DEPRECATED::SetCanMove(bool CanMove) +{ + bCanMove = CanMove; +} + +bool ASNGCharacterBase_DEPRECATED::CanMove() +{ + return bCanMove; +} + +void ASNGCharacterBase_DEPRECATED::SetCanCharacterJump(bool CanJump) +{ + bCanJump = CanJump; +} + +bool ASNGCharacterBase_DEPRECATED::CanCharacterJump() +{ + return bCanJump; +} + +void ASNGCharacterBase_DEPRECATED::SetCanAttack(bool CanAttack) +{ + bCanAttack = CanAttack; +} + +bool ASNGCharacterBase_DEPRECATED::CanAttack() +{ + return bCanAttack; +} + +void ASNGCharacterBase_DEPRECATED::SetCanDodge(bool CanDodge) +{ + bCanDodge = CanDodge; +} + +bool ASNGCharacterBase_DEPRECATED::CanDodge() +{ + return bCanDodge; +} + +void ASNGCharacterBase_DEPRECATED::ApplyHitStop(float HitStopTime, float HitSlowTime) +{ + CurrHitStopTime = HitStopTime; + CurrHitSlowTime = HitSlowTime; + bIsInHitStop = true; +} + +void ASNGCharacterBase_DEPRECATED::PushEvent_Implementation(FSNGEvent Event) +{ + if(StateMachineComponent) + { + StateMachineComponent->PushEvent(Event); + } +} + +ASNGWeaponBase* ASNGCharacterBase_DEPRECATED::GetCurrentWeapon_Implementation() +{ + return nullptr; +} + +void ASNGCharacterBase_DEPRECATED::ReceiveHit(FSNGHitData const& HitData, AController* EventInstigator, AActor* DamageCauser) +{ + AActor* Causer = EventInstigator->GetPawn(); + + if(HitData.HitstopApplicationType == ESNGHitstopApplicationType::Both || + HitData.HitstopApplicationType == ESNGHitstopApplicationType::ReceiverOnly) + { + ApplyHitStop(HitData.StopTime, HitData.SlowTime); + } + + FVector AdjustedLaunchDir; + switch (HitData.LaunchDirectionType) + { + case ESNGLaunchDirectionType::UseCauserRotation: + { + FRotator CauserRotationYaw(0.0f, Causer->GetActorRotation().Yaw, 0.0f); + AdjustedLaunchDir = CauserRotationYaw.RotateVector(HitData.LaunchDirection); + } + break; + case ESNGLaunchDirectionType::UseLookAtRotation: + { + FRotator LookAtRotation = UKismetMathLibrary::FindLookAtRotation(Causer->GetActorLocation(), GetActorLocation()); + FRotator LookAtRotationYaw(0.0f, LookAtRotation.Yaw, 0.0f); + AdjustedLaunchDir = LookAtRotationYaw.RotateVector(HitData.LaunchDirection); + } + break; + default: + { + AdjustedLaunchDir = HitData.LaunchDirection; + } + break; + } + + switch (HitData.LaunchType) + { + case ESNGLaunchType::OnlyInAir: + { + bool IsInAir = GetMovementComponent()->IsFalling(); + if(IsInAir) + { + AdjustedLaunchDir *= HitData.LaunchForce; + LaunchCharacter(AdjustedLaunchDir, true, true); + } + else + { + AdjustedLaunchDir = FVector(AdjustedLaunchDir.X, AdjustedLaunchDir.Y, 0.0f); + LaunchCharacter(AdjustedLaunchDir, true, true); + } + } + break; + case ESNGLaunchType::Always: + { + AdjustedLaunchDir *= HitData.LaunchForce; + LaunchCharacter(AdjustedLaunchDir, true, true); + } + break; + default: + { + + } + break; + } +} + +float ASNGCharacterBase_DEPRECATED::TakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, + AActor* DamageCauser) +{ + Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser); + + if(HealthComponent) + { + HealthComponent->SubtractHealth(Damage); + } + + if (DamageEvent.IsOfType(FSNGDamageEvent::ClassID)) + { + // point damage event, pass off to helper function + FSNGDamageEvent* const MyDamageEvent = (FSNGDamageEvent*) &DamageEvent; + ReceiveHit(MyDamageEvent->HitData, EventInstigator, DamageCauser); + + FSNGEvent Event; + Event.EventType = ESNGEventType::Damage; + Event.DamageData.HitData = MyDamageEvent->HitData; + Event.DamageData.EventInstigator = EventInstigator; + Event.DamageData.DamageCauser = DamageCauser; + Event.DamageData.SurfaceType = MyDamageEvent->SurfaceType; + Event.DamageData.ImpactPoint = MyDamageEvent->ImpactPoint; + PushEvent(Event); + } + + return Damage; +} + +void ASNGCharacterBase_DEPRECATED::Tick(float DeltaSeconds) +{ + Super::Tick(DeltaSeconds); + + RotateTowardsTarget(DeltaSeconds); + + if(bIsInHitStop) + { + CurrHitStopTime = FMath::Clamp(CurrHitStopTime - GetWorld()->GetDeltaSeconds(), 0.0f, CurrHitStopTime); + if(CurrHitStopTime > 0.0f) + { + CustomTimeDilation = 0.0f; + } + else + { + CustomTimeDilation = 0.01; + CurrHitSlowTime = FMath::Clamp(CurrHitSlowTime - GetWorld()->GetDeltaSeconds(), 0.0f, CurrHitSlowTime); + if(CurrHitSlowTime == 0.0f) + { + CustomTimeDilation = 1.0f; + bIsInHitStop = false; + } + } + } +} + +void ASNGCharacterBase_DEPRECATED::PostInitializeComponents() +{ + Super::PostInitializeComponents(); + + SNGCharacterMovementComponent = Cast(Super::GetMovementComponent()); +} + diff --git a/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp b/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp index 5ab7d50..b45f919 100644 --- a/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp +++ b/SwordNGun/Source/SwordNGun/Private/Components/SNGCharacterMovementComponent.cpp @@ -5,7 +5,7 @@ USNGCharacterMovementComponent::USNGCharacterMovementComponent() { - // Set defaults dealign with grounded movement + // Set defaults dealing with grounded movement DefaultGravityScale = 1.0f; DefaultMaxWalkSpeed = 475.0f; FiringMaxWalkSpeed = 300.0f; @@ -13,7 +13,7 @@ USNGCharacterMovementComponent::USNGCharacterMovementComponent() SprintingMaxWalkSpeed = 600.0f; // Set defaults dealing with jumping and being airborne - JumpForce = 1000.0f; + DefaultJumpForce = 1000.0f; DefaultAirFriction = 150.0f; DefaultAirControl = 0.35; @@ -36,23 +36,28 @@ void USNGCharacterMovementComponent::RestoreMovementDefaults() MaxWalkSpeed = DefaultMaxWalkSpeed; BrakingDecelerationFalling = DefaultAirFriction; AirControl = DefaultAirControl; + JumpZVelocity = DefaultJumpForce; } void USNGCharacterMovementComponent::StartJump() { + /* JumpTimer = MaxJumpTime; Velocity = FVector(Velocity.X * LateralVelocityDampening, Velocity.Y * LateralVelocityDampening, 0.0f); + */ } void USNGCharacterMovementComponent::AddJumpForce() { + /* if(JumpTimer > 0.0f) { Velocity = FVector(Velocity.X, Velocity.Y, Velocity.Z + (JumpForce * GetWorld()->DeltaTimeSeconds)); JumpTimer = FMath::Max(JumpTimer - GetWorld()->DeltaTimeSeconds, 0.0f); } + */ } void USNGCharacterMovementComponent::BeginPlay() @@ -61,9 +66,6 @@ void USNGCharacterMovementComponent::BeginPlay() // set character movement parameters to defaults RestoreMovementDefaults(); - - // Reset timers - JumpTimer = 0.0f; } void USNGCharacterMovementComponent::TickComponent(float DeltaTime, ELevelTick Tick, diff --git a/SwordNGun/Source/SwordNGun/Private/Weapons/SNGInstantRangedWeapon.cpp b/SwordNGun/Source/SwordNGun/Private/Weapons/SNGInstantRangedWeapon.cpp index 10b593f..fc56116 100644 --- a/SwordNGun/Source/SwordNGun/Private/Weapons/SNGInstantRangedWeapon.cpp +++ b/SwordNGun/Source/SwordNGun/Private/Weapons/SNGInstantRangedWeapon.cpp @@ -4,7 +4,7 @@ #include "Weapons/SNGInstantRangedWeapon.h" #include "DrawDebugHelpers.h" -#include "Characters/SNGCharacterBase.h" +#include "Characters/SNGCharacterBase_DEPRECATED.h" #include "Kismet/GameplayStatics.h" #include "Particles/ParticleSystemComponent.h" #include "PhysicalMaterials/PhysicalMaterial.h" @@ -107,7 +107,7 @@ void ASNGInstantRangedWeapon::DoLineTrace(FRotator SpreadOffset) if(HitData.HitstopApplicationType == ESNGHitstopApplicationType::Both || HitData.HitstopApplicationType == ESNGHitstopApplicationType::CauserOnly) { - ASNGCharacterBase* OwnerAsChar = Cast(GetOwner()); + ASNGCharacterBase_DEPRECATED* OwnerAsChar = Cast(GetOwner()); OwnerAsChar->ApplyHitStop(HitData.StopTime, HitData.SlowTime); } diff --git a/SwordNGun/Source/SwordNGun/Private/Weapons/SNGMeleeWeaponBase.cpp b/SwordNGun/Source/SwordNGun/Private/Weapons/SNGMeleeWeaponBase.cpp index 2d577fd..6a91ca6 100644 --- a/SwordNGun/Source/SwordNGun/Private/Weapons/SNGMeleeWeaponBase.cpp +++ b/SwordNGun/Source/SwordNGun/Private/Weapons/SNGMeleeWeaponBase.cpp @@ -4,7 +4,7 @@ #include "Weapons/SNGMeleeWeaponBase.h" -#include "Characters/SNGCharacterBase.h" +#include "Characters/SNGCharacterBase_DEPRECATED.h" #include "Kismet/KismetSystemLibrary.h" #include "SwordNGun/SwordNGun.h" @@ -61,7 +61,7 @@ void ASNGMeleeWeaponBase::DoSphereCast(FSNGHitData const& HitData, bool Override if(HitData.HitstopApplicationType == ESNGHitstopApplicationType::Both || HitData.HitstopApplicationType == ESNGHitstopApplicationType::CauserOnly) { - ASNGCharacterBase* OwnerAsChar = Cast(GetOwner()); + ASNGCharacterBase_DEPRECATED* OwnerAsChar = Cast(GetOwner()); OwnerAsChar->ApplyHitStop(HitData.StopTime, HitData.SlowTime); } diff --git a/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h b/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase.h index b50db15d4de9b1aaeb601866a3142588c641e703..7f30421e8ccbffe49aad79279a101ef6363a4954 100644 GIT binary patch literal 2174 zcmd6oU2hUm5QgU#6aT}eCQ6NI)k};Q1=^<3D&eEXD??$SYXKWrAZYwS{z>(D=PU@_ z2Dmh2*|X=&yfg27oj<>i?bsr#+1S3>SBtG!&>DHnkD&3cGi<;3ToW z-MH*8_Fvmeo>#2ifidG$(ly73kxJQlY>)hT0>aqZ=nwgikQre$UOSg|#|GH!vLD%j z+a0sMbmYV}2X=%92N`Bw=N$AQI%jT8tH9|N#uYT%zA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qBmvK7G%dMZ{}?77{? zHuPP*4pQB6G`+_*ET*WC5vD~#lyv1yT@orF^6EjKfxlIBV% zBGLJ1&Np}q)s#>>JLTJbVN(}{Qw)(3pU%0sqyIf-m@mTDR-7H)(#uXsqm>Y-Ti}Yo zkg7C~nNgZn=^deH!CR@zGJ1L*-sPdp*#r7LIb1)ur2?We`W`UwV_#}qAGpqCx~YEz z1E}w5%_BUbE{^susRhd1X0E7toHh{iS!*^+MGhBod)kE>d&HD@Kh;sAc1%Z9p_rz} zQEib{KAbOzEMg5=;^E9anz;kh9Jon(V*9ZhQ4ua;t%tEjOed&kNdAk8`Fr+zvGqBw zQ3Us?+r1NdC=AQP`GAd<;PN*-iEvIW=S$Fgz9z^e+{)1&a5c`+90Wr(*B2~FF)G?( z4Q0m_osu`zS*lA){VPwo{R$u-chthDT$F{npz!;&ufk%frKNc%KX(ziI`tLIS*9ZY x|Mu#mk8&+InsC=0l({*lm*HOc`0z|`_N&8DdnVFSeG978Cx%*8l+Uk&zX48DVWj{7 diff --git a/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase_DEPRECATED.h b/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase_DEPRECATED.h new file mode 100644 index 0000000..0adcaf6 --- /dev/null +++ b/SwordNGun/Source/SwordNGun/Public/Characters/SNGCharacterBase_DEPRECATED.h @@ -0,0 +1,174 @@ +// Project Sword & Gun Copyright © 2021 Kevin Poretti + +#pragma once + +#include "CoreMinimal.h" +#include "Components/SNGCharacterMovementComponent.h" + +#include "Components/SNGHealthComponent.h" +#include "Components/SNGStateMachineComponent.h" +#include "GameFramework/Character.h" +#include "Interfaces/SNGEventProcessorInterface.h" +#include "Interfaces/SNGWeaponUserInterface.h" + +#include "SNGCharacterBase_DEPRECATED.generated.h" + +UCLASS() +class SWORDNGUN_API ASNGCharacterBase_DEPRECATED : public ACharacter, public ISNGEventProcessorInterface, public ISNGWeaponUserInterface +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + ASNGCharacterBase_DEPRECATED(const FObjectInitializer& ObjectInitializer); + + /********************************************************************* + * Flags + ********************************************************************/ + + UFUNCTION(BlueprintCallable) + void DisableAllActions(); + + UFUNCTION(BlueprintCallable) + void EnableAllActions(); + + // NOTE(kevin): should be a blueprint setter but I could not get that working for the life of me + UFUNCTION(BlueprintCallable) + void SetCanMove(bool CanMove); + + UFUNCTION(BlueprintGetter) + bool CanMove(); + + // NOTE(kevin): should be a blueprint setter but I could not get that working for the life of me + // should also probably be a protagonist/player character specific thing + UFUNCTION(BlueprintCallable) + void SetCanCharacterJump(bool CanJump); + + UFUNCTION(BlueprintGetter) + bool CanCharacterJump(); + + // NOTE(kevin): should be a blueprint setter but I could not get that working for the life of me + UFUNCTION(BlueprintCallable) + void SetCanAttack(bool CanAttack); + + UFUNCTION(BlueprintGetter) + bool CanAttack(); + + // NOTE(kevin): should be a blueprint setter but I could not get that working for the life of me + // should also probably be a protagonist/player character specific thing + UFUNCTION(BlueprintCallable) + void SetCanDodge(bool CanDodge); + + UFUNCTION(BlueprintGetter) + bool CanDodge(); + +protected: + UPROPERTY(BlueprintReadOnly) + bool bCanMove; + + UPROPERTY(BlueprintReadOnly) + bool bCanJump; + + UPROPERTY(BlueprintReadOnly) + bool bCanAttack; + + UPROPERTY(BlueprintReadOnly) + bool bCanDodge; + + /********************************************************************* + * Movement + ********************************************************************/ + +public: + + UFUNCTION(BlueprintCallable, Category="Movement") + void SetIgnoreMovementInput(bool IsIgnored); + + UFUNCTION(BlueprintCallable, Category="Movement") + FORCEINLINE class USNGCharacterMovementComponent* GetSNGCharacterMovementComponent() const + { + return SNGCharacterMovementComponent; + } + +protected: + USNGCharacterMovementComponent* SNGCharacterMovementComponent; + +public: + /********************************************************************* + * Event processing interface + ********************************************************************/ + // event processing + UFUNCTION(BlueprintCallable, BlueprintNativeEvent) + void PushEvent(FSNGEvent Event); + + /** + * The state machine will be handling most if not all of the states + * we simply wrap the state machine's push event implementation since most + * characters that will want to push events to another character will have a reference + * to the character itself rather than the state machine component + */ + virtual void PushEvent_Implementation(FSNGEvent Event); + + + /********************************************************************* + * Weapons + ********************************************************************/ + UFUNCTION(BlueprintCallable, BlueprintNativeEvent) + ASNGWeaponBase* GetCurrentWeapon(); + + virtual ASNGWeaponBase* GetCurrentWeapon_Implementation(); + + /********************************************************************* + * Damage and hits + ********************************************************************/ + // damage and related + UFUNCTION(BlueprintCallable) + void ApplyHitStop(float HitStopTime, float HitSlowTime); + + virtual void ReceiveHit(FSNGHitData const& HitData, AController* EventInstigator, AActor* DamageCauser); + + virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override; + +protected: + bool bIsInHitStop; + + float CurrHitStopTime; + + float CurrHitSlowTime; + + /********************************************************************* + * Rotate towards target + ********************************************************************/ +public: + UFUNCTION(BlueprintCallable) + void SetupRotateTowardsTarget(FRotator TargetRotation, float DegreesPerSecond, float MaxRotation); + + UFUNCTION(BlueprintCallable) + void RotateTowardsTarget(float DeltaTime); + +protected: + FRotator InitialRot; + + FRotator TargetRot; + + float DegPerSecond; + + float MaxRot; + + float RotateTime; + + float RotateTimeElapsed; + + /********************************************************************* + * Components + ********************************************************************/ + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components") + USNGStateMachineComponent* StateMachineComponent; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components") + USNGHealthComponent* HealthComponent; + + virtual void Tick(float DeltaSeconds) override; + + virtual void PostInitializeComponents() override; +}; diff --git a/SwordNGun/Source/SwordNGun/Public/Characters/SNGEnemyBase.h b/SwordNGun/Source/SwordNGun/Public/Characters/SNGEnemyBase.h index c0c456a..0e2a6b9 100644 --- a/SwordNGun/Source/SwordNGun/Public/Characters/SNGEnemyBase.h +++ b/SwordNGun/Source/SwordNGun/Public/Characters/SNGEnemyBase.h @@ -3,14 +3,14 @@ #pragma once #include "CoreMinimal.h" -#include "Characters/SNGCharacterBase.h" +#include "Characters/SNGCharacterBase_DEPRECATED.h" #include "SNGEnemyBase.generated.h" /** * */ UCLASS() -class SWORDNGUN_API ASNGEnemyBase : public ASNGCharacterBase +class SWORDNGUN_API ASNGEnemyBase : public ASNGCharacterBase_DEPRECATED { GENERATED_BODY() diff --git a/SwordNGun/Source/SwordNGun/Public/Characters/SNGProtagonist.h b/SwordNGun/Source/SwordNGun/Public/Characters/SNGProtagonist.h index c7f5229..f849661 100644 --- a/SwordNGun/Source/SwordNGun/Public/Characters/SNGProtagonist.h +++ b/SwordNGun/Source/SwordNGun/Public/Characters/SNGProtagonist.h @@ -5,7 +5,7 @@ #include "CoreMinimal.h" #include "Camera/CameraComponent.h" -#include "Characters/SNGCharacterBase.h" +#include "Characters/SNGCharacterBase_DEPRECATED.h" #include "Components/SNGWeaponInventoryComponent.h" #include "GameFramework/SpringArmComponent.h" @@ -27,7 +27,7 @@ struct FMeleeAttackData * */ UCLASS() -class SWORDNGUN_API ASNGProtagonist : public ASNGCharacterBase +class SWORDNGUN_API ASNGProtagonist : public ASNGCharacterBase_DEPRECATED { GENERATED_BODY() diff --git a/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h b/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h index 223c747..8fa5cce 100644 --- a/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h +++ b/SwordNGun/Source/SwordNGun/Public/Components/SNGCharacterMovementComponent.h @@ -54,11 +54,7 @@ protected: /** Force to continuously apply to character when they are holding the jump button */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Character Movement: SNG Air Defaults", meta=(ClampMin="0", UIMin="0")) - float JumpForce; - - /** Timer that counts down */ - UPROPERTY(BlueprintReadWrite); - float JumpTimer; + float DefaultJumpForce; /** Minimum height a character must reach before jump force is no longer applied even if the jump input is not being held */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Character Movement: SNG Air Defaults", meta=(ClampMin="0", UIMin="0"))