diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index aa4856d..df8fa0f 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -131,9 +131,11 @@ ManualIPAddress= +Profiles=(Name="Ragdoll",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="PhysicsBody",CustomResponses=((Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="Simulating Skeletal Mesh Component. All other channels will be set to default.") +Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.") +Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap),(Channel="Bullet",Response=ECR_Ignore)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ") ++Profiles=(Name="Drop",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="Drop",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="Bullet",Response=ECR_Ignore),(Channel="Enemy",Response=ECR_Ignore),(Channel="Drop",Response=ECR_Ignore)),HelpMessage="Needs description") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Bullet") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False,Name="Enemy") +DefaultChannelResponses=(Channel=ECC_GameTraceChannel3,DefaultResponse=ECR_Ignore,bTraceType=False,bStaticObject=False,Name="Projectile") ++DefaultChannelResponses=(Channel=ECC_GameTraceChannel4,DefaultResponse=ECR_Block,bTraceType=False,bStaticObject=False,Name="Drop") +EditProfiles=(Name="NoCollision",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) +EditProfiles=(Name="OverlapAll",CustomResponses=((Channel="Bullet",Response=ECR_Overlap))) +EditProfiles=(Name="CharacterMesh",CustomResponses=((Channel="Bullet",Response=ECR_Ignore))) diff --git a/Content/FMOD/Desktop/Master.bank b/Content/FMOD/Desktop/Master.bank index a920a9b..94beb94 100644 --- a/Content/FMOD/Desktop/Master.bank +++ b/Content/FMOD/Desktop/Master.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e323b4ba1ca2e71a5ba40a4d2c8fa7aae1887367c135340266247ba246d30b46 -size 57600 +oid sha256:22afc72f4ec868d285549b3d651f29d42437b5c0f4ad4b340e33d9a223e7d5cd +size 63136 diff --git a/Content/FMOD/Desktop/Master.strings.bank b/Content/FMOD/Desktop/Master.strings.bank index 4353e74..ff0ea2c 100644 --- a/Content/FMOD/Desktop/Master.strings.bank +++ b/Content/FMOD/Desktop/Master.strings.bank @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d6822a5a948507cb9a44d7f32dcdffab34b7eac0a2bc26fbc7cac1e53353f73 -size 1210 +oid sha256:7cd99ff23ad00c3c45f268a2865d08a8dbb04636b768cb4281f10f77957350de +size 1330 diff --git a/Content/Legumix/Drops/BP_AmmoSpawner.uasset b/Content/Legumix/Drops/BP_AmmoSpawner.uasset new file mode 100644 index 0000000..ec42523 --- /dev/null +++ b/Content/Legumix/Drops/BP_AmmoSpawner.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9c6959a952dccce541ac2076d99cd92d5d01db2de6d2bfd4eb0769239e5aedd +size 39528 diff --git a/Content/Legumix/Drops/BP_DropRevolver.uasset b/Content/Legumix/Drops/BP_DropRevolver.uasset index 74a39c7..085476f 100644 --- a/Content/Legumix/Drops/BP_DropRevolver.uasset +++ b/Content/Legumix/Drops/BP_DropRevolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e56ca9e4a3f512aefb7d9d1a0914c3f00a7b5ab18d6c32ac6d30e57be7fabd6 -size 34961 +oid sha256:c81ae7940fd0d9bfbbd9ab2659f2a0aca7b56c094a00dc57f52ecfa43e8c82aa +size 38220 diff --git a/Content/Legumix/Drops/BP_DropShotgun.uasset b/Content/Legumix/Drops/BP_DropShotgun.uasset index 0518f37..8307c21 100644 --- a/Content/Legumix/Drops/BP_DropShotgun.uasset +++ b/Content/Legumix/Drops/BP_DropShotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c323a5669a06a5314d372d57edcd1638bbb828178a9e7c9b6299d245dc6f3794 -size 35513 +oid sha256:58d5e1577f8d3fe8d6e31fa53b2f7f9e6141138dad56b8a7b38dd44cc08ba89f +size 38044 diff --git a/Content/Legumix/Drops/BP_HealthPack.uasset b/Content/Legumix/Drops/BP_HealthPack.uasset index 208c515..2cbe4f6 100644 --- a/Content/Legumix/Drops/BP_HealthPack.uasset +++ b/Content/Legumix/Drops/BP_HealthPack.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5e2f39e549b5f598278cb14832e87390b3c05da6d4a7e07daa45e29ed4b6af04 -size 36664 +oid sha256:237e35c4b2e5a378032198bb9da95c9f9e43fbe93b3309e593ad0ce151e724d0 +size 38978 diff --git a/Content/Legumix/Ennemy/E_EnemyState.uasset b/Content/Legumix/Ennemy/E_EnemyState.uasset new file mode 100644 index 0000000..92e5dec --- /dev/null +++ b/Content/Legumix/Ennemy/E_EnemyState.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a30c0970576d8a12503040f483b0cd3b0f6f9291d7a8c3f2a8cef9e1f432f591 +size 2362 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset index 9e4468f..f23a510 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/BB_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17b4954d33d02b19a041ab80cb354e1267c0c48855f938a6f60f5f271a2b97e3 -size 3164 +oid sha256:d48ff45c6df936e3c5c0273bc744097f5af9eb6c49efea349f4c49fa3cc84e22 +size 3753 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset index 0e4831b..93243eb 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/AI/BT_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6c114a3a67b92085baf4239b13b5cc03915aac21c1487bd1adea82a6e37b380 -size 14596 +oid sha256:3c1d0de944be3a186cd83767fcad2b3c45db7992ee4a7b4c113dd94b6b365da0 +size 14578 diff --git a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset index d1c5956..5137ae4 100644 --- a/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset +++ b/Content/Legumix/Ennemy/MeleeEnemy/BP_MeleeEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:972f0ab7be3e08dd5b398135218d51de818594c4a7f3a9013f87c6b29ff7dabc -size 163138 +oid sha256:4b99f679157ce353be343093b016d9385ee3f22a716f56c58d3cd9af5ef9fba4 +size 155467 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset index 8882c5b..6abcbb6 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BB_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f0c051b120695df59fc210d0228690187e72d7365d2ff14fe648ab82fe069587 -size 4844 +oid sha256:f7c204b2084e9bcf242cf2b1e273dacc89f398ceb7d0d6caea68e55000c7b3d1 +size 4764 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset index 63033a9..a7afc91 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/BT_RangeEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b46ec742714bc4daa369f965a18aa057be790fde68a4a2d1e3e03e76dbe505b4 -size 50360 +oid sha256:784e000a3f2cee6e2eedd3d5385317736f6088a309d833fe56d49f76730139bb +size 63522 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset b/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset index a947653..c1f57fb 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AI/Task/BTTask_RangeAttack.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40bc19f91521ce13ecebe56a7e7137cf6a2089e29e47932e514a2266657203e2 +oid sha256:8f6f919369ab935dd7dea39fa41bc7b3fe7a436237e8ede1f9ffb09eb9bf977b size 23377 diff --git a/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset index 04ab42c..9618c3a 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/AIC_DistantEnnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e2737c468d3483de2b45e7f606cfd6f84df298a5baa7a788e746d765fbf536b -size 44086 +oid sha256:2af9306765d7314b9ab33dbc6c7f9cd14f191950152a053a28e80f07cefcce25 +size 129982 diff --git a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset index 6e5bb11..9b712a0 100644 --- a/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset +++ b/Content/Legumix/Ennemy/RangeEnemy/BP_DistantEnemy.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bf09f7315dd6ed8ccad7ffbfa895e37ca97266338ddb8326455065ce452bad25 -size 295981 +oid sha256:5d9dc5f261c0e8a715031171eb0a022f96fd54d3b84dfc0400b4b6d190dc0f24 +size 296710 diff --git a/Content/Legumix/Levels/LVL_00.umap b/Content/Legumix/Levels/LVL_00.umap index 18024d9..87eef1f 100644 --- a/Content/Legumix/Levels/LVL_00.umap +++ b/Content/Legumix/Levels/LVL_00.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe05af22763868ebb24c4664d26ea4b48f7f71431168c5c00fa125d0ab07bb84 -size 116636 +oid sha256:53601be56a5858e1b76ae01857f3aba8f74c5982a7eacd1aba65eab31908027b +size 128808 diff --git a/Content/Legumix/Levels/LVL_TEST_003.umap b/Content/Legumix/Levels/LVL_TEST_003.umap index 34a2bef..993bcc1 100644 --- a/Content/Legumix/Levels/LVL_TEST_003.umap +++ b/Content/Legumix/Levels/LVL_TEST_003.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4da41674e8ae2fd7743ba5f0ae3dc68105b3e3736c5305460f579c8f20f8ef33 -size 1597041 +oid sha256:c2b6f07b35bec3ac7bfa0f292d45318d1dd6d725c0c229245ade9e2f4ea07251 +size 291 diff --git a/Content/Legumix/Player/BP_GrabComponent.uasset b/Content/Legumix/Player/BP_GrabComponent.uasset new file mode 100644 index 0000000..6546214 --- /dev/null +++ b/Content/Legumix/Player/BP_GrabComponent.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc4a6166579c377d3c8a2ac96634a5e37d05c2aa325abac959e5ea39f3558d4d +size 9696 diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 252f3d7..e0b165c 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:097724fddf62f164c3e438a22511a911db5d1f28cb24e61d53b5cb8c71c2f031 -size 638942 +oid sha256:df786d770dc0106b0d0ba66b32f9fde2483ed489db125481e847c87523c7b467 +size 642697 diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index 12d2476..6804311 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fc92081abb28b81e9a56e981284c3e7802f559c318716fe4c5d2f2bba749c6e3 -size 22303 +oid sha256:c394e1e698d9ca42975ee6cc67d1d92372e58e2241b97abbcddf40d23f5c718d +size 22358 diff --git a/Content/Legumix/Player/C_GrabMovement.uasset b/Content/Legumix/Player/C_GrabMovement.uasset new file mode 100644 index 0000000..9e6ef1d --- /dev/null +++ b/Content/Legumix/Player/C_GrabMovement.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5683d4d38474f956c5e35a3597c4f1d18766f2d312303cfe8173aacf1557f4be +size 5054 diff --git a/Content/Legumix/Spawner/DT_WavePreset.uasset b/Content/Legumix/Spawner/DT_WavePreset.uasset index 98efd95..4685997 100644 --- a/Content/Legumix/Spawner/DT_WavePreset.uasset +++ b/Content/Legumix/Spawner/DT_WavePreset.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0a8c14f41d1b2e5c1655d90dbbf4bf5ad091136fc028d831c2791b67dade66f5 -size 3973 +oid sha256:d5ad534f038b5ffb73b2c8a71bb452ca0738b663171f420e20399107859821dc +size 3345 diff --git a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp index cfc4560..366a839 100644 --- a/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp +++ b/Source/LegumeMix/Private/Ammo/LMAmmoPack.cpp @@ -3,8 +3,20 @@ #include "Ammo/LMAmmoPack.h" +#include "Player/LMPlayer.h" +#include "Weapon/LMWeaponManager.h" + ALMAmmoPack::ALMAmmoPack() { PrimaryActorTick.bCanEverTick = false; } + +void ALMAmmoPack::ConsumePack(ALMPlayer* Player) +{ + Super::ConsumePack(Player); + + Player->AddAmmo(AmmoType, AmmoCount); + OnPackConsumed(); + Despawn(); +} diff --git a/Source/LegumeMix/Private/Enemy/LMEnemy.cpp b/Source/LegumeMix/Private/Enemy/LMEnemy.cpp index aadbe70..6d8aaca 100644 --- a/Source/LegumeMix/Private/Enemy/LMEnemy.cpp +++ b/Source/LegumeMix/Private/Enemy/LMEnemy.cpp @@ -5,7 +5,6 @@ ALMEnemy::ALMEnemy() { PrimaryActorTick.bCanEverTick = true; - EnemyState = EEnemyState::EES_Chasing; AttackingRadius = 100.f; AttackingDamage = 0.f; } @@ -22,11 +21,6 @@ void ALMEnemy::Attack(const APawn* TargetedPawn) GEngine->AddOnScreenDebugMessage(1, 2.f, FColor::Cyan, Debug); } -double ALMEnemy::GetDistanceToTarget(const AActor* TargetedActor) -{ - return (TargetedActor->GetActorLocation() - GetActorLocation()).Length(); -} - void ALMEnemy::Tick(float DeltaTime) { Super::Tick(DeltaTime); diff --git a/Source/LegumeMix/Private/LMHealthPack.cpp b/Source/LegumeMix/Private/LMHealthPack.cpp index 51b9614..833ee14 100644 --- a/Source/LegumeMix/Private/LMHealthPack.cpp +++ b/Source/LegumeMix/Private/LMHealthPack.cpp @@ -3,9 +3,21 @@ #include "LMHealthPack.h" +#include "Player/LMHealthComponent.h" +#include "Player/LMPlayer.h" + ALMHealthPack::ALMHealthPack() { PrimaryActorTick.bCanEverTick = false; } +void ALMHealthPack::ConsumePack(ALMPlayer* Player) +{ + Super::ConsumePack(Player); + + Player->GetHealthComponent()->AddHealth(HealthGain); + OnPackConsumed(); + Despawn(); +} + diff --git a/Source/LegumeMix/Private/LMItemDrop.cpp b/Source/LegumeMix/Private/LMItemDrop.cpp index de74b26..e6ad47e 100644 --- a/Source/LegumeMix/Private/LMItemDrop.cpp +++ b/Source/LegumeMix/Private/LMItemDrop.cpp @@ -3,20 +3,63 @@ #include "LMItemDrop.h" +#include "Kismet/KismetMathLibrary.h" + ALMItemDrop::ALMItemDrop() { PrimaryActorTick.bCanEverTick = true; + Root = CreateDefaultSubobject("Root"); + RootComponent = Root; + StaticMeshComponent = CreateDefaultSubobject("MeshComponent"); - RootComponent = StaticMeshComponent; + StaticMeshComponent->SetupAttachment(RootComponent); } void ALMItemDrop::BeginPlay() { Super::BeginPlay(); + SpawnLocation = GetActorLocation(); GetWorldTimerManager().SetTimer(DespawnHandle, this, &ALMItemDrop::Despawn, TimeBeforeDespawn); } +void ALMItemDrop::SetAttractor(AActor* Target) +{ + Attractor = Target; + GetWorldTimerManager().SetTimer(MoveHandle, this, &ALMItemDrop::DoMovingTowardsTarget, MoveRate, true); + GetWorldTimerManager().ClearTimer(DespawnHandle); +} + +void ALMItemDrop::DoMovingTowardsTarget() +{ + if (MoveTime >= MoveDuration) + { + GetWorldTimerManager().ClearTimer(MoveHandle); + SetActorLocation(Attractor->GetActorLocation()); + return; + } + + const FVector Position = Attractor->GetActorLocation(); + + const float Duration = MoveTime / MoveDuration; + + FString text = FString::Printf(TEXT("Time : %f / %f = %f"), MoveTime, MoveDuration, Duration); + GEngine->AddOnScreenDebugMessage(-15, 1.f, FColor::Red, text); + const float CurvePosition = PositionAtTime->GetFloatValue(Duration); + const FVector NewPosition = UKismetMathLibrary::VLerp(SpawnLocation, Position, CurvePosition); + + MoveTime += MoveRate; + SetActorLocation(NewPosition); +} + +void ALMItemDrop::ConsumePack(ALMPlayer* Player) +{ + if (MoveHandle.IsValid()) + { + GetWorldTimerManager().ClearTimer(MoveHandle); + } +} + void ALMItemDrop::Despawn() { GetWorldTimerManager().ClearTimer(DespawnHandle); diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.cpp b/Source/LegumeMix/Private/Player/LMGrabRange.cpp new file mode 100644 index 0000000..0a67c9b --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMGrabRange.cpp @@ -0,0 +1,66 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "LMGrabRange.h" + +#include "LMItemDrop.h" +#include "Player/LMPlayer.h" + + +ULMGrabRange::ULMGrabRange() +{ + PrimaryComponentTick.bCanEverTick = true; + +} + +void ULMGrabRange::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + if (!bIsEnabled) + return; + + for (int i = Drops.Num() - 1; i >= 0; i--) + { + ALMItemDrop* Item = Drops[i]; + + const FVector ItemPosition = Item->GetActorLocation(); + const FVector Position = GetComponentLocation(); + + const float DistanceLeft = FVector::Dist(ItemPosition, Position); + FString text = FString::Printf(TEXT("Item %s at distance %f"), *Item->GetName(), DistanceLeft); + GEngine->AddOnScreenDebugMessage(i, 1.f, FColor::Cyan, text); + + if (DistanceLeft <= RangeToGrab) + { + Item->ConsumePack(Player); + Drops.Remove(Item); + } + } +} + +void ULMGrabRange::OnDropOverlapped(ALMItemDrop* ItemDrop) +{ + Drops.AddUnique(ItemDrop); + ItemDrop->SetAttractor(Player); +} + +void ULMGrabRange::BeginPlay() +{ + Super::BeginPlay(); + Player = CastChecked(GetOwner()); + OnComponentBeginOverlap.AddUniqueDynamic(this, &ULMGrabRange::OnComponentOverlap); +} + +void ULMGrabRange::OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, + UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) +{ + if (!bIsEnabled) + return; + + if (ALMItemDrop* ItemDrop = Cast(OtherActor)) + { + OnDropOverlapped(ItemDrop); + } +} + diff --git a/Source/LegumeMix/Private/Player/LMGrabRange.h b/Source/LegumeMix/Private/Player/LMGrabRange.h new file mode 100644 index 0000000..eeb97e7 --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMGrabRange.h @@ -0,0 +1,45 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/SphereComponent.h" +#include "LMGrabRange.generated.h" + + +class ALMPlayer; +class ALMItemDrop; + +UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class LEGUMEMIX_API ULMGrabRange : public USphereComponent +{ + GENERATED_BODY() + +private: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) + bool bIsEnabled = true; + + UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true)) + TArray Drops; + + /** The range at which the drop is consumed. */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.1f)) + float RangeToGrab = 10.f; + + TObjectPtr Player; + +public: + ULMGrabRange(); + UFUNCTION(BlueprintCallable, Category=Legumix) + void OnDropOverlapped(ALMItemDrop* ItemDrop); + + virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + +protected: + virtual void BeginPlay() override; + +private: + UFUNCTION() + void OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, + int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult); +}; diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 10d4bb7..f5b5f86 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -116,6 +116,14 @@ bool ALMPlayer::CanJumpInternal_Implementation() const return JumpIsAllowedInternal(); } +void ALMPlayer::AddAmmo(const EAmmoType Ammo, const int AmmoCount) +{ + if (GetWeaponManager()->AddAmmoType(Ammo, AmmoCount)) + { + OnAmmoPickup(); + } +} + void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) { UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 06e4911..adb0930 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -35,6 +35,7 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(FireAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Fire); Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); + Input->BindAction(ScrollAction, ETriggerEvent::Canceled, this, &ALMPlayerController::ScrollEnded); Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause); Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput); Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel); @@ -73,8 +74,19 @@ void ALMPlayerController::Reload(const FInputActionValue& InputValue) void ALMPlayerController::Scroll(const FInputActionValue& InputValue) { + if (bIsScrolling) + return; + const float ScrollAmount = InputValue.Get(); LegumixPlayer->GetWeaponManager()->SwitchWeapon(ScrollAmount); + bIsScrolling = true; + GetWorldTimerManager().SetTimer(ScrollTimer, this, &ALMPlayerController::ScrollEnded, SwitchWeaponDelay, false); +} + +void ALMPlayerController::ScrollEnded() +{ + GetWorldTimerManager().ClearTimer(ScrollTimer); + bIsScrolling = false; } void ALMPlayerController::PauseInput(const FInputActionValue& InputValue) diff --git a/Source/LegumeMix/Public/Ammo/LMAmmoPack.h b/Source/LegumeMix/Public/Ammo/LMAmmoPack.h index 71d1d65..835babd 100644 --- a/Source/LegumeMix/Public/Ammo/LMAmmoPack.h +++ b/Source/LegumeMix/Public/Ammo/LMAmmoPack.h @@ -21,4 +21,6 @@ public: public: ALMAmmoPack(); + + virtual void ConsumePack(ALMPlayer* Player) override; }; diff --git a/Source/LegumeMix/Public/Enemy/LMEnemy.h b/Source/LegumeMix/Public/Enemy/LMEnemy.h index 001b14d..c3f8b71 100644 --- a/Source/LegumeMix/Public/Enemy/LMEnemy.h +++ b/Source/LegumeMix/Public/Enemy/LMEnemy.h @@ -6,13 +6,6 @@ #include "GameFramework/Character.h" #include "LMEnemy.generated.h" -UENUM(BlueprintType) -enum class EEnemyState : uint8 -{ - EES_Chasing UMETA(DisplayName = "Chasing"), - EES_Attacking UMETA(DisplayName = "Attacking") -}; - UCLASS() class LEGUMEMIX_API ALMEnemy : public ACharacter { @@ -31,23 +24,12 @@ public: protected: virtual void BeginPlay() override; - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") - EEnemyState EnemyState; - UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") double AttackingRadius; UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = "true"), Category = "Legumix") float AttackingDamage; - - /** - * Returns the distance between the enemy and a target. - * @param TargetedActor - * @returns the distance - */ - UFUNCTION(BlueprintCallable, Category="Legumix", meta=(ReturnDisplayName="Distance", DefaultToSelf="TargetedActor")) - double GetDistanceToTarget(const AActor* TargetedActor); - + /** * Performs an attack on the targeted pawn * @param TargetedPawn diff --git a/Source/LegumeMix/Public/LMHealthPack.h b/Source/LegumeMix/Public/LMHealthPack.h index ef6f956..db6a4fd 100644 --- a/Source/LegumeMix/Public/LMHealthPack.h +++ b/Source/LegumeMix/Public/LMHealthPack.h @@ -17,4 +17,6 @@ public: public: ALMHealthPack(); + + virtual void ConsumePack(ALMPlayer* Player) override; }; diff --git a/Source/LegumeMix/Public/LMItemDrop.h b/Source/LegumeMix/Public/LMItemDrop.h index 423c7dd..1ccb8b7 100644 --- a/Source/LegumeMix/Public/LMItemDrop.h +++ b/Source/LegumeMix/Public/LMItemDrop.h @@ -6,6 +6,7 @@ #include "GameFramework/Actor.h" #include "LMItemDrop.generated.h" +class ALMPlayer; class ULMDropData; UCLASS() @@ -16,17 +17,50 @@ class LEGUMEMIX_API ALMItemDrop : public AActor protected: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) float TimeBeforeDespawn = 30.f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) + float MoveRate = 0.1f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix) + float MoveDuration = 1.f; + + /** Distance curve from 0-1 to the player. */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true)) + TObjectPtr PositionAtTime; + + FTimerHandle DespawnHandle; + FTimerHandle MoveHandle; private: + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) + TObjectPtr Root; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) TObjectPtr StaticMeshComponent; - - FTimerHandle DespawnHandle; + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true)) + FVector SpawnLocation; + + UPROPERTY() + TObjectPtr Attractor; + + float MoveTime = 0.f; public: ALMItemDrop(); virtual void BeginPlay() override; + void SetAttractor(AActor* Target); + UFUNCTION() + void DoMovingTowardsTarget(); + + UFUNCTION(BlueprintCallable) + virtual void ConsumePack(ALMPlayer* Player); + + UFUNCTION(BlueprintImplementableEvent) + void OnPackConsumed(); + + FVector GetSpawnLocation() const { return SpawnLocation; } + protected: UFUNCTION(BlueprintCallable) void Despawn(); diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 02e4b55..2183e22 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "LMBulletInfo.h" #include "LMTeam.h" +#include "Ammo/LMAmmoPack.h" #include "Camera/CameraComponent.h" #include "GameFramework/Character.h" #include "LMPlayer.generated.h" @@ -56,6 +57,9 @@ public: virtual bool CanJumpInternal_Implementation() const override; + UFUNCTION(BlueprintCallable) + void AddAmmo(EAmmoType Ammo, int AmmoCount); + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index 8497837..bd5f4bf 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -54,7 +54,6 @@ private: UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; - virtual void SetupInputComponent() override; void Move(const FInputActionValue& InputValue); void Jump(const FInputActionValue& InputValue); @@ -68,6 +67,10 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0)) float Sensitivity = 1.0f; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.f)) + float SwitchWeaponDelay = 0.1f; + private: UFUNCTION(BlueprintCallable, Category = Legumix) @@ -75,4 +78,9 @@ private: UFUNCTION(BlueprintCallable, Category = Legumix) void OnSettingsChanged(); + + void ScrollEnded(); + + FTimerHandle ScrollTimer; + bool bIsScrolling; };