diff --git a/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.cpp b/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.cpp index ade25671..3d2bf453 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.cpp @@ -3,6 +3,8 @@ #include "BaseWeaponClass.h" +#include "Components/CapsuleComponent.h" + // Sets default values ABaseWeaponClass::ABaseWeaponClass() diff --git a/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.h index 57604d02..32225fe0 100644 --- a/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/BaseWeaponClass.h @@ -6,6 +6,8 @@ #include "WeaponItemClass.h" #include "BaseWeaponClass.generated.h" +class UCapsuleComponent; + UCLASS() class ENDLESSVENDETTA_API ABaseWeaponClass : public AWeaponItemClass { @@ -22,4 +24,20 @@ protected: public: // Called every frame virtual void Tick(float DeltaTime) override; + + UPROPERTY(EditAnywhere) + FName WeaponName; + + UPROPERTY(EditAnywhere) + int WeaponDamage; + + UPROPERTY(EditAnywhere) + float FireRate; + + UPROPERTY(EditAnywhere) + int MagazineSize; + + UPROPERTY(EditAnywhere) + UTexture2D* WeaponImage; + }; diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 59310e24..f9dc4927 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -69,6 +69,9 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent* //Looking EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look); + + //Weapon Switching + EnhancedInputComponent->BindAction(WeaponEquipAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::WeaponEquip); } } @@ -99,6 +102,11 @@ void AEndlessVendettaCharacter::Look(const FInputActionValue& Value) } } +void AEndlessVendettaCharacter::WeaponEquip() +{ + UE_LOG(LogTemp, Display, TEXT("EQUIPPING WEAPONS")); +} + void AEndlessVendettaCharacter::SetHasRifle(bool bNewHasRifle) { bHasRifle = bNewHasRifle; diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index 667db81c..c9405896 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -7,6 +7,7 @@ #include "InputActionValue.h" #include "EndlessVendettaCharacter.generated.h" +class UWeaponInventory; class UInputComponent; class USkeletalMeshComponent; class USceneComponent; @@ -39,6 +40,10 @@ class AEndlessVendettaCharacter : public ACharacter UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) class UInputAction* MoveAction; + /** Weapon Equip Action */ + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true")) + class UInputAction* WeaponEquipAction; + public: AEndlessVendettaCharacter(); @@ -71,6 +76,8 @@ protected: /** Called for looking input */ void Look(const FInputActionValue& Value); + void WeaponEquip(); + protected: // APawn interface virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override; @@ -82,6 +89,9 @@ public: /** Returns FirstPersonCameraComponent subobject **/ UCameraComponent* GetFirstPersonCameraComponent() const { return FirstPersonCameraComponent; } +private: + UWeaponInventory* WeaponInventory; + }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.cpp index 14c10a17..97262c6c 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.cpp @@ -3,6 +3,8 @@ #include "WeaponInventory.h" +#include "WeaponItemClass.h" + // Sets default values for this component's properties UWeaponInventory::UWeaponInventory() @@ -10,8 +12,7 @@ UWeaponInventory::UWeaponInventory() // 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; - - // ... + } @@ -33,3 +34,11 @@ void UWeaponInventory::TickComponent(float DeltaTime, ELevelTick TickType, FActo // ... } +//Called from blueprints from the player +void UWeaponInventory::WeaponPickup(AActor* WeaponPickedUp) +{ + AWeaponItemClass* WeaponItemClass = Cast(WeaponPickedUp); + WeaponsArray.Add(WeaponItemClass); + WeaponPickedUp->Destroy(); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.h b/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.h index 5ac32b02..b060d0ac 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponInventory.h @@ -7,6 +7,8 @@ #include "WeaponInventory.generated.h" +class AWeaponItemClass; + UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class ENDLESSVENDETTA_API UWeaponInventory : public UActorComponent { @@ -20,7 +22,23 @@ protected: // Called when the game starts virtual void BeginPlay() override; + UPROPERTY(VisibleAnywhere, Category = "Weapon System") + TArray WeaponsArray; + public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + //Using a getter to get the protected weaponsArray + UFUNCTION() + TArray GetWeaponArray() const { return WeaponsArray; } + + //Using a Setter to set the protected weapons array to the getter + UFUNCTION() + void SetArray(const TArray weaponArray) { WeaponsArray = weaponArray; } + +private: + //Called from blueprints from the player + UFUNCTION(BlueprintCallable) + void WeaponPickup(AActor* WeaponPickedUp); }; diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.cpp b/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.cpp index 90d8f5ac..d1e399a7 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.cpp @@ -24,3 +24,18 @@ void AWeaponItemClass::Tick(float DeltaTime) Super::Tick(DeltaTime); } +//Called from WeaponInventory actor component class +void AWeaponItemClass::Equip(ABaseWeaponClass* PickedUpWeapon) +{ + //get the weapons in the array from component + //whatever input is being pressed add that to the player socket + //if there is no gun simply add it to the socket + //if there is a weapon remove from socket and add the requested one +} + +//Called from WeaponInventory actor component class +void AWeaponItemClass::Unequip(ABaseWeaponClass* PickedUpWeapon) +{ + //same as equip but +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.h index e7042620..a1ad01bf 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponItemClass.h @@ -6,6 +6,8 @@ #include "GameFramework/Actor.h" #include "WeaponItemClass.generated.h" +class ABaseWeaponClass; + UCLASS() class ENDLESSVENDETTA_API AWeaponItemClass : public AActor { @@ -22,4 +24,12 @@ protected: public: // Called every frame virtual void Tick(float DeltaTime) override; + +private: + + UFUNCTION() + void Equip(ABaseWeaponClass* PickedUpWeapon); + + UFUNCTION() + void Unequip(ABaseWeaponClass* PickedUpWeapon); };