diff --git a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset index 08851b4..031c2b8 100644 Binary files a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset and b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset differ diff --git a/Content/Blueprints/Items/RevolverGun.uasset b/Content/Blueprints/Items/RevolverGun.uasset index 121fe08..83e0745 100644 Binary files a/Content/Blueprints/Items/RevolverGun.uasset and b/Content/Blueprints/Items/RevolverGun.uasset differ diff --git a/Content/Blueprints/Items/ShotGun.uasset b/Content/Blueprints/Items/ShotGun.uasset index fa6eb93..edcb328 100644 Binary files a/Content/Blueprints/Items/ShotGun.uasset and b/Content/Blueprints/Items/ShotGun.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Falling.uasset b/Content/FirstPersonArms/Animations/FP_Falling.uasset new file mode 100644 index 0000000..e794510 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Falling.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Idle.uasset b/Content/FirstPersonArms/Animations/FP_Idle.uasset new file mode 100644 index 0000000..019b8e7 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Idle.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Jump.uasset b/Content/FirstPersonArms/Animations/FP_Jump.uasset new file mode 100644 index 0000000..11e7634 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Jump.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Land.uasset b/Content/FirstPersonArms/Animations/FP_Land.uasset new file mode 100644 index 0000000..562be0a Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Land.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Falling.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Falling.uasset new file mode 100644 index 0000000..0c33c78 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Falling.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Fire.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Fire.uasset new file mode 100644 index 0000000..286d2c7 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Fire.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Idle.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Idle.uasset new file mode 100644 index 0000000..46d80cf Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Idle.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Jump.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Jump.uasset new file mode 100644 index 0000000..6393742 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Jump.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Land.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Land.uasset new file mode 100644 index 0000000..05ccc7d Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Land.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Run.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Run.uasset new file mode 100644 index 0000000..3bf7baf Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Run.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Rifle_Shoot_Montage.uasset b/Content/FirstPersonArms/Animations/FP_Rifle_Shoot_Montage.uasset new file mode 100644 index 0000000..db54723 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Rifle_Shoot_Montage.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Run_Fwd.uasset b/Content/FirstPersonArms/Animations/FP_Run_Fwd.uasset new file mode 100644 index 0000000..ac4400c Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Run_Fwd.uasset differ diff --git a/Content/FirstPersonArms/Animations/FP_Walk_Fwd.uasset b/Content/FirstPersonArms/Animations/FP_Walk_Fwd.uasset new file mode 100644 index 0000000..f7bcff6 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FP_Walk_Fwd.uasset differ diff --git a/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset b/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset new file mode 100644 index 0000000..538a721 Binary files /dev/null and b/Content/FirstPersonArms/Animations/FirstPerson_AnimBP.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Functions/CA_Mannequin.uasset b/Content/FirstPersonArms/Character/Materials/Functions/CA_Mannequin.uasset new file mode 100644 index 0000000..d1c8f07 Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Functions/CA_Mannequin.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Functions/ChromaticCurve.uasset b/Content/FirstPersonArms/Character/Materials/Functions/ChromaticCurve.uasset new file mode 100644 index 0000000..4e4aa79 Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Functions/ChromaticCurve.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Functions/MF_Diffraction.uasset b/Content/FirstPersonArms/Character/Materials/Functions/MF_Diffraction.uasset new file mode 100644 index 0000000..7f5e7c6 Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Functions/MF_Diffraction.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Functions/MF_logo3layers.uasset b/Content/FirstPersonArms/Character/Materials/Functions/MF_logo3layers.uasset new file mode 100644 index 0000000..13b36fb Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Functions/MF_logo3layers.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Functions/ML_BaseColorFallOff.uasset b/Content/FirstPersonArms/Character/Materials/Functions/ML_BaseColorFallOff.uasset new file mode 100644 index 0000000..d061fc2 Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Functions/ML_BaseColorFallOff.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_01.uasset b/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_01.uasset new file mode 100644 index 0000000..168b822 Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_01.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_02.uasset b/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_02.uasset new file mode 100644 index 0000000..56dcb9e Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/Instances/Manny/MI_Manny_02.uasset differ diff --git a/Content/FirstPersonArms/Character/Materials/M_Mannequin.uasset b/Content/FirstPersonArms/Character/Materials/M_Mannequin.uasset new file mode 100644 index 0000000..ded1ffe Binary files /dev/null and b/Content/FirstPersonArms/Character/Materials/M_Mannequin.uasset differ diff --git a/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms.uasset b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms.uasset new file mode 100644 index 0000000..58218a1 Binary files /dev/null and b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms.uasset differ diff --git a/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_PhysicsAsset.uasset b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_PhysicsAsset.uasset new file mode 100644 index 0000000..204f1f0 Binary files /dev/null and b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_PhysicsAsset.uasset differ diff --git a/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_Skeleton.uasset b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_Skeleton.uasset new file mode 100644 index 0000000..4407a4b Binary files /dev/null and b/Content/FirstPersonArms/Character/Mesh/SK_Mannequin_Arms_Skeleton.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_ASAOPMASK_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_ASAOPMASK_MSK.uasset new file mode 100644 index 0000000..d0a8410 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_ASAOPMASK_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_BN.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_BN.uasset new file mode 100644 index 0000000..0c29012 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_BN.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_CCRCCPlastic_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_CCRCCPlastic_MSK.uasset new file mode 100644 index 0000000..9998bef Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_CCRCCPlastic_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_D.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_D.uasset new file mode 100644 index 0000000..28cff0c Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_D.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_MSR_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_MSR_MSK.uasset new file mode 100644 index 0000000..1a6eb0c Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_MSR_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_N.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_N.uasset new file mode 100644 index 0000000..d8451ac Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_N.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_Tan.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_Tan.uasset new file mode 100644 index 0000000..67202b5 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_01_Tan.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_ASAOPMASK_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_ASAOPMASK_MSK.uasset new file mode 100644 index 0000000..0367acc Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_ASAOPMASK_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_BN.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_BN.uasset new file mode 100644 index 0000000..6b9a723 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_BN.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_CCRCCPlastic_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_CCRCCPlastic_MSK.uasset new file mode 100644 index 0000000..c30481b Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_CCRCCPlastic_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_D.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_D.uasset new file mode 100644 index 0000000..e0b3c82 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_D.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_MSR_MSK.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_MSR_MSK.uasset new file mode 100644 index 0000000..b6b921a Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_MSR_MSK.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_N.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_N.uasset new file mode 100644 index 0000000..3ba7dec Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_N.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_Tan.uasset b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_Tan.uasset new file mode 100644 index 0000000..2ab4d61 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Manny/T_Manny_02_Tan.uasset differ diff --git a/Content/FirstPersonArms/Character/Textures/Shared/T_UE_Logo_M.uasset b/Content/FirstPersonArms/Character/Textures/Shared/T_UE_Logo_M.uasset new file mode 100644 index 0000000..30213c8 Binary files /dev/null and b/Content/FirstPersonArms/Character/Textures/Shared/T_UE_Logo_M.uasset differ diff --git a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp index 1eb3226..4463987 100644 --- a/Source/Exo/Private/Characters/Components/ShootingComponent.cpp +++ b/Source/Exo/Private/Characters/Components/ShootingComponent.cpp @@ -5,18 +5,12 @@ #include "Items/ThrowableBase.h" -// Sets default values for this component's properties UShootingComponent::UShootingComponent() { - // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features - // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; - - // ... } -// Called when the game starts void UShootingComponent::BeginPlay() { Super::BeginPlay(); @@ -30,27 +24,27 @@ void UShootingComponent::BeginPlay() void UShootingComponent::Shoot() { - if (!IsValid(CurrentGun) || CurrentGun->CurrentAmmo == 0 || bIsReloading || !bCanShoot) return; + if (!IsValid(CurrentGunBase) || CurrentGunBase->CurrentAmmo == 0 || bIsReloading || !bCanShoot) return; bCanShoot = false; - CurrentGun->CurrentAmmo--; + CurrentGunBase->CurrentAmmo--; - AActor* HitActor = ExecuteLineTrace(CurrentGun->MaxRange); + AActor* HitActor = ExecuteLineTrace(CurrentGunBase->MaxRange); if (HitActor) { - IDamageable::Execute_TakeDamage(HitActor, CurrentGun->DamageValue); + IDamageable::Execute_TakeDamage(HitActor, CurrentGunBase->DamageValue); - UE_LOG(LogTemp, Display, TEXT("Shoot. Ammo: %d/%d"), CurrentGun->CurrentAmmo, CurrentGun->MaxAmmo); // Docelowo tutaj wywołanie UI aktualizujące stan ammo + UE_LOG(LogTemp, Display, TEXT("Shoot. Ammo: %d/%d"), CurrentGunBase->CurrentAmmo, CurrentGunBase->MaxAmmo); // Docelowo tutaj wywołanie UI aktualizujące stan ammo } - PlayerCharacter->GetWorldTimerManager().SetTimer(ShootCooldownTimer, this, &UShootingComponent::ResetFireCooldown, CurrentGun->FireRateCooldown, false); + PlayerCharacter->GetWorldTimerManager().SetTimer(ShootCooldownTimer, this, &UShootingComponent::ResetFireCooldown, CurrentGunBase->FireRateCooldown, false); // Odrzut float RecoilPitch = FMath::RandRange(-1.0f, -0.5f); float RecoilYaw = FMath::RandRange(-0.5f, 0.5f); - PlayerCharacter->AddControllerPitchInput(RecoilPitch * CurrentGun->RecoilForceMultiplier); - PlayerCharacter->AddControllerYawInput(RecoilYaw * CurrentGun->RecoilForceMultiplier); + PlayerCharacter->AddControllerPitchInput(RecoilPitch * CurrentGunBase->RecoilForceMultiplier); + PlayerCharacter->AddControllerYawInput(RecoilYaw * CurrentGunBase->RecoilForceMultiplier); } void UShootingComponent::MeleAttack() @@ -88,30 +82,30 @@ AActor* UShootingComponent::ExecuteLineTrace(float LineRange) void UShootingComponent::Reload() { - if (!IsValid(CurrentGun) || bIsReloading) return; + if (!IsValid(CurrentGunBase) || bIsReloading) return; bIsReloading = true; StopAiming(); - CurrentGun->CurrentAmmo = CurrentGun->MaxAmmo; - PlayerCharacter->GetWorldTimerManager().SetTimer(ReloadTimer, this, &UShootingComponent::ReloadCompleted, CurrentGun->ReloadTime, false); + CurrentGunBase->CurrentAmmo = CurrentGunBase->MaxAmmo; + PlayerCharacter->GetWorldTimerManager().SetTimer(ReloadTimer, this, &UShootingComponent::ReloadCompleted, CurrentGunBase->ReloadTime, false); - UE_LOG(LogTemp, Display, TEXT("Reloaded. Ammo: %d/%d"), CurrentGun->CurrentAmmo, CurrentGun->MaxAmmo); // Docelowo tutaj wywo�anie UI aktualizuj�ce stan ammo + UE_LOG(LogTemp, Display, TEXT("Reloaded. Ammo: %d/%d"), CurrentGunBase->CurrentAmmo, CurrentGunBase->MaxAmmo); // Docelowo tutaj wywo�anie UI aktualizuj�ce stan ammo } bool UShootingComponent::AddAmmo(EAmmoType CheckingAmmo, int AddValue) { - if (IsValid(CurrentGun)) + if (IsValid(CurrentGunBase)) { // Adding ammo only if type is compatible - if (CurrentGun->AmmoType == CheckingAmmo) + if (CurrentGunBase->AmmoType == CheckingAmmo) { - CurrentGun->AddAmmo(AddValue); + CurrentGunBase->AddAmmo(AddValue); return true; } - if (SecondaryGun->AmmoType == CheckingAmmo) + if (SecondaryGunBase->AmmoType == CheckingAmmo) { - SecondaryGun->AddAmmo(AddValue); + SecondaryGunBase->AddAmmo(AddValue); return true; } } @@ -119,27 +113,31 @@ bool UShootingComponent::AddAmmo(EAmmoType CheckingAmmo, int AddValue) return false; } -void UShootingComponent::PickUpGun(AGunBase* gunItem) +void UShootingComponent::PickUpGun(UStaticMeshComponent* PickedGunMesh) { - if (IsValid(CurrentGun) && IsValid(SecondaryGun)) + if (IsValid(CurrentGunBase) && IsValid(SecondaryGunBase)) DropGun(); - AGunBase* NewGun = NewObject(); - - NewGun->MaxRange = gunItem->MaxRange; - NewGun->DamageValue = gunItem->DamageValue; - NewGun->FireRateCooldown = gunItem->FireRateCooldown; - NewGun->RecoilForceMultiplier = gunItem->RecoilForceMultiplier; - NewGun->ReloadTime = gunItem->ReloadTime; - NewGun->AmmoType = gunItem->AmmoType; - NewGun->CurrentAmmo = gunItem->CurrentAmmo; - NewGun->MaxAmmo = gunItem->MaxAmmo; - NewGun->SceneItemClass = gunItem->GetClass(); + FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, + EAttachmentRule::KeepRelative, true); - if (IsValid(CurrentGun)) - SecondaryGun = NewGun; + PickedGunMesh->SetSimulatePhysics(false); + PickedGunMesh->SetCastShadow(false); + PickedGunMesh->AttachToComponent(PlayerCharacter->Weapon, AttachmentRules, FName(TEXT("GripPoint"))); + + AGunBase* PickedGunBase = Cast(PickedGunMesh->GetOwner()); + + if (IsValid(CurrentGunBase)) + { + SecondaryGunBase = PickedGunBase; + SecondaryGunMesh = PickedGunMesh; + SecondaryGunMesh->SetVisibility(false); + } else - CurrentGun = NewGun; + { + CurrentGunBase = PickedGunBase; + CurrentGunMesh = PickedGunMesh; + } } bool UShootingComponent::PickUpThrow(AThrowableBase* ThrowItem) @@ -176,33 +174,20 @@ bool UShootingComponent::PickUpThrow(AThrowableBase* ThrowItem) void UShootingComponent::DropGun() { - if (!IsValid(CurrentGun)) return; + if (!IsValid(CurrentGunBase)) return; StopAiming(); - FVector ForwardVector = PlayerCharacter->GetActorForwardVector(); - FVector PlayerPos = PlayerCharacter->GetActorLocation(); - FVector DroppedGunPos = PlayerPos + (ForwardVector * DropGunRange); - - FTransform DroppedGunTransform = PlayerCharacter->GetActorTransform(); - DroppedGunTransform.SetLocation(DroppedGunPos); + FDetachmentTransformRules DetachmentRules(EDetachmentRule::KeepRelative, EDetachmentRule::KeepRelative, + EDetachmentRule::KeepRelative, false); - AGunBase* DroppedGun = GetWorld()->SpawnActor(CurrentGun->SceneItemClass, DroppedGunTransform); + CurrentGunMesh->DetachFromComponent(DetachmentRules); + CurrentGunMesh->SetSimulatePhysics(true); + CurrentGunMesh->bCastDynamicShadow = true; + CurrentGunMesh->CastShadow = true; - if (DroppedGun) - { - DroppedGun->MaxRange = CurrentGun->MaxRange; - DroppedGun->DamageValue = CurrentGun->DamageValue; - DroppedGun->FireRateCooldown = CurrentGun->FireRateCooldown; - DroppedGun->RecoilForceMultiplier = CurrentGun->RecoilForceMultiplier; - DroppedGun->ReloadTime = CurrentGun->ReloadTime; - DroppedGun->AmmoType = CurrentGun->AmmoType; - DroppedGun->CurrentAmmo = CurrentGun->CurrentAmmo; - DroppedGun->MaxAmmo = CurrentGun->MaxAmmo; - - CurrentGun->Destroy(); - CurrentGun = nullptr; - } + CurrentGunMesh = nullptr; + CurrentGunBase = nullptr; } void UShootingComponent::DropThrow() @@ -247,9 +232,19 @@ void UShootingComponent::SelectGun(bool bSelectFirstSlot) void UShootingComponent::SwitchGun() { - AGunBase* temp = CurrentGun; - CurrentGun = SecondaryGun; - SecondaryGun = temp; + AGunBase* tempBase = CurrentGunBase; + CurrentGunBase = SecondaryGunBase; + SecondaryGunBase = tempBase; + + UStaticMeshComponent* tempMesh = CurrentGunMesh; + CurrentGunMesh = SecondaryGunMesh; + SecondaryGunMesh = tempMesh; + + if (IsValid(SecondaryGunMesh)) + SecondaryGunMesh->SetVisibility(false); + + if (IsValid(CurrentGunMesh)) + CurrentGunMesh->SetVisibility(true); bIsFirstGunSelected = !bIsFirstGunSelected; StopAiming(); @@ -267,12 +262,12 @@ void UShootingComponent::SwitchGun() void UShootingComponent::StartAiming() { - if (IsValid(CurrentGun)) + if (IsValid(CurrentGunBase)) { PlayerCharacter->bIsAimingMode = true; PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed * AimingMoveSpeedScale; - TargetFOV = CurrentGun->AimingFOV; + TargetFOV = CurrentGunBase->AimingFOV; } } @@ -317,7 +312,14 @@ void UShootingComponent::Throw() } -// Called every frame +bool UShootingComponent::IsHoldingGun() +{ + if (IsValid(CurrentGunBase)) + return true; + + return false; +} + void UShootingComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); diff --git a/Source/Exo/Private/Characters/ExoCharacterBase.cpp b/Source/Exo/Private/Characters/ExoCharacterBase.cpp index 7a8e85c..6d56655 100644 --- a/Source/Exo/Private/Characters/ExoCharacterBase.cpp +++ b/Source/Exo/Private/Characters/ExoCharacterBase.cpp @@ -6,11 +6,6 @@ AExoCharacterBase::AExoCharacterBase() { PrimaryActorTick.bCanEverTick = false; - - Weapon = CreateDefaultSubobject("Weapon"); - Weapon->SetupAttachment(GetMesh(), FName("WeaponHandSocket")); - Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision); - } void AExoCharacterBase::BeginPlay() diff --git a/Source/Exo/Private/Characters/ExoPlayerCharacter.cpp b/Source/Exo/Private/Characters/ExoPlayerCharacter.cpp index 2137d56..53999db 100644 --- a/Source/Exo/Private/Characters/ExoPlayerCharacter.cpp +++ b/Source/Exo/Private/Characters/ExoPlayerCharacter.cpp @@ -13,9 +13,15 @@ AExoPlayerCharacter::AExoPlayerCharacter() GetCharacterMovement()->bSnapToPlaneAtStart = true; InteractionComponent = CreateDefaultSubobject(TEXT("Interaction Component")); - ShootingComponent = CreateDefaultSubobject(TEXT("Shooting Component")); + Weapon = CreateDefaultSubobject("Weapon"); + Weapon->SetupAttachment(GetMesh()); + Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision); + Weapon->bCastDynamicShadow = false; + Weapon->CastShadow = false; + Weapon->SetRelativeLocation(FVector(-50.f, 0.f, -90.f)); + bUseControllerRotationPitch = false; bUseControllerRotationYaw = true; bUseControllerRotationRoll = false; diff --git a/Source/Exo/Private/Items/GunBase.cpp b/Source/Exo/Private/Items/GunBase.cpp index 1b50918..6f06170 100644 --- a/Source/Exo/Private/Items/GunBase.cpp +++ b/Source/Exo/Private/Items/GunBase.cpp @@ -5,35 +5,24 @@ #include "Characters/Components/ShootingComponent.h" -// Sets default values AGunBase::AGunBase() { - // 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 AGunBase::BeginPlay() { Super::BeginPlay(); } -// Called every frame void AGunBase::Tick(float DeltaTime) { Super::Tick(DeltaTime); } -void AGunBase::Interact_Implementation(AExoPlayerCharacter* playerCharacter) -{ - playerCharacter->ShootingComponent->PickUpGun(this); - - Destroy(); -} - void AGunBase::AddAmmo(int AddValue) { CurrentAmmo += AddValue; diff --git a/Source/Exo/Public/Characters/Components/ShootingComponent.h b/Source/Exo/Public/Characters/Components/ShootingComponent.h index 09dc357..d2576f6 100644 --- a/Source/Exo/Public/Characters/Components/ShootingComponent.h +++ b/Source/Exo/Public/Characters/Components/ShootingComponent.h @@ -19,7 +19,6 @@ class EXO_API UShootingComponent : public UActorComponent GENERATED_BODY() public: - // Sets default values for this component's properties UShootingComponent(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug") @@ -32,11 +31,9 @@ public: TObjectPtr CameraManager; protected: - // Called when the game starts virtual void BeginPlay() override; public: - // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; UFUNCTION(Category = "Shooting") @@ -52,7 +49,7 @@ public: bool AddAmmo(EAmmoType CheckingAmmo, int AddValue); UFUNCTION(BlueprintCallable, Category = "Shooting") - void PickUpGun(AGunBase* gunItem); + void PickUpGun(UStaticMeshComponent* PickedGunMesh); UFUNCTION(BlueprintCallable, Category = "Shooting") bool PickUpThrow(AThrowableBase* ThrowItem); @@ -77,6 +74,9 @@ public: UFUNCTION(Category = "Shooting") void Throw(); + + UFUNCTION(BlueprintCallable, Category = "Shooting") + bool IsHoldingGun(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Aiming") float AimingAnimationSpeed = 30.0f; @@ -93,8 +93,11 @@ public: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Shooting") AThrowableBase* ThrowableItem = nullptr; - AGunBase* CurrentGun = nullptr; - AGunBase* SecondaryGun = nullptr; + AGunBase* CurrentGunBase = nullptr; + UStaticMeshComponent* CurrentGunMesh = nullptr; + + AGunBase* SecondaryGunBase = nullptr; + UStaticMeshComponent* SecondaryGunMesh = nullptr; private: void ResetFireCooldown(); diff --git a/Source/Exo/Public/Characters/ExoCharacterBase.h b/Source/Exo/Public/Characters/ExoCharacterBase.h index 446a9e3..1abd9cb 100644 --- a/Source/Exo/Public/Characters/ExoCharacterBase.h +++ b/Source/Exo/Public/Characters/ExoCharacterBase.h @@ -16,8 +16,4 @@ public: protected: virtual void BeginPlay() override; - - UPROPERTY(EditAnywhere, Category = "Combat") - TObjectPtr Weapon; - }; diff --git a/Source/Exo/Public/Characters/ExoPlayerCharacter.h b/Source/Exo/Public/Characters/ExoPlayerCharacter.h index b798f1f..52e5b70 100644 --- a/Source/Exo/Public/Characters/ExoPlayerCharacter.h +++ b/Source/Exo/Public/Characters/ExoPlayerCharacter.h @@ -18,6 +18,9 @@ class EXO_API AExoPlayerCharacter : public AExoCharacterBase public: AExoPlayerCharacter(); + UPROPERTY(EditAnywhere, Category = "Combat") + TObjectPtr Weapon; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly) TObjectPtr InteractionComponent; diff --git a/Source/Exo/Public/Items/GunBase.h b/Source/Exo/Public/Items/GunBase.h index ec100ef..40fc318 100644 --- a/Source/Exo/Public/Items/GunBase.h +++ b/Source/Exo/Public/Items/GunBase.h @@ -14,7 +14,6 @@ class EXO_API AGunBase : public AActor, public IInteractable GENERATED_BODY() public: - // Sets default values for this actor's properties AGunBase(); UPROPERTY(EditAnywhere, Category = "Shooting") @@ -44,18 +43,12 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Ammo") EAmmoType AmmoType = EAmmoType::Revolver; - TSubclassOf SceneItemClass; - UFUNCTION(Category = "Ammo") void AddAmmo(int AddValue); protected: - // Called when the game starts or when spawned virtual void BeginPlay() override; public: - // Called every frame virtual void Tick(float DeltaTime) override; - - virtual void Interact_Implementation(AExoPlayerCharacter* playerCharacter) override; };