From d29bb501c772730277436188e31d052a6aa125a6 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Sun, 13 Nov 2022 22:21:51 +0000 Subject: [PATCH 01/12] Updated Interaction,TempCharacter to cleanup I cleaned up and removed unused functions in both interaction and tempcharacter scripts. --- Content/Blueprints/BP_Interaction.uasset | 4 +- .../MerchantInteraction/Interaction.cpp | 3 +- .../MerchantInteraction/Interaction.h | 6 +- .../PlayerTemp/TempCharacter.cpp | 1 - .../PlayerTemp/TempCharacter.cpp~ | 87 +++++++++++++++++++ 5 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ diff --git a/Content/Blueprints/BP_Interaction.uasset b/Content/Blueprints/BP_Interaction.uasset index 024952c..36accd5 100644 --- a/Content/Blueprints/BP_Interaction.uasset +++ b/Content/Blueprints/BP_Interaction.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:14deaac2c8f6b6aa67592c8a806ed6059a566d3a767fbd18a092107b29913718 -size 27683 +oid sha256:4c7a00cbf616d22eba20079c3f1640b3d1c3ef86aee1bcfa4335ca32a5390a80 +size 27630 diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index df5bad3..237d6ee 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -12,7 +12,6 @@ AInteraction::AInteraction() { // 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; - WidgetBase = CreateDefaultSubobject(TEXT("Widget Base Class")); } // Called when the game starts or when spawned @@ -31,7 +30,7 @@ void AInteraction::Tick(float DeltaTime) void AInteraction::OnInteract() { - auto spawnedWidget = CreateWidget(GetWorld(), Widget); + UUserWidget* spawnedWidget = CreateWidget(GetWorld(), Widget); spawnedWidget->AddToViewport(0); } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index da9fd47..2fa21b1 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -22,12 +22,10 @@ protected: public: // Called every frame virtual void Tick(float DeltaTime) override; - - UPROPERTY(VisibleAnywhere) - class UWidgetComponent* WidgetBase; - + UPROPERTY(EditAnywhere) TSubclassOf Widget; virtual void OnInteract(); }; + diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index b1f86e8..83bf10b 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -79,7 +79,6 @@ void ATempCharacter::LineTraceLogic() } if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); MyInteractable->OnInteract(); UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ new file mode 100644 index 0000000..83bf10b --- /dev/null +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ @@ -0,0 +1,87 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#include "TempCharacter.h" +#include "UObject/SoftObjectPath.h" +#include "Dialogs/Dialogs.h" +#include "Engine/GameViewportClient.h" +#include "Blueprint/UserWidget.h" +#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" +#include "the_twilight_abyss/MerchantInteraction/Interaction.h" + + +// CONSTRUCTOR +ATempCharacter::ATempCharacter() +{ + // Set this character 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 ATempCharacter::BeginPlay() +{ + Super::BeginPlay(); + +} + +//Binds the input we made in the setup player component to the forward vector +void ATempCharacter::ForwardInput(float Axis) +{ + AddMovementInput(GetActorForwardVector() * Axis); +} + +//Binds the input we made in the setup player component to the right vector +void ATempCharacter::RightMoveInput(float Axis) +{ + AddMovementInput(GetActorRightVector() * Axis); +} + + +// Called every frame +void ATempCharacter::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + +// Called to bind functionality to input +void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + PlayerInputComponent->BindAxis(TEXT("Move Forward / Backward"), this, &ATempCharacter::ForwardInput); + PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput); + PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput); + PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput); + PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); + // custom keybind Interact +} + +void ATempCharacter::KeyPressed() +{ + LineTraceLogic(); +} + +void ATempCharacter::LineTraceLogic() +{ + float GlobalTrace = TraceDistance; + FHitResult OutHit; + FVector Start = GetActorLocation(); + FVector End = Start + GlobalTrace * GetActorForwardVector(); + + FCollisionQueryParams TraceParams; + + TraceParams.AddIgnoredActor(this); + + bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams); + if (bHit) + { + if(OutHit.GetActor() == nullptr) + { + return; + } + if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) + { + DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); + MyInteractable->OnInteract(); + UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); + } + } +} From e070b32f0e12808ad77c8393fad824f5f8c74262 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 14:57:02 +0000 Subject: [PATCH 02/12] Created BaseItem and InventoryComponent for Items Created both the baseitem and inventorycomponent class to start adding in the custom items to the game. --- Content/Levels/MerchantPrototype.umap | 4 +- .../BaseItems/InventoryComponent.cpp | 36 ++++++++++++++++ .../BaseItems/InventoryComponent.h | 27 ++++++++++++ .../BaseItems/Items/BaseItem.cpp | 4 ++ .../BaseItems/Items/BaseItem.h | 41 +++++++++++++++++++ 5 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp create mode 100644 Source/the_twilight_abyss/BaseItems/InventoryComponent.h create mode 100644 Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp create mode 100644 Source/the_twilight_abyss/BaseItems/Items/BaseItem.h diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index 5e6ba54..433a8e5 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b452da02d420447c486ed947537ab3030dddf2942de6533b784f7ec131498696 -size 23264 +oid sha256:659d40d87576c276667484be63bcb818039f4f8ac40525cdcea92c90eee7aaec +size 23245 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp new file mode 100644 index 0000000..d3e0cb0 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -0,0 +1,36 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "InventoryComponent.h" + + +// Sets default values for this component's properties +UInventoryComponent::UInventoryComponent() +{ + // 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 UInventoryComponent::BeginPlay() +{ + Super::BeginPlay(); + + // ... + +} + + +// Called every frame +void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + // ... +} + diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h new file mode 100644 index 0000000..e4fbe77 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "InventoryComponent.generated.h" + + +UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class THE_TWILIGHT_ABYSS_API UInventoryComponent : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UInventoryComponent(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; +}; diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp new file mode 100644 index 0000000..62ba79f --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp @@ -0,0 +1,4 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "BaseItem.h" diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h new file mode 100644 index 0000000..74a4e45 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -0,0 +1,41 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "UObject/Object.h" +#include "BaseItem.generated.h" + +/** + * + */ +UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew, DefaultToInstanced) +class THE_TWILIGHT_ABYSS_API UBaseItem : public UObject +{ + GENERATED_BODY() + +public: + //The text that will be displayed for using the item (Equip, Eat) + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + FText ItemUseAction; + + //The actual mesh of the item + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + class UStaticMesh* ItemMesh; + + //The picture of the item icon + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + class UTexture2D* ItemIcon; + + //The name of the item + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + FText ItemDisplayName; + + //The description of the item + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + FText ItemDescription; + + //reference to the UInventoryComponent script + UPROPERTY() + class UInventoryComponent* StoredItems; +}; From 7699a088ae5d7805781aa7ea35d288013977147b Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 15:53:50 +0000 Subject: [PATCH 03/12] Added Jelly1 and ItemPurchaseComponent class Jelly1 is the test item i am creating and i also added a health variable for the temp character --- .../BaseItems/InventoryComponent.h | 6 +- .../BaseItems/Items/BaseItem.h | 12 +++ .../BaseItems/Items/Jelly1.cpp | 14 +++ .../BaseItems/Items/Jelly1.h | 21 +++++ .../ItemPurchaseComponent.cpp | 35 ++++++++ .../ItemPurchaseComponent.h | 26 ++++++ .../PlayerTemp/TempCharacter.cpp | 3 +- .../PlayerTemp/TempCharacter.cpp~ | 87 ------------------- .../PlayerTemp/TempCharacter.h | 3 + 9 files changed, 116 insertions(+), 91 deletions(-) create mode 100644 Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp create mode 100644 Source/the_twilight_abyss/BaseItems/Items/Jelly1.h create mode 100644 Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp create mode 100644 Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h delete mode 100644 Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h index e4fbe77..bb4b7d1 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -22,6 +22,8 @@ protected: public: // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + int32 GoldBalance = 500; }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 74a4e45..6f29afe 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -35,7 +35,19 @@ public: UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") FText ItemDescription; + //The cost of the item + UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + int32 ItemCostPrice; + + //ADD A HEALING ITEM VALUE? + //reference to the UInventoryComponent script UPROPERTY() class UInventoryComponent* StoredItems; + + //The buy class to purchase the item + virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); + + //The use Item class to use the item in the player Inventory + virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem); }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp new file mode 100644 index 0000000..0e68019 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp @@ -0,0 +1,14 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Jelly1.h" + +void UJelly1::Buy(UItemPurchaseComponent* PurchaseItem) +{ + Super::Buy(PurchaseItem); +} + +void UJelly1::Use(ATempCharacter* Character) +{ + Super::Use(Character); +} diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h new file mode 100644 index 0000000..42a56b1 --- /dev/null +++ b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "BaseItem.h" +#include "Jelly1.generated.h" + +/** + * + */ +UCLASS() +class THE_TWILIGHT_ABYSS_API UJelly1 : public UBaseItem +{ + GENERATED_BODY() + +protected: + virtual void Buy(class UItemPurchaseComponent* PurchaseItem) override; + + virtual void Use(class ATempCharacter* Character) override; +}; diff --git a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp new file mode 100644 index 0000000..0f06d98 --- /dev/null +++ b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp @@ -0,0 +1,35 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "ItemPurchaseComponent.h" + + +// Sets default values for this component's properties +UItemPurchaseComponent::UItemPurchaseComponent() +{ + // 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 UItemPurchaseComponent::BeginPlay() +{ + Super::BeginPlay(); + + // ... + +} + + +// Called every frame +void UItemPurchaseComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + // ... +} + diff --git a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h new file mode 100644 index 0000000..9b7bb90 --- /dev/null +++ b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "ItemPurchaseComponent.generated.h" + + +UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class THE_TWILIGHT_ABYSS_API UItemPurchaseComponent : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UItemPurchaseComponent(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; +}; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 83bf10b..2b4919e 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -20,7 +20,7 @@ ATempCharacter::ATempCharacter() void ATempCharacter::BeginPlay() { Super::BeginPlay(); - + Health = 100; } //Binds the input we made in the setup player component to the forward vector @@ -28,7 +28,6 @@ void ATempCharacter::ForwardInput(float Axis) { AddMovementInput(GetActorForwardVector() * Axis); } - //Binds the input we made in the setup player component to the right vector void ATempCharacter::RightMoveInput(float Axis) { diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ deleted file mode 100644 index 83bf10b..0000000 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp~ +++ /dev/null @@ -1,87 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#include "TempCharacter.h" -#include "UObject/SoftObjectPath.h" -#include "Dialogs/Dialogs.h" -#include "Engine/GameViewportClient.h" -#include "Blueprint/UserWidget.h" -#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" -#include "the_twilight_abyss/MerchantInteraction/Interaction.h" - - -// CONSTRUCTOR -ATempCharacter::ATempCharacter() -{ - // Set this character 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 ATempCharacter::BeginPlay() -{ - Super::BeginPlay(); - -} - -//Binds the input we made in the setup player component to the forward vector -void ATempCharacter::ForwardInput(float Axis) -{ - AddMovementInput(GetActorForwardVector() * Axis); -} - -//Binds the input we made in the setup player component to the right vector -void ATempCharacter::RightMoveInput(float Axis) -{ - AddMovementInput(GetActorRightVector() * Axis); -} - - -// Called every frame -void ATempCharacter::Tick(float DeltaTime) -{ - Super::Tick(DeltaTime); -} - -// Called to bind functionality to input -void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) -{ - Super::SetupPlayerInputComponent(PlayerInputComponent); - PlayerInputComponent->BindAxis(TEXT("Move Forward / Backward"), this, &ATempCharacter::ForwardInput); - PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput); - PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput); - PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput); - PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); - // custom keybind Interact -} - -void ATempCharacter::KeyPressed() -{ - LineTraceLogic(); -} - -void ATempCharacter::LineTraceLogic() -{ - float GlobalTrace = TraceDistance; - FHitResult OutHit; - FVector Start = GetActorLocation(); - FVector End = Start + GlobalTrace * GetActorForwardVector(); - - FCollisionQueryParams TraceParams; - - TraceParams.AddIgnoredActor(this); - - bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams); - if (bHit) - { - if(OutHit.GetActor() == nullptr) - { - return; - } - if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) - { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); - MyInteractable->OnInteract(); - UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); - } - } -} diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 3f170b4..fd5924c 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -35,4 +35,7 @@ public: float TraceDistance = 200; void LineTraceLogic(); + + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health") + float Health; }; From 8f0a770bfb0705d7bcbdd6928fb4c3faba611746 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 16:52:04 +0000 Subject: [PATCH 04/12] Removed ItemPurchaseComponent script Removed the script as I am not using it for now and solely sticking to creating the inventory system and items currently. --- .../ItemPurchaseComponent.cpp | 35 ------------------- .../ItemPurchaseComponent.h | 26 -------------- 2 files changed, 61 deletions(-) delete mode 100644 Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp delete mode 100644 Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h diff --git a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp deleted file mode 100644 index 0f06d98..0000000 --- a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "ItemPurchaseComponent.h" - - -// Sets default values for this component's properties -UItemPurchaseComponent::UItemPurchaseComponent() -{ - // 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 UItemPurchaseComponent::BeginPlay() -{ - Super::BeginPlay(); - - // ... - -} - - -// Called every frame -void UItemPurchaseComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) -{ - Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - - // ... -} - diff --git a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h b/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h deleted file mode 100644 index 9b7bb90..0000000 --- a/Source/the_twilight_abyss/MerchantInteraction/ItemPurchaseComponent.h +++ /dev/null @@ -1,26 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Components/ActorComponent.h" -#include "ItemPurchaseComponent.generated.h" - - -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) -class THE_TWILIGHT_ABYSS_API UItemPurchaseComponent : public UActorComponent -{ - GENERATED_BODY() - -public: - // Sets default values for this component's properties - UItemPurchaseComponent(); - -protected: - // Called when the game starts - virtual void BeginPlay() override; - -public: - // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; -}; From 83d4d16588d65d3e97a3335b8c158b53782398d3 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 16:52:57 +0000 Subject: [PATCH 05/12] Updated BaseItem,Jelly1,Inventory Component,Temp Updated all the scripts adding more functionality, Currently just added a very basic Use item and it giving the character health. --- .../BaseItems/InventoryComponent.cpp | 3 +-- .../BaseItems/InventoryComponent.h | 3 --- .../BaseItems/Items/BaseItem.cpp | 7 +++++++ .../the_twilight_abyss/BaseItems/Items/BaseItem.h | 8 +++++++- .../the_twilight_abyss/BaseItems/Items/Jelly1.cpp | 11 ++++++----- .../the_twilight_abyss/BaseItems/Items/Jelly1.h | 3 +-- .../PlayerTemp/TempCharacter.cpp | 15 +++++++++++++-- .../the_twilight_abyss/PlayerTemp/TempCharacter.h | 4 ++++ 8 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index d3e0cb0..007c15a 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -26,8 +26,7 @@ void UInventoryComponent::BeginPlay() // Called every frame -void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) +void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h index bb4b7d1..f9ab60e 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -23,7 +23,4 @@ protected: public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; - - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) - int32 GoldBalance = 500; }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp index 62ba79f..1fd0d31 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp @@ -2,3 +2,10 @@ #include "BaseItem.h" + +//constructor +UBaseItem::UBaseItem() +{ + ItemDisplayName = FText::FromString("ItemName"); + ItemUseAction = FText::FromString("UseAction"); +} diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 6f29afe..0c308a5 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -15,6 +15,8 @@ class THE_TWILIGHT_ABYSS_API UBaseItem : public UObject GENERATED_BODY() public: + + UBaseItem(); //The text that will be displayed for using the item (Equip, Eat) UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") FText ItemUseAction; @@ -46,8 +48,12 @@ public: class UInventoryComponent* StoredItems; //The buy class to purchase the item - virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); + virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER //The use Item class to use the item in the player Inventory virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem); + + //This is the same as the use item class but its in BP instead + UFUNCTION(BlueprintImplementableEvent) + void OnUse (class ATempCharacter* Character); }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp index 0e68019..b5d5506 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp @@ -3,12 +3,13 @@ #include "Jelly1.h" -void UJelly1::Buy(UItemPurchaseComponent* PurchaseItem) -{ - Super::Buy(PurchaseItem); -} +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" + void UJelly1::Use(ATempCharacter* Character) { - Super::Use(Character); + if(Character) + { + Character->Health += 10; + } } diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h index 42a56b1..3b6c55f 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h +++ b/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h @@ -15,7 +15,6 @@ class THE_TWILIGHT_ABYSS_API UJelly1 : public UBaseItem GENERATED_BODY() protected: - virtual void Buy(class UItemPurchaseComponent* PurchaseItem) override; - + virtual void Use(class ATempCharacter* Character) override; }; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 2b4919e..6e204db 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -6,6 +6,7 @@ #include "Engine/GameViewportClient.h" #include "Blueprint/UserWidget.h" #include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" +#include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "the_twilight_abyss/MerchantInteraction/Interaction.h" @@ -41,7 +42,7 @@ void ATempCharacter::Tick(float DeltaTime) Super::Tick(DeltaTime); } -// Called to bind functionality to input +// Gives the character the functionality void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { Super::SetupPlayerInputComponent(PlayerInputComponent); @@ -50,14 +51,15 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput); PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput); PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); - // custom keybind Interact } +// When the player presses the E key void ATempCharacter::KeyPressed() { LineTraceLogic(); } +// Line trace logic void ATempCharacter::LineTraceLogic() { float GlobalTrace = TraceDistance; @@ -84,3 +86,12 @@ void ATempCharacter::LineTraceLogic() } } } + +void ATempCharacter::UseItem(class UBaseItem* Item) +{ + if(Item) + { + Item->Use(this); + Item->OnUse(this); //Blueprint Version + } +} diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index fd5924c..11da9ba 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -38,4 +38,8 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Health") float Health; + + //Using the item in the inventory + UFUNCTION(BlueprintCallable, Category= "Items") + void UseItem(class UBaseItem* Item); }; From 785974e1697404a7180b8d441355e0264f0ed389 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 16:58:20 +0000 Subject: [PATCH 06/12] Updated TempCharacter Commented the headerFile for tempcharacter.h --- Source/the_twilight_abyss/PlayerTemp/TempCharacter.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 11da9ba..7cafb29 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -11,6 +11,10 @@ class THE_TWILIGHT_ABYSS_API ATempCharacter : public ACharacter { GENERATED_BODY() + //Player inventory + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) + class UInventoryComponent* Inventory; //Using the InventoryComponent class + public: // Sets default values for this character's properties ATempCharacter(); @@ -41,5 +45,5 @@ public: //Using the item in the inventory UFUNCTION(BlueprintCallable, Category= "Items") - void UseItem(class UBaseItem* Item); + void UseItem(class UBaseItem* Item); // Overriding the BaseItem Class }; From a40aa57f70243e13c2e5d7346aee9f3beadc2001 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 17:42:26 +0000 Subject: [PATCH 07/12] Added all BP Items in the game and updated scripts All Items are added in BP with the values they are meant to have. Starting to now actually implement them into the inventory UI and creating the Inventory UI --- .../Blueprints/Items/BP_HealingSyringe.uasset | 3 ++ Content/Blueprints/Items/BP_Jelly1.uasset | 3 ++ Content/Blueprints/Items/BP_Jelly2.uasset | 3 ++ Content/Blueprints/Items/BP_Jelly3.uasset | 3 ++ .../BaseItems/InventoryComponent.cpp | 42 +++++++++++++++---- .../BaseItems/InventoryComponent.h | 19 ++++++++- .../BaseItems/Items/BaseItem.h | 26 +++++++----- .../Items/{Jelly1.cpp => EatableItems.cpp} | 4 +- .../Items/{Jelly1.h => EatableItems.h} | 4 +- .../PlayerTemp/TempCharacter.cpp | 6 +-- 10 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 Content/Blueprints/Items/BP_HealingSyringe.uasset create mode 100644 Content/Blueprints/Items/BP_Jelly1.uasset create mode 100644 Content/Blueprints/Items/BP_Jelly2.uasset create mode 100644 Content/Blueprints/Items/BP_Jelly3.uasset rename Source/the_twilight_abyss/BaseItems/Items/{Jelly1.cpp => EatableItems.cpp} (71%) rename Source/the_twilight_abyss/BaseItems/Items/{Jelly1.h => EatableItems.h} (72%) diff --git a/Content/Blueprints/Items/BP_HealingSyringe.uasset b/Content/Blueprints/Items/BP_HealingSyringe.uasset new file mode 100644 index 0000000..95e16d9 --- /dev/null +++ b/Content/Blueprints/Items/BP_HealingSyringe.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8e387511b72d482c0cef5dcaf48822ceba438b4bd0cc13ff7410220ca992f15c +size 6030 diff --git a/Content/Blueprints/Items/BP_Jelly1.uasset b/Content/Blueprints/Items/BP_Jelly1.uasset new file mode 100644 index 0000000..e947689 --- /dev/null +++ b/Content/Blueprints/Items/BP_Jelly1.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d8d52b9430b52830e8488a07bdc388bb5a602828a0b898e727c18aeb583fffb +size 5894 diff --git a/Content/Blueprints/Items/BP_Jelly2.uasset b/Content/Blueprints/Items/BP_Jelly2.uasset new file mode 100644 index 0000000..bd7ba3a --- /dev/null +++ b/Content/Blueprints/Items/BP_Jelly2.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:302db81a27f3921406ca175911dd01315a52040b80af2d5515e150f169383463 +size 5894 diff --git a/Content/Blueprints/Items/BP_Jelly3.uasset b/Content/Blueprints/Items/BP_Jelly3.uasset new file mode 100644 index 0000000..9941cf8 --- /dev/null +++ b/Content/Blueprints/Items/BP_Jelly3.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b443f673bb208fa1d7dd5a10319aaf03d7173f4232adda4d9e692895c6c6ade +size 5894 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index 007c15a..30d29bd 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -2,6 +2,9 @@ #include "InventoryComponent.h" +#include "Items/BaseItem.h" + + // Sets default values for this component's properties @@ -11,7 +14,7 @@ UInventoryComponent::UInventoryComponent() // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; - // ... + MaxItemSlots = 10; } @@ -20,16 +23,39 @@ void UInventoryComponent::BeginPlay() { Super::BeginPlay(); - // ... - + for(auto & BaseItem : DefaultItems) + { + AddItem(BaseItem); + } } - -// Called every frame -void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction) +bool UInventoryComponent::AddItem(class UBaseItem* BaseItem) { - Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + //if the items is over the maxinventoryslots then it wont add the item + if (Items.Num() >= MaxItemSlots || !BaseItem) + { + return false; + } + BaseItem->StoredItems = this; + BaseItem->World = GetWorld(); + Items.Add(BaseItem); + + //Update UI + OnInventoryUpdated.Broadcast(); - // ... + return true; +} + +bool UInventoryComponent::Remove(UBaseItem* BaseItem) +{ + if(BaseItem) + { + BaseItem->StoredItems = nullptr; + BaseItem->World = nullptr; + Items.RemoveSingle(BaseItem); + OnInventoryUpdated.Broadcast(); // Updates UI + return true; + } + return false; } diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h index f9ab60e..d2fbb5a 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.h +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.h @@ -6,6 +6,8 @@ #include "Components/ActorComponent.h" #include "InventoryComponent.generated.h" +//OUR DELEGATE IS CALLED FONINVENTORYUPDATED +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInventoryUpdated); UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) class THE_TWILIGHT_ABYSS_API UInventoryComponent : public UActorComponent @@ -21,6 +23,19 @@ protected: virtual void BeginPlay() override; public: - // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + bool AddItem(class UBaseItem* BaseItem); //adds the item to the player + + bool Remove(class UBaseItem* BaseItem); //removes the item from the player + + UPROPERTY(EditDefaultsOnly, Instanced) + TArray DefaultItems; //Items you start the game with IF YOU WANT YOU CAN JUST NOT USE THIS + + UPROPERTY(EditDefaultsOnly, Category= "Inventory") + int32 MaxItemSlots; + + UPROPERTY(BlueprintAssignable, Category= "Inventory") + FOnInventoryUpdated OnInventoryUpdated; //This is our delegate + + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Items") + TArray Items; // The items currently in the inventory }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 0c308a5..639bc1b 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -6,6 +6,7 @@ #include "UObject/Object.h" #include "BaseItem.generated.h" + /** * */ @@ -15,45 +16,50 @@ class THE_TWILIGHT_ABYSS_API UBaseItem : public UObject GENERATED_BODY() public: - UBaseItem(); + + virtual class UWorld* GetWorld() const { return World; }; + + UPROPERTY(Transient) + class UWorld* World; + //The text that will be displayed for using the item (Equip, Eat) - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") FText ItemUseAction; //The actual mesh of the item - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") class UStaticMesh* ItemMesh; //The picture of the item icon - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") class UTexture2D* ItemIcon; //The name of the item - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") FText ItemDisplayName; //The description of the item - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") FText ItemDescription; //The cost of the item - UPROPERTY(EditDefaultsOnly,BlueprintReadWrite, Category = "Item") + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item") int32 ItemCostPrice; //ADD A HEALING ITEM VALUE? - + //reference to the UInventoryComponent script UPROPERTY() class UInventoryComponent* StoredItems; //The buy class to purchase the item - virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER + virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER //The use Item class to use the item in the player Inventory virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem); //This is the same as the use item class but its in BP instead UFUNCTION(BlueprintImplementableEvent) - void OnUse (class ATempCharacter* Character); + void OnUse(class ATempCharacter* Character); }; diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp similarity index 71% rename from Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp rename to Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index b5d5506..63956df 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -1,12 +1,12 @@ // Fill out your copyright notice in the Description page of Project Settings. -#include "Jelly1.h" +#include "EatableItems.h" #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" -void UJelly1::Use(ATempCharacter* Character) +void UEatableItems::Use(ATempCharacter* Character) { if(Character) { diff --git a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h similarity index 72% rename from Source/the_twilight_abyss/BaseItems/Items/Jelly1.h rename to Source/the_twilight_abyss/BaseItems/Items/EatableItems.h index 3b6c55f..127041f 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/Jelly1.h +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.h @@ -4,13 +4,13 @@ #include "CoreMinimal.h" #include "BaseItem.h" -#include "Jelly1.generated.h" +#include "EatableItems.generated.h" /** * */ UCLASS() -class THE_TWILIGHT_ABYSS_API UJelly1 : public UBaseItem +class THE_TWILIGHT_ABYSS_API UEatableItems : public UBaseItem { GENERATED_BODY() diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 6e204db..092c3e6 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -1,11 +1,9 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "TempCharacter.h" -#include "UObject/SoftObjectPath.h" -#include "Dialogs/Dialogs.h" -#include "Engine/GameViewportClient.h" #include "Blueprint/UserWidget.h" #include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" +#include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "the_twilight_abyss/MerchantInteraction/Interaction.h" @@ -15,6 +13,8 @@ ATempCharacter::ATempCharacter() { // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; + Inventory = CreateDefaultSubobject("Inventory"); + Inventory->MaxItemSlots = 10; } // Called when the game starts or when spawned From 83da7265d598cbaf8f4fb68c83ea11278a897249 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 19:22:50 +0000 Subject: [PATCH 08/12] Added HealingJelly Item, Added PlayerInventory Added healing jelly item blueprint and started working on the playerinventory UI --- Content/Blueprints/Items/BP_HealingJelly.uasset | 3 +++ Content/Blueprints/Items/BP_HealingSyringe.uasset | 3 --- Content/Blueprints/Items/BP_Jelly1.uasset | 3 --- Content/Blueprints/Items/BP_Jelly2.uasset | 3 --- Content/Blueprints/Items/BP_Jelly3.uasset | 3 --- Content/Blueprints/WBP_PlayerInventory.uasset | 3 +++ Source/the_twilight_abyss/BaseItems/Items/BaseItem.h | 2 +- 7 files changed, 7 insertions(+), 13 deletions(-) create mode 100644 Content/Blueprints/Items/BP_HealingJelly.uasset delete mode 100644 Content/Blueprints/Items/BP_HealingSyringe.uasset delete mode 100644 Content/Blueprints/Items/BP_Jelly1.uasset delete mode 100644 Content/Blueprints/Items/BP_Jelly2.uasset delete mode 100644 Content/Blueprints/Items/BP_Jelly3.uasset create mode 100644 Content/Blueprints/WBP_PlayerInventory.uasset diff --git a/Content/Blueprints/Items/BP_HealingJelly.uasset b/Content/Blueprints/Items/BP_HealingJelly.uasset new file mode 100644 index 0000000..65677e7 --- /dev/null +++ b/Content/Blueprints/Items/BP_HealingJelly.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79844600695e0e7790cb68584c0c58f21af18a8872904ccd645f1ec3108da22d +size 6681 diff --git a/Content/Blueprints/Items/BP_HealingSyringe.uasset b/Content/Blueprints/Items/BP_HealingSyringe.uasset deleted file mode 100644 index 95e16d9..0000000 --- a/Content/Blueprints/Items/BP_HealingSyringe.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8e387511b72d482c0cef5dcaf48822ceba438b4bd0cc13ff7410220ca992f15c -size 6030 diff --git a/Content/Blueprints/Items/BP_Jelly1.uasset b/Content/Blueprints/Items/BP_Jelly1.uasset deleted file mode 100644 index e947689..0000000 --- a/Content/Blueprints/Items/BP_Jelly1.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d8d52b9430b52830e8488a07bdc388bb5a602828a0b898e727c18aeb583fffb -size 5894 diff --git a/Content/Blueprints/Items/BP_Jelly2.uasset b/Content/Blueprints/Items/BP_Jelly2.uasset deleted file mode 100644 index bd7ba3a..0000000 --- a/Content/Blueprints/Items/BP_Jelly2.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:302db81a27f3921406ca175911dd01315a52040b80af2d5515e150f169383463 -size 5894 diff --git a/Content/Blueprints/Items/BP_Jelly3.uasset b/Content/Blueprints/Items/BP_Jelly3.uasset deleted file mode 100644 index 9941cf8..0000000 --- a/Content/Blueprints/Items/BP_Jelly3.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6b443f673bb208fa1d7dd5a10319aaf03d7173f4232adda4d9e692895c6c6ade -size 5894 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset new file mode 100644 index 0000000..d344783 --- /dev/null +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78538ab814d72cd06a99884f5656b4a37cd55ddb9116484f8301be5038323a9e +size 18699 diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 639bc1b..2782c63 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -58,7 +58,7 @@ public: //The use Item class to use the item in the player Inventory virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem); - + //This is the same as the use item class but its in BP instead UFUNCTION(BlueprintImplementableEvent) void OnUse(class ATempCharacter* Character); From 5ebf6a3431d7ac7b6a8ebc95e3b530808b3593be Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 19:47:17 +0000 Subject: [PATCH 09/12] Updated PlayerInventory->ItemDisplay Added a placeholder jelly image to the first item and finished blueprinting and creating the itemdisplay --- Content/Blueprints/WBP_ItemDisplay.uasset | 3 +++ Content/Blueprints/WBP_PlayerInventory.uasset | 3 --- Content/Images/testimage.uasset | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 Content/Blueprints/WBP_ItemDisplay.uasset delete mode 100644 Content/Blueprints/WBP_PlayerInventory.uasset create mode 100644 Content/Images/testimage.uasset diff --git a/Content/Blueprints/WBP_ItemDisplay.uasset b/Content/Blueprints/WBP_ItemDisplay.uasset new file mode 100644 index 0000000..afb5151 --- /dev/null +++ b/Content/Blueprints/WBP_ItemDisplay.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c70ffaf4738412537996db61c6620a7f49e7fe9c07108cff72ab3738fdfe5c78 +size 80902 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset deleted file mode 100644 index d344783..0000000 --- a/Content/Blueprints/WBP_PlayerInventory.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:78538ab814d72cd06a99884f5656b4a37cd55ddb9116484f8301be5038323a9e -size 18699 diff --git a/Content/Images/testimage.uasset b/Content/Images/testimage.uasset new file mode 100644 index 0000000..8691ea4 --- /dev/null +++ b/Content/Images/testimage.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:727645288d26ba910415d48a76aef277d0ba0840e5d5f859b58e11f0eaecbe0a +size 45103 From fe75a8c3881b188ce06b016bad5d6539e4f5844e Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 19:50:57 +0000 Subject: [PATCH 10/12] Created Inventory BP Created the Inventory UI --- Content/Blueprints/WBP_PlayerInventory.uasset | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 Content/Blueprints/WBP_PlayerInventory.uasset diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset new file mode 100644 index 0000000..ce2f4e0 --- /dev/null +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:47660a75d7b9806d0475c43f31f887d9f7266604ce09614b958b452fadbcd6f3 +size 29178 From 7a8dead59b1fbb2c45f1b9258a109e6213e53473 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 20:28:34 +0000 Subject: [PATCH 11/12] Added Default Item to test Added a default item to the inventory BP. --- Content/Blueprints/BP_MyTempCharacter.uasset | 4 ++-- Content/Blueprints/WBP_ItemDisplay.uasset | 4 ++-- Content/Blueprints/WBP_PlayerInventory.uasset | 4 ++-- Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp | 5 +++++ Source/the_twilight_abyss/BaseItems/Items/BaseItem.h | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset index 0594c08..7085e97 100644 --- a/Content/Blueprints/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ab40229553278ecf914c2fb5a78609d1bff1d3c451797bf175ecf6a8948d3d5 -size 29619 +oid sha256:17cdf7f4c862e174899a1ef838d3e587abbb616a4e7d668ec440a0bfd0c250da +size 67817 diff --git a/Content/Blueprints/WBP_ItemDisplay.uasset b/Content/Blueprints/WBP_ItemDisplay.uasset index afb5151..aa0672a 100644 --- a/Content/Blueprints/WBP_ItemDisplay.uasset +++ b/Content/Blueprints/WBP_ItemDisplay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c70ffaf4738412537996db61c6620a7f49e7fe9c07108cff72ab3738fdfe5c78 -size 80902 +oid sha256:394e6fd5c273948655cad58ad595dff0a3b24abc9279bfc1096997186314c7b8 +size 81622 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset index ce2f4e0..9d031ad 100644 --- a/Content/Blueprints/WBP_PlayerInventory.uasset +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:47660a75d7b9806d0475c43f31f887d9f7266604ce09614b958b452fadbcd6f3 -size 29178 +oid sha256:d596c831e4baffe954feea4961e34e18072e026f907adbe7824d32d2db4e2e4a +size 89851 diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp index 1fd0d31..2fac2d1 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.cpp @@ -9,3 +9,8 @@ UBaseItem::UBaseItem() ItemDisplayName = FText::FromString("ItemName"); ItemUseAction = FText::FromString("UseAction"); } + +void UBaseItem::Use(ATempCharacter* Character) +{ + +} diff --git a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h index 2782c63..47cdbcc 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h +++ b/Source/the_twilight_abyss/BaseItems/Items/BaseItem.h @@ -57,7 +57,7 @@ public: virtual void Buy(class UItemPurchaseComponent* PurchaseItem) PURE_VIRTUAL(UBaseItem); // WILL SET THIS UP LATER //The use Item class to use the item in the player Inventory - virtual void Use(class ATempCharacter* Character) PURE_VIRTUAL(UBaseItem); + virtual void Use(class ATempCharacter* Character); //This is the same as the use item class but its in BP instead UFUNCTION(BlueprintImplementableEvent) From 593badeca937b2a6b6f193e11ef1332a475751ee Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 14 Nov 2022 22:40:09 +0000 Subject: [PATCH 12/12] Updated AllInventory BP's Updated all the blueprints --- Content/Blueprints/BP_MyTempCharacter.uasset | 4 ++-- Content/Blueprints/WBP_ItemDisplay.uasset | 4 ++-- Content/Blueprints/WBP_PlayerInventory.uasset | 4 ++-- Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp | 1 + Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp | 1 - 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset index 7085e97..ed9200f 100644 --- a/Content/Blueprints/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17cdf7f4c862e174899a1ef838d3e587abbb616a4e7d668ec440a0bfd0c250da -size 67817 +oid sha256:83b78bc2c32ead48fb4b3986da18675ab1673013673104c5232b504978a0c1ad +size 68346 diff --git a/Content/Blueprints/WBP_ItemDisplay.uasset b/Content/Blueprints/WBP_ItemDisplay.uasset index aa0672a..748f45b 100644 --- a/Content/Blueprints/WBP_ItemDisplay.uasset +++ b/Content/Blueprints/WBP_ItemDisplay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:394e6fd5c273948655cad58ad595dff0a3b24abc9279bfc1096997186314c7b8 -size 81622 +oid sha256:b3326b738a1a849cc33276c0a9c12c545dee4510e510848526cc225f939996d5 +size 81310 diff --git a/Content/Blueprints/WBP_PlayerInventory.uasset b/Content/Blueprints/WBP_PlayerInventory.uasset index 9d031ad..f05676b 100644 --- a/Content/Blueprints/WBP_PlayerInventory.uasset +++ b/Content/Blueprints/WBP_PlayerInventory.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d596c831e4baffe954feea4961e34e18072e026f907adbe7824d32d2db4e2e4a -size 89851 +oid sha256:7df9350594b51cf2639b09ee43273d07e56f0328301b51d0c89b70c8edecf450 +size 90586 diff --git a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp index 30d29bd..8036177 100644 --- a/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp +++ b/Source/the_twilight_abyss/BaseItems/InventoryComponent.cpp @@ -36,6 +36,7 @@ bool UInventoryComponent::AddItem(class UBaseItem* BaseItem) { return false; } + BaseItem->StoredItems = this; BaseItem->World = GetWorld(); Items.Add(BaseItem); diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 092c3e6..d21da03 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -2,7 +2,6 @@ #include "TempCharacter.h" #include "Blueprint/UserWidget.h" -#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" #include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "the_twilight_abyss/MerchantInteraction/Interaction.h"