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
This commit is contained in:
parent
785974e169
commit
a40aa57f70
3
Content/Blueprints/Items/BP_HealingSyringe.uasset
Normal file
3
Content/Blueprints/Items/BP_HealingSyringe.uasset
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8e387511b72d482c0cef5dcaf48822ceba438b4bd0cc13ff7410220ca992f15c
|
||||
size 6030
|
3
Content/Blueprints/Items/BP_Jelly1.uasset
Normal file
3
Content/Blueprints/Items/BP_Jelly1.uasset
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6d8d52b9430b52830e8488a07bdc388bb5a602828a0b898e727c18aeb583fffb
|
||||
size 5894
|
3
Content/Blueprints/Items/BP_Jelly2.uasset
Normal file
3
Content/Blueprints/Items/BP_Jelly2.uasset
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:302db81a27f3921406ca175911dd01315a52040b80af2d5515e150f169383463
|
||||
size 5894
|
3
Content/Blueprints/Items/BP_Jelly3.uasset
Normal file
3
Content/Blueprints/Items/BP_Jelly3.uasset
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6b443f673bb208fa1d7dd5a10319aaf03d7173f4232adda4d9e692895c6c6ade
|
||||
size 5894
|
@ -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();
|
||||
|
||||
// ...
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Called every frame
|
||||
void UInventoryComponent::TickComponent(float DeltaTime, ELevelTick TickType,FActorComponentTickFunction* ThisTickFunction)
|
||||
for(auto & BaseItem : DefaultItems)
|
||||
{
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
// ...
|
||||
AddItem(BaseItem);
|
||||
}
|
||||
}
|
||||
|
||||
bool UInventoryComponent::AddItem(class UBaseItem* BaseItem)
|
||||
{
|
||||
//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;
|
||||
}
|
||||
|
||||
|
@ -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<class UBaseItem*> 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<class UBaseItem*> Items; // The items currently in the inventory
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "UObject/Object.h"
|
||||
#include "BaseItem.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -15,8 +16,13 @@ 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")
|
||||
FText ItemUseAction;
|
||||
|
@ -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)
|
||||
{
|
@ -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()
|
||||
|
@ -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<UInventoryComponent>("Inventory");
|
||||
Inventory->MaxItemSlots = 10;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
|
Loading…
Reference in New Issue
Block a user